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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FStar.HyperStack.ST.Stack | val crypto_kem_enc_ss:
a:FP.frodo_alg
-> k:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h k /\ live h ct /\ live h ss /\
disjoint ct ss /\ disjoint k ct /\ disjoint k ss)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_enc_ss a (as_seq h0 k) (as_seq h0 ct)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let crypto_kem_enc_ss a k ct ss =
push_frame ();
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let shake_input_ss = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) k shake_input_ss;
frodo_shake a ss_init_len shake_input_ss (crypto_bytes a) ss;
clear_words_u8 shake_input_ss;
pop_frame () | val crypto_kem_enc_ss:
a:FP.frodo_alg
-> k:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h k /\ live h ct /\ live h ss /\
disjoint ct ss /\ disjoint k ct /\ disjoint k ss)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_enc_ss a (as_seq h0 k) (as_seq h0 ct))
let crypto_kem_enc_ss a k ct ss = | true | null | false | push_frame ();
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let shake_input_ss = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) k shake_input_ss;
frodo_shake a ss_init_len shake_input_ss (crypto_bytes a) ss;
clear_words_u8 shake_input_ss;
pop_frame () | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Frodo.KEM.clear_words_u8",
"Hacl.Impl.Frodo.Params.frodo_shake",
"Lib.Buffer.concat2",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.op_Plus_Bang",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 =
push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se))
let get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix =
push_frame ();
[@inline_let] let s_bytes_len = secretmatrixbytes_len a in
let r = create (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) (u8 0) in
KG.frodo_shake_r a (u8 0x96) seed_se (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) r;
frodo_sample_matrix a params_nbar (params_n a) (sub r 0ul s_bytes_len) sp_matrix;
frodo_sample_matrix a params_nbar (params_n a) (sub r s_bytes_len s_bytes_len) ep_matrix;
frodo_sample_matrix a params_nbar params_nbar (sub r (2ul *! s_bytes_len) (2ul *! params_nbar *! params_nbar)) epp_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2))
let crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
let h0 = ST.get () in
crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1;
let h1 = ST.get () in
crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 ct) 0 (v (ct1bytes_len a)))
(LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)));
LSeq.lemma_concat2
(v (ct1bytes_len a)) (LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)))
(v (ct2bytes_len a)) (LSeq.sub (as_seq h2 ct) (v (ct1bytes_len a)) (v (ct2bytes_len a))) (as_seq h2 ct)
inline_for_extraction noextract
val clear_matrix3:
a:FP.frodo_alg
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint sp_matrix ep_matrix /\ disjoint sp_matrix epp_matrix /\
disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 ->
modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1)
let clear_matrix3 a sp_matrix ep_matrix epp_matrix =
clear_matrix sp_matrix;
clear_matrix ep_matrix;
clear_matrix epp_matrix
inline_for_extraction noextract
val crypto_kem_enc_ct:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se /\ live h ct /\
disjoint ct mu /\ disjoint ct pk /\ disjoint ct seed_se)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct a gen_a mu pk seed_se ct =
push_frame ();
let h0 = ST.get () in
FP.expand_crypto_publickeybytes a;
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (publicmatrixbytes_len a) in
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 ct)
(S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se));
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_enc_ss:
a:FP.frodo_alg
-> k:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h k /\ live h ct /\ live h ss /\
disjoint ct ss /\ disjoint k ct /\ disjoint k ss)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_enc_ss a (as_seq h0 k) (as_seq h0 ct)) | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val crypto_kem_enc_ss:
a:FP.frodo_alg
-> k:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h k /\ live h ct /\ live h ss /\
disjoint ct ss /\ disjoint k ct /\ disjoint k ss)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_enc_ss a (as_seq h0 k) (as_seq h0 ct)) | [] | Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ss | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
k: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) ->
ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 304,
"start_col": 2,
"start_line": 298
} |
FStar.HyperStack.ST.Stack | val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame () | val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix = | true | null | false | push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame () | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.bytes_seed_a",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Matrix.matrix_add",
"Hacl.Impl.Matrix.matrix_mul",
"Hacl.Impl.Frodo.Params.frodo_gen_matrix",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Matrix.matrix_create",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix)) | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix)) | [] | Hacl.Impl.Frodo.KEM.Encaps.frodo_mul_add_sa_plus_e | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
seed_a: Hacl.Impl.Matrix.lbytes Hacl.Impl.Frodo.Params.bytes_seed_a ->
sp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
ep_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
bp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 53,
"start_col": 2,
"start_line": 48
} |
FStar.HyperStack.ST.Stack | val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame () | val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix = | true | null | false | push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame () | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.publicmatrixbytes_len",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Matrix.matrix_add",
"Hacl.Impl.Matrix.matrix_mul",
"Hacl.Impl.Frodo.Pack.frodo_unpack",
"Hacl.Impl.Frodo.Params.params_logq",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Matrix.matrix_create",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix)) | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix)) | [] | Hacl.Impl.Frodo.KEM.Encaps.frodo_mul_add_sb_plus_e | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
b: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.publicmatrixbytes_len a) ->
sp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
epp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
Hacl.Impl.Frodo.Params.params_nbar ->
v_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
Hacl.Impl.Frodo.Params.params_nbar
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 101,
"start_col": 2,
"start_line": 96
} |
FStar.HyperStack.ST.Stack | val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame () | val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 = | true | null | false | push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame () | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.bytes_seed_a",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"Hacl.Impl.Frodo.Params.ct1bytes_len",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Frodo.Pack.frodo_pack",
"Hacl.Impl.Frodo.Params.params_logq",
"Hacl.Impl.Frodo.KEM.Encaps.frodo_mul_add_sa_plus_e",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Matrix.matrix_create",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix)) | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix)) | [] | Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ct_pack_c1 | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
seed_a: Hacl.Impl.Matrix.lbytes Hacl.Impl.Frodo.Params.bytes_seed_a ->
sp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
ep_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
c1: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.ct1bytes_len a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 77,
"start_col": 2,
"start_line": 73
} |
FStar.HyperStack.ST.Stack | val crypto_kem_enc_seed_se_k:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se_k /\
disjoint seed_se_k mu /\ disjoint seed_se_k pk)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_enc_seed_se_k a (as_seq h0 mu) (as_seq h0 pk)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let crypto_kem_enc_seed_se_k a mu pk seed_se_k =
push_frame ();
let pkh_mu = create (bytes_pkhash a +! bytes_mu a) (u8 0) in
let h0 = ST.get () in
update_sub_f h0 pkh_mu 0ul (bytes_pkhash a)
(fun h -> FP.frodo_shake a (v (crypto_publickeybytes a)) (as_seq h0 pk) (v (bytes_pkhash a)))
(fun _ -> frodo_shake a (crypto_publickeybytes a) pk (bytes_pkhash a) (sub pkh_mu 0ul (bytes_pkhash a)));
let h1 = ST.get () in
update_sub pkh_mu (bytes_pkhash a) (bytes_mu a) mu;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 pkh_mu) 0 (v (bytes_pkhash a)))
(LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)));
LSeq.lemma_concat2
(v (bytes_pkhash a)) (LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)))
(v (bytes_mu a)) (as_seq h0 mu) (as_seq h2 pkh_mu);
//concat2 (bytes_pkhash a) pkh (bytes_mu a) mu pkh_mu;
frodo_shake a (bytes_pkhash a +! bytes_mu a) pkh_mu (2ul *! crypto_bytes a) seed_se_k;
pop_frame () | val crypto_kem_enc_seed_se_k:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se_k /\
disjoint seed_se_k mu /\ disjoint seed_se_k pk)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_enc_seed_se_k a (as_seq h0 mu) (as_seq h0 pk))
let crypto_kem_enc_seed_se_k a mu pk seed_se_k = | true | null | false | push_frame ();
let pkh_mu = create (bytes_pkhash a +! bytes_mu a) (u8 0) in
let h0 = ST.get () in
update_sub_f h0
pkh_mu
0ul
(bytes_pkhash a)
(fun h -> FP.frodo_shake a (v (crypto_publickeybytes a)) (as_seq h0 pk) (v (bytes_pkhash a)))
(fun _ ->
frodo_shake a (crypto_publickeybytes a) pk (bytes_pkhash a) (sub pkh_mu 0ul (bytes_pkhash a)));
let h1 = ST.get () in
update_sub pkh_mu (bytes_pkhash a) (bytes_mu a) mu;
let h2 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h2 pkh_mu) 0 (v (bytes_pkhash a)))
(LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)));
LSeq.lemma_concat2 (v (bytes_pkhash a))
(LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)))
(v (bytes_mu a))
(as_seq h0 mu)
(as_seq h2 pkh_mu);
frodo_shake a (bytes_pkhash a +! bytes_mu a) pkh_mu (2ul *! crypto_bytes a) seed_se_k;
pop_frame () | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Frodo.Params.crypto_publickeybytes",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Frodo.Params.frodo_shake",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Impl.Frodo.Params.bytes_pkhash",
"Lib.Sequence.lemma_concat2",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.v",
"Lib.Sequence.sub",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.Sequence.eq_intro",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.update_sub",
"Lib.Buffer.update_sub_f",
"Spec.Frodo.Params.frodo_shake",
"Lib.Sequence.lseq",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.Buffer.sub",
"Lib.IntTypes.add",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 =
push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se))
let get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix =
push_frame ();
[@inline_let] let s_bytes_len = secretmatrixbytes_len a in
let r = create (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) (u8 0) in
KG.frodo_shake_r a (u8 0x96) seed_se (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) r;
frodo_sample_matrix a params_nbar (params_n a) (sub r 0ul s_bytes_len) sp_matrix;
frodo_sample_matrix a params_nbar (params_n a) (sub r s_bytes_len s_bytes_len) ep_matrix;
frodo_sample_matrix a params_nbar params_nbar (sub r (2ul *! s_bytes_len) (2ul *! params_nbar *! params_nbar)) epp_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2))
let crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
let h0 = ST.get () in
crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1;
let h1 = ST.get () in
crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 ct) 0 (v (ct1bytes_len a)))
(LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)));
LSeq.lemma_concat2
(v (ct1bytes_len a)) (LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)))
(v (ct2bytes_len a)) (LSeq.sub (as_seq h2 ct) (v (ct1bytes_len a)) (v (ct2bytes_len a))) (as_seq h2 ct)
inline_for_extraction noextract
val clear_matrix3:
a:FP.frodo_alg
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint sp_matrix ep_matrix /\ disjoint sp_matrix epp_matrix /\
disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 ->
modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1)
let clear_matrix3 a sp_matrix ep_matrix epp_matrix =
clear_matrix sp_matrix;
clear_matrix ep_matrix;
clear_matrix epp_matrix
inline_for_extraction noextract
val crypto_kem_enc_ct:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se /\ live h ct /\
disjoint ct mu /\ disjoint ct pk /\ disjoint ct seed_se)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct a gen_a mu pk seed_se ct =
push_frame ();
let h0 = ST.get () in
FP.expand_crypto_publickeybytes a;
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (publicmatrixbytes_len a) in
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 ct)
(S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se));
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_enc_ss:
a:FP.frodo_alg
-> k:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h k /\ live h ct /\ live h ss /\
disjoint ct ss /\ disjoint k ct /\ disjoint k ss)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_enc_ss a (as_seq h0 k) (as_seq h0 ct))
let crypto_kem_enc_ss a k ct ss =
push_frame ();
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let shake_input_ss = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) k shake_input_ss;
frodo_shake a ss_init_len shake_input_ss (crypto_bytes a) ss;
clear_words_u8 shake_input_ss;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_seed_se_k:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se_k /\
disjoint seed_se_k mu /\ disjoint seed_se_k pk)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_enc_seed_se_k a (as_seq h0 mu) (as_seq h0 pk)) | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val crypto_kem_enc_seed_se_k:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se_k /\
disjoint seed_se_k mu /\ disjoint seed_se_k pk)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_enc_seed_se_k a (as_seq h0 mu) (as_seq h0 pk)) | [] | Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_seed_se_k | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
mu: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
pk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_publickeybytes a) ->
seed_se_k: Hacl.Impl.Matrix.lbytes (2ul *! Hacl.Impl.Frodo.Params.crypto_bytes a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 339,
"start_col": 2,
"start_line": 321
} |
FStar.HyperStack.ST.Stack | val crypto_kem_enc_ct_ss:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h seed_se_k /\ live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint seed_se_k ct /\ disjoint seed_se_k ss)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(let seed_se = LSeq.sub (as_seq h0 seed_se_k) 0 (v (crypto_bytes a)) in
let k = LSeq.sub (as_seq h0 seed_se_k) (v (crypto_bytes a)) (v (crypto_bytes a)) in
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) seed_se /\
as_seq h1 ss == S.crypto_kem_enc_ss a k (as_seq h1 ct))) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk =
let seed_se = sub seed_se_k 0ul (crypto_bytes a) in
let k = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in
crypto_kem_enc_ct a gen_a mu pk seed_se ct;
crypto_kem_enc_ss a k ct ss | val crypto_kem_enc_ct_ss:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h seed_se_k /\ live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint seed_se_k ct /\ disjoint seed_se_k ss)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(let seed_se = LSeq.sub (as_seq h0 seed_se_k) 0 (v (crypto_bytes a)) in
let k = LSeq.sub (as_seq h0 seed_se_k) (v (crypto_bytes a)) (v (crypto_bytes a)) in
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) seed_se /\
as_seq h1 ss == S.crypto_kem_enc_ss a k (as_seq h1 ct)))
let crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk = | true | null | false | let seed_se = sub seed_se_k 0ul (crypto_bytes a) in
let k = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in
crypto_kem_enc_ct a gen_a mu pk seed_se ct;
crypto_kem_enc_ss a k ct ss | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_publickeybytes",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ss",
"Prims.unit",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ct",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"Lib.IntTypes.uint8"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 =
push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se))
let get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix =
push_frame ();
[@inline_let] let s_bytes_len = secretmatrixbytes_len a in
let r = create (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) (u8 0) in
KG.frodo_shake_r a (u8 0x96) seed_se (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) r;
frodo_sample_matrix a params_nbar (params_n a) (sub r 0ul s_bytes_len) sp_matrix;
frodo_sample_matrix a params_nbar (params_n a) (sub r s_bytes_len s_bytes_len) ep_matrix;
frodo_sample_matrix a params_nbar params_nbar (sub r (2ul *! s_bytes_len) (2ul *! params_nbar *! params_nbar)) epp_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2))
let crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
let h0 = ST.get () in
crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1;
let h1 = ST.get () in
crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 ct) 0 (v (ct1bytes_len a)))
(LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)));
LSeq.lemma_concat2
(v (ct1bytes_len a)) (LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)))
(v (ct2bytes_len a)) (LSeq.sub (as_seq h2 ct) (v (ct1bytes_len a)) (v (ct2bytes_len a))) (as_seq h2 ct)
inline_for_extraction noextract
val clear_matrix3:
a:FP.frodo_alg
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint sp_matrix ep_matrix /\ disjoint sp_matrix epp_matrix /\
disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 ->
modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1)
let clear_matrix3 a sp_matrix ep_matrix epp_matrix =
clear_matrix sp_matrix;
clear_matrix ep_matrix;
clear_matrix epp_matrix
inline_for_extraction noextract
val crypto_kem_enc_ct:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se /\ live h ct /\
disjoint ct mu /\ disjoint ct pk /\ disjoint ct seed_se)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct a gen_a mu pk seed_se ct =
push_frame ();
let h0 = ST.get () in
FP.expand_crypto_publickeybytes a;
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (publicmatrixbytes_len a) in
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 ct)
(S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se));
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_enc_ss:
a:FP.frodo_alg
-> k:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h k /\ live h ct /\ live h ss /\
disjoint ct ss /\ disjoint k ct /\ disjoint k ss)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_enc_ss a (as_seq h0 k) (as_seq h0 ct))
let crypto_kem_enc_ss a k ct ss =
push_frame ();
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let shake_input_ss = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) k shake_input_ss;
frodo_shake a ss_init_len shake_input_ss (crypto_bytes a) ss;
clear_words_u8 shake_input_ss;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_seed_se_k:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se_k /\
disjoint seed_se_k mu /\ disjoint seed_se_k pk)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_enc_seed_se_k a (as_seq h0 mu) (as_seq h0 pk))
let crypto_kem_enc_seed_se_k a mu pk seed_se_k =
push_frame ();
let pkh_mu = create (bytes_pkhash a +! bytes_mu a) (u8 0) in
let h0 = ST.get () in
update_sub_f h0 pkh_mu 0ul (bytes_pkhash a)
(fun h -> FP.frodo_shake a (v (crypto_publickeybytes a)) (as_seq h0 pk) (v (bytes_pkhash a)))
(fun _ -> frodo_shake a (crypto_publickeybytes a) pk (bytes_pkhash a) (sub pkh_mu 0ul (bytes_pkhash a)));
let h1 = ST.get () in
update_sub pkh_mu (bytes_pkhash a) (bytes_mu a) mu;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 pkh_mu) 0 (v (bytes_pkhash a)))
(LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)));
LSeq.lemma_concat2
(v (bytes_pkhash a)) (LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)))
(v (bytes_mu a)) (as_seq h0 mu) (as_seq h2 pkh_mu);
//concat2 (bytes_pkhash a) pkh (bytes_mu a) mu pkh_mu;
frodo_shake a (bytes_pkhash a +! bytes_mu a) pkh_mu (2ul *! crypto_bytes a) seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_ss:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h seed_se_k /\ live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint seed_se_k ct /\ disjoint seed_se_k ss)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(let seed_se = LSeq.sub (as_seq h0 seed_se_k) 0 (v (crypto_bytes a)) in
let k = LSeq.sub (as_seq h0 seed_se_k) (v (crypto_bytes a)) (v (crypto_bytes a)) in
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) seed_se /\
as_seq h1 ss == S.crypto_kem_enc_ss a k (as_seq h1 ct))) | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val crypto_kem_enc_ct_ss:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h seed_se_k /\ live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint seed_se_k ct /\ disjoint seed_se_k ss)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(let seed_se = LSeq.sub (as_seq h0 seed_se_k) 0 (v (crypto_bytes a)) in
let k = LSeq.sub (as_seq h0 seed_se_k) (v (crypto_bytes a)) (v (crypto_bytes a)) in
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) seed_se /\
as_seq h1 ss == S.crypto_kem_enc_ss a k (as_seq h1 ct))) | [] | Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ct_ss | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
seed_se_k: Hacl.Impl.Matrix.lbytes (2ul *! Hacl.Impl.Frodo.Params.crypto_bytes a) ->
mu: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) ->
ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) ->
pk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_publickeybytes a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 29,
"end_line": 366,
"start_col": 56,
"start_line": 362
} |
FStar.HyperStack.ST.Stack | val crypto_kem_enc_:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint mu pk)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let crypto_kem_enc_ a gen_a mu ct ss pk =
push_frame ();
let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in
crypto_kem_enc0 a gen_a mu ct ss pk seed_se_k;
clear_words_u8 seed_se_k;
pop_frame () | val crypto_kem_enc_:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint mu pk)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk))
let crypto_kem_enc_ a gen_a mu ct ss pk = | true | null | false | push_frame ();
let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in
crypto_kem_enc0 a gen_a mu ct ss pk seed_se_k;
clear_words_u8 seed_se_k;
pop_frame () | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_publickeybytes",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Frodo.KEM.clear_words_u8",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc0",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.uint8",
"Lib.IntTypes.u8",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 =
push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se))
let get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix =
push_frame ();
[@inline_let] let s_bytes_len = secretmatrixbytes_len a in
let r = create (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) (u8 0) in
KG.frodo_shake_r a (u8 0x96) seed_se (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) r;
frodo_sample_matrix a params_nbar (params_n a) (sub r 0ul s_bytes_len) sp_matrix;
frodo_sample_matrix a params_nbar (params_n a) (sub r s_bytes_len s_bytes_len) ep_matrix;
frodo_sample_matrix a params_nbar params_nbar (sub r (2ul *! s_bytes_len) (2ul *! params_nbar *! params_nbar)) epp_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2))
let crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
let h0 = ST.get () in
crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1;
let h1 = ST.get () in
crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 ct) 0 (v (ct1bytes_len a)))
(LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)));
LSeq.lemma_concat2
(v (ct1bytes_len a)) (LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)))
(v (ct2bytes_len a)) (LSeq.sub (as_seq h2 ct) (v (ct1bytes_len a)) (v (ct2bytes_len a))) (as_seq h2 ct)
inline_for_extraction noextract
val clear_matrix3:
a:FP.frodo_alg
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint sp_matrix ep_matrix /\ disjoint sp_matrix epp_matrix /\
disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 ->
modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1)
let clear_matrix3 a sp_matrix ep_matrix epp_matrix =
clear_matrix sp_matrix;
clear_matrix ep_matrix;
clear_matrix epp_matrix
inline_for_extraction noextract
val crypto_kem_enc_ct:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se /\ live h ct /\
disjoint ct mu /\ disjoint ct pk /\ disjoint ct seed_se)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct a gen_a mu pk seed_se ct =
push_frame ();
let h0 = ST.get () in
FP.expand_crypto_publickeybytes a;
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (publicmatrixbytes_len a) in
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 ct)
(S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se));
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_enc_ss:
a:FP.frodo_alg
-> k:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h k /\ live h ct /\ live h ss /\
disjoint ct ss /\ disjoint k ct /\ disjoint k ss)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_enc_ss a (as_seq h0 k) (as_seq h0 ct))
let crypto_kem_enc_ss a k ct ss =
push_frame ();
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let shake_input_ss = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) k shake_input_ss;
frodo_shake a ss_init_len shake_input_ss (crypto_bytes a) ss;
clear_words_u8 shake_input_ss;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_seed_se_k:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se_k /\
disjoint seed_se_k mu /\ disjoint seed_se_k pk)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_enc_seed_se_k a (as_seq h0 mu) (as_seq h0 pk))
let crypto_kem_enc_seed_se_k a mu pk seed_se_k =
push_frame ();
let pkh_mu = create (bytes_pkhash a +! bytes_mu a) (u8 0) in
let h0 = ST.get () in
update_sub_f h0 pkh_mu 0ul (bytes_pkhash a)
(fun h -> FP.frodo_shake a (v (crypto_publickeybytes a)) (as_seq h0 pk) (v (bytes_pkhash a)))
(fun _ -> frodo_shake a (crypto_publickeybytes a) pk (bytes_pkhash a) (sub pkh_mu 0ul (bytes_pkhash a)));
let h1 = ST.get () in
update_sub pkh_mu (bytes_pkhash a) (bytes_mu a) mu;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 pkh_mu) 0 (v (bytes_pkhash a)))
(LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)));
LSeq.lemma_concat2
(v (bytes_pkhash a)) (LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)))
(v (bytes_mu a)) (as_seq h0 mu) (as_seq h2 pkh_mu);
//concat2 (bytes_pkhash a) pkh (bytes_mu a) mu pkh_mu;
frodo_shake a (bytes_pkhash a +! bytes_mu a) pkh_mu (2ul *! crypto_bytes a) seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_ss:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h seed_se_k /\ live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint seed_se_k ct /\ disjoint seed_se_k ss)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(let seed_se = LSeq.sub (as_seq h0 seed_se_k) 0 (v (crypto_bytes a)) in
let k = LSeq.sub (as_seq h0 seed_se_k) (v (crypto_bytes a)) (v (crypto_bytes a)) in
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) seed_se /\
as_seq h1 ss == S.crypto_kem_enc_ss a k (as_seq h1 ct)))
let crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk =
let seed_se = sub seed_se_k 0ul (crypto_bytes a) in
let k = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in
crypto_kem_enc_ct a gen_a mu pk seed_se ct;
crypto_kem_enc_ss a k ct ss
inline_for_extraction noextract
val crypto_kem_enc0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\ live h seed_se_k /\
loc_pairwise_disjoint [loc mu; loc ct; loc ss; loc pk; loc seed_se_k])
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss |+| loc seed_se_k) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk))
#push-options "--z3rlimit 200"
let crypto_kem_enc0 a gen_a mu ct ss pk seed_se_k =
crypto_kem_enc_seed_se_k a mu pk seed_se_k;
crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk
#pop-options
inline_for_extraction noextract
val crypto_kem_enc_:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint mu pk)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk)) | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val crypto_kem_enc_:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint mu pk)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk)) | [] | Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
mu: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) ->
ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) ->
pk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_publickeybytes a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 412,
"start_col": 2,
"start_line": 408
} |
FStar.HyperStack.ST.Stack | val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix =
push_frame ();
[@inline_let] let s_bytes_len = secretmatrixbytes_len a in
let r = create (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) (u8 0) in
KG.frodo_shake_r a (u8 0x96) seed_se (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) r;
frodo_sample_matrix a params_nbar (params_n a) (sub r 0ul s_bytes_len) sp_matrix;
frodo_sample_matrix a params_nbar (params_n a) (sub r s_bytes_len s_bytes_len) ep_matrix;
frodo_sample_matrix a params_nbar params_nbar (sub r (2ul *! s_bytes_len) (2ul *! params_nbar *! params_nbar)) epp_matrix;
pop_frame () | val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se))
let get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix = | true | null | false | push_frame ();
[@@ inline_let ]let s_bytes_len = secretmatrixbytes_len a in
let r = create (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) (u8 0) in
KG.frodo_shake_r a (u8 0x96) seed_se (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) r;
frodo_sample_matrix a params_nbar (params_n a) (sub r 0ul s_bytes_len) sp_matrix;
frodo_sample_matrix a params_nbar (params_n a) (sub r s_bytes_len s_bytes_len) ep_matrix;
frodo_sample_matrix a
params_nbar
params_nbar
(sub r (2ul *! s_bytes_len) (2ul *! params_nbar *! params_nbar))
epp_matrix;
pop_frame () | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Frodo.Sample.frodo_sample_matrix",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Frodo.KEM.KeyGen.frodo_shake_r",
"Lib.IntTypes.u8",
"Lib.IntTypes.add",
"Lib.Buffer.create",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Frodo.Params.secretmatrixbytes_len",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 =
push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se)) | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se)) | [] | Hacl.Impl.Frodo.KEM.Encaps.get_sp_ep_epp_matrices | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
seed_se: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) ->
sp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
ep_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
epp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
Hacl.Impl.Frodo.Params.params_nbar
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 186,
"start_col": 2,
"start_line": 179
} |
FStar.HyperStack.ST.Stack | val crypto_kem_enc:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack uint32
(requires fun h ->
disjoint state ct /\ disjoint state ss /\ disjoint state pk /\
live h ct /\ live h ss /\ live h pk /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk)
(ensures fun h0 _ h1 -> modifies (loc state |+| (loc ct |+| loc ss)) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc a gen_a (as_seq h0 state) (as_seq h0 pk)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let crypto_kem_enc a gen_a ct ss pk =
recall state;
push_frame ();
let coins = create (bytes_mu a) (u8 0) in
recall state;
randombytes_ (bytes_mu a) coins;
crypto_kem_enc_ a gen_a coins ct ss pk;
clear_words_u8 coins;
pop_frame ();
u32 0 | val crypto_kem_enc:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack uint32
(requires fun h ->
disjoint state ct /\ disjoint state ss /\ disjoint state pk /\
live h ct /\ live h ss /\ live h pk /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk)
(ensures fun h0 _ h1 -> modifies (loc state |+| (loc ct |+| loc ss)) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc a gen_a (as_seq h0 state) (as_seq h0 pk))
let crypto_kem_enc a gen_a ct ss pk = | true | null | false | recall state;
push_frame ();
let coins = create (bytes_mu a) (u8 0) in
recall state;
randombytes_ (bytes_mu a) coins;
crypto_kem_enc_ a gen_a coins ct ss pk;
clear_words_u8 coins;
pop_frame ();
u32 0 | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_publickeybytes",
"Lib.IntTypes.u32",
"Lib.IntTypes.uint32",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Hacl.Impl.Frodo.KEM.clear_words_u8",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_",
"Hacl.Frodo.Random.randombytes_",
"Lib.Buffer.recall",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Frodo.Random.state",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 =
push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se))
let get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix =
push_frame ();
[@inline_let] let s_bytes_len = secretmatrixbytes_len a in
let r = create (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) (u8 0) in
KG.frodo_shake_r a (u8 0x96) seed_se (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) r;
frodo_sample_matrix a params_nbar (params_n a) (sub r 0ul s_bytes_len) sp_matrix;
frodo_sample_matrix a params_nbar (params_n a) (sub r s_bytes_len s_bytes_len) ep_matrix;
frodo_sample_matrix a params_nbar params_nbar (sub r (2ul *! s_bytes_len) (2ul *! params_nbar *! params_nbar)) epp_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2))
let crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
let h0 = ST.get () in
crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1;
let h1 = ST.get () in
crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 ct) 0 (v (ct1bytes_len a)))
(LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)));
LSeq.lemma_concat2
(v (ct1bytes_len a)) (LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)))
(v (ct2bytes_len a)) (LSeq.sub (as_seq h2 ct) (v (ct1bytes_len a)) (v (ct2bytes_len a))) (as_seq h2 ct)
inline_for_extraction noextract
val clear_matrix3:
a:FP.frodo_alg
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint sp_matrix ep_matrix /\ disjoint sp_matrix epp_matrix /\
disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 ->
modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1)
let clear_matrix3 a sp_matrix ep_matrix epp_matrix =
clear_matrix sp_matrix;
clear_matrix ep_matrix;
clear_matrix epp_matrix
inline_for_extraction noextract
val crypto_kem_enc_ct:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se /\ live h ct /\
disjoint ct mu /\ disjoint ct pk /\ disjoint ct seed_se)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct a gen_a mu pk seed_se ct =
push_frame ();
let h0 = ST.get () in
FP.expand_crypto_publickeybytes a;
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (publicmatrixbytes_len a) in
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 ct)
(S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se));
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_enc_ss:
a:FP.frodo_alg
-> k:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h k /\ live h ct /\ live h ss /\
disjoint ct ss /\ disjoint k ct /\ disjoint k ss)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_enc_ss a (as_seq h0 k) (as_seq h0 ct))
let crypto_kem_enc_ss a k ct ss =
push_frame ();
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let shake_input_ss = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) k shake_input_ss;
frodo_shake a ss_init_len shake_input_ss (crypto_bytes a) ss;
clear_words_u8 shake_input_ss;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_seed_se_k:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se_k /\
disjoint seed_se_k mu /\ disjoint seed_se_k pk)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_enc_seed_se_k a (as_seq h0 mu) (as_seq h0 pk))
let crypto_kem_enc_seed_se_k a mu pk seed_se_k =
push_frame ();
let pkh_mu = create (bytes_pkhash a +! bytes_mu a) (u8 0) in
let h0 = ST.get () in
update_sub_f h0 pkh_mu 0ul (bytes_pkhash a)
(fun h -> FP.frodo_shake a (v (crypto_publickeybytes a)) (as_seq h0 pk) (v (bytes_pkhash a)))
(fun _ -> frodo_shake a (crypto_publickeybytes a) pk (bytes_pkhash a) (sub pkh_mu 0ul (bytes_pkhash a)));
let h1 = ST.get () in
update_sub pkh_mu (bytes_pkhash a) (bytes_mu a) mu;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 pkh_mu) 0 (v (bytes_pkhash a)))
(LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)));
LSeq.lemma_concat2
(v (bytes_pkhash a)) (LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)))
(v (bytes_mu a)) (as_seq h0 mu) (as_seq h2 pkh_mu);
//concat2 (bytes_pkhash a) pkh (bytes_mu a) mu pkh_mu;
frodo_shake a (bytes_pkhash a +! bytes_mu a) pkh_mu (2ul *! crypto_bytes a) seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_ss:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h seed_se_k /\ live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint seed_se_k ct /\ disjoint seed_se_k ss)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(let seed_se = LSeq.sub (as_seq h0 seed_se_k) 0 (v (crypto_bytes a)) in
let k = LSeq.sub (as_seq h0 seed_se_k) (v (crypto_bytes a)) (v (crypto_bytes a)) in
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) seed_se /\
as_seq h1 ss == S.crypto_kem_enc_ss a k (as_seq h1 ct)))
let crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk =
let seed_se = sub seed_se_k 0ul (crypto_bytes a) in
let k = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in
crypto_kem_enc_ct a gen_a mu pk seed_se ct;
crypto_kem_enc_ss a k ct ss
inline_for_extraction noextract
val crypto_kem_enc0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\ live h seed_se_k /\
loc_pairwise_disjoint [loc mu; loc ct; loc ss; loc pk; loc seed_se_k])
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss |+| loc seed_se_k) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk))
#push-options "--z3rlimit 200"
let crypto_kem_enc0 a gen_a mu ct ss pk seed_se_k =
crypto_kem_enc_seed_se_k a mu pk seed_se_k;
crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk
#pop-options
inline_for_extraction noextract
val crypto_kem_enc_:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint mu pk)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk))
let crypto_kem_enc_ a gen_a mu ct ss pk =
push_frame ();
let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in
crypto_kem_enc0 a gen_a mu ct ss pk seed_se_k;
clear_words_u8 seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack uint32
(requires fun h ->
disjoint state ct /\ disjoint state ss /\ disjoint state pk /\
live h ct /\ live h ss /\ live h pk /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk)
(ensures fun h0 _ h1 -> modifies (loc state |+| (loc ct |+| loc ss)) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc a gen_a (as_seq h0 state) (as_seq h0 pk)) | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val crypto_kem_enc:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack uint32
(requires fun h ->
disjoint state ct /\ disjoint state ss /\ disjoint state pk /\
live h ct /\ live h ss /\ live h pk /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk)
(ensures fun h0 _ h1 -> modifies (loc state |+| (loc ct |+| loc ss)) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc a gen_a (as_seq h0 state) (as_seq h0 pk)) | [] | Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) ->
ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) ->
pk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_publickeybytes a)
-> FStar.HyperStack.ST.Stack Lib.IntTypes.uint32 | {
"end_col": 7,
"end_line": 439,
"start_col": 2,
"start_line": 431
} |
FStar.HyperStack.ST.Stack | val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame () | val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix = | true | null | false | push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame () | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Frodo.Params.publicmatrixbytes_len",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Frodo.KEM.clear_matrix",
"Hacl.Impl.Matrix.matrix_add",
"Hacl.Impl.Frodo.Encode.frodo_key_encode",
"Hacl.Impl.Frodo.Params.params_logq",
"Hacl.Impl.Frodo.Params.params_extracted_bits",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Matrix.matrix_create",
"Hacl.Impl.Frodo.KEM.Encaps.frodo_mul_add_sb_plus_e",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix)) | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix)) | [] | Hacl.Impl.Frodo.KEM.Encaps.frodo_mul_add_sb_plus_e_plus_mu | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
mu: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
b: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.publicmatrixbytes_len a) ->
sp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
epp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
Hacl.Impl.Frodo.Params.params_nbar ->
v_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
Hacl.Impl.Frodo.Params.params_nbar
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 129,
"start_col": 2,
"start_line": 123
} |
FStar.HyperStack.ST.Stack | val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
let h0 = ST.get () in
crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1;
let h1 = ST.get () in
crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 ct) 0 (v (ct1bytes_len a)))
(LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)));
LSeq.lemma_concat2
(v (ct1bytes_len a)) (LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)))
(v (ct2bytes_len a)) (LSeq.sub (as_seq h2 ct) (v (ct1bytes_len a)) (v (ct2bytes_len a))) (as_seq h2 ct) | val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2))
let crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct = | true | null | false | let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
let h0 = ST.get () in
crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1;
let h1 = ST.get () in
crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2;
let h2 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h2 ct) 0 (v (ct1bytes_len a)))
(LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)));
LSeq.lemma_concat2 (v (ct1bytes_len a))
(LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)))
(v (ct2bytes_len a))
(LSeq.sub (as_seq h2 ct) (v (ct1bytes_len a)) (v (ct2bytes_len a)))
(as_seq h2 ct) | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.bytes_seed_a",
"Hacl.Impl.Frodo.Params.publicmatrixbytes_len",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Lib.Sequence.lemma_concat2",
"Lib.IntTypes.uint8",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Frodo.Params.ct1bytes_len",
"Lib.Sequence.sub",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Impl.Frodo.Params.ct2bytes_len",
"Prims.unit",
"Lib.Sequence.eq_intro",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ct_pack_c2",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ct_pack_c1",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 =
push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se))
let get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix =
push_frame ();
[@inline_let] let s_bytes_len = secretmatrixbytes_len a in
let r = create (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) (u8 0) in
KG.frodo_shake_r a (u8 0x96) seed_se (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) r;
frodo_sample_matrix a params_nbar (params_n a) (sub r 0ul s_bytes_len) sp_matrix;
frodo_sample_matrix a params_nbar (params_n a) (sub r s_bytes_len s_bytes_len) ep_matrix;
frodo_sample_matrix a params_nbar params_nbar (sub r (2ul *! s_bytes_len) (2ul *! params_nbar *! params_nbar)) epp_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2)) | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2)) | [] | Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ct0 | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
seed_a: Hacl.Impl.Matrix.lbytes Hacl.Impl.Frodo.Params.bytes_seed_a ->
b: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.publicmatrixbytes_len a) ->
mu: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
sp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
ep_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
epp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
Hacl.Impl.Frodo.Params.params_nbar ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 107,
"end_line": 225,
"start_col": 78,
"start_line": 212
} |
FStar.HyperStack.ST.Stack | val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 =
push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame () | val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 = | true | null | false | push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame () | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Frodo.Params.publicmatrixbytes_len",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"Hacl.Impl.Frodo.Params.ct2bytes_len",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Frodo.KEM.clear_matrix",
"Hacl.Impl.Frodo.Pack.frodo_pack",
"Hacl.Impl.Frodo.Params.params_logq",
"Hacl.Impl.Frodo.KEM.Encaps.frodo_mul_add_sb_plus_e_plus_mu",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Matrix.matrix_create",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
#push-options "--z3rlimit 200" | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix)) | [] | Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ct_pack_c2 | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
mu: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
b: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.publicmatrixbytes_len a) ->
sp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
(Hacl.Impl.Frodo.Params.params_n a) ->
epp_matrix:
Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar
Hacl.Impl.Frodo.Params.params_nbar ->
c2: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.ct2bytes_len a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 157,
"start_col": 2,
"start_line": 152
} |
FStar.HyperStack.ST.Stack | val crypto_kem_enc0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\ live h seed_se_k /\
loc_pairwise_disjoint [loc mu; loc ct; loc ss; loc pk; loc seed_se_k])
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss |+| loc seed_se_k) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let crypto_kem_enc0 a gen_a mu ct ss pk seed_se_k =
crypto_kem_enc_seed_se_k a mu pk seed_se_k;
crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk | val crypto_kem_enc0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\ live h seed_se_k /\
loc_pairwise_disjoint [loc mu; loc ct; loc ss; loc pk; loc seed_se_k])
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss |+| loc seed_se_k) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk))
let crypto_kem_enc0 a gen_a mu ct ss pk seed_se_k = | true | null | false | crypto_kem_enc_seed_se_k a mu pk seed_se_k;
crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_publickeybytes",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ct_ss",
"Prims.unit",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_seed_se_k"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 =
push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se))
let get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix =
push_frame ();
[@inline_let] let s_bytes_len = secretmatrixbytes_len a in
let r = create (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) (u8 0) in
KG.frodo_shake_r a (u8 0x96) seed_se (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) r;
frodo_sample_matrix a params_nbar (params_n a) (sub r 0ul s_bytes_len) sp_matrix;
frodo_sample_matrix a params_nbar (params_n a) (sub r s_bytes_len s_bytes_len) ep_matrix;
frodo_sample_matrix a params_nbar params_nbar (sub r (2ul *! s_bytes_len) (2ul *! params_nbar *! params_nbar)) epp_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2))
let crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
let h0 = ST.get () in
crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1;
let h1 = ST.get () in
crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 ct) 0 (v (ct1bytes_len a)))
(LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)));
LSeq.lemma_concat2
(v (ct1bytes_len a)) (LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)))
(v (ct2bytes_len a)) (LSeq.sub (as_seq h2 ct) (v (ct1bytes_len a)) (v (ct2bytes_len a))) (as_seq h2 ct)
inline_for_extraction noextract
val clear_matrix3:
a:FP.frodo_alg
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint sp_matrix ep_matrix /\ disjoint sp_matrix epp_matrix /\
disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 ->
modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1)
let clear_matrix3 a sp_matrix ep_matrix epp_matrix =
clear_matrix sp_matrix;
clear_matrix ep_matrix;
clear_matrix epp_matrix
inline_for_extraction noextract
val crypto_kem_enc_ct:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se /\ live h ct /\
disjoint ct mu /\ disjoint ct pk /\ disjoint ct seed_se)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct a gen_a mu pk seed_se ct =
push_frame ();
let h0 = ST.get () in
FP.expand_crypto_publickeybytes a;
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (publicmatrixbytes_len a) in
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 ct)
(S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se));
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_enc_ss:
a:FP.frodo_alg
-> k:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h k /\ live h ct /\ live h ss /\
disjoint ct ss /\ disjoint k ct /\ disjoint k ss)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_enc_ss a (as_seq h0 k) (as_seq h0 ct))
let crypto_kem_enc_ss a k ct ss =
push_frame ();
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let shake_input_ss = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) k shake_input_ss;
frodo_shake a ss_init_len shake_input_ss (crypto_bytes a) ss;
clear_words_u8 shake_input_ss;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_seed_se_k:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se_k /\
disjoint seed_se_k mu /\ disjoint seed_se_k pk)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_enc_seed_se_k a (as_seq h0 mu) (as_seq h0 pk))
let crypto_kem_enc_seed_se_k a mu pk seed_se_k =
push_frame ();
let pkh_mu = create (bytes_pkhash a +! bytes_mu a) (u8 0) in
let h0 = ST.get () in
update_sub_f h0 pkh_mu 0ul (bytes_pkhash a)
(fun h -> FP.frodo_shake a (v (crypto_publickeybytes a)) (as_seq h0 pk) (v (bytes_pkhash a)))
(fun _ -> frodo_shake a (crypto_publickeybytes a) pk (bytes_pkhash a) (sub pkh_mu 0ul (bytes_pkhash a)));
let h1 = ST.get () in
update_sub pkh_mu (bytes_pkhash a) (bytes_mu a) mu;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 pkh_mu) 0 (v (bytes_pkhash a)))
(LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)));
LSeq.lemma_concat2
(v (bytes_pkhash a)) (LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)))
(v (bytes_mu a)) (as_seq h0 mu) (as_seq h2 pkh_mu);
//concat2 (bytes_pkhash a) pkh (bytes_mu a) mu pkh_mu;
frodo_shake a (bytes_pkhash a +! bytes_mu a) pkh_mu (2ul *! crypto_bytes a) seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_ss:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h seed_se_k /\ live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint seed_se_k ct /\ disjoint seed_se_k ss)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(let seed_se = LSeq.sub (as_seq h0 seed_se_k) 0 (v (crypto_bytes a)) in
let k = LSeq.sub (as_seq h0 seed_se_k) (v (crypto_bytes a)) (v (crypto_bytes a)) in
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) seed_se /\
as_seq h1 ss == S.crypto_kem_enc_ss a k (as_seq h1 ct)))
let crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk =
let seed_se = sub seed_se_k 0ul (crypto_bytes a) in
let k = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in
crypto_kem_enc_ct a gen_a mu pk seed_se ct;
crypto_kem_enc_ss a k ct ss
inline_for_extraction noextract
val crypto_kem_enc0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\ live h seed_se_k /\
loc_pairwise_disjoint [loc mu; loc ct; loc ss; loc pk; loc seed_se_k])
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss |+| loc seed_se_k) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk))
#push-options "--z3rlimit 200" | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val crypto_kem_enc0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\ live h seed_se_k /\
loc_pairwise_disjoint [loc mu; loc ct; loc ss; loc pk; loc seed_se_k])
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss |+| loc seed_se_k) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk)) | [] | Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc0 | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
mu: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) ->
ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) ->
pk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_publickeybytes a) ->
seed_se_k: Hacl.Impl.Matrix.lbytes (2ul *! Hacl.Impl.Frodo.Params.crypto_bytes a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 52,
"end_line": 388,
"start_col": 2,
"start_line": 387
} |
FStar.HyperStack.ST.Stack | val crypto_kem_enc_ct:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se /\ live h ct /\
disjoint ct mu /\ disjoint ct pk /\ disjoint ct seed_se)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let crypto_kem_enc_ct a gen_a mu pk seed_se ct =
push_frame ();
let h0 = ST.get () in
FP.expand_crypto_publickeybytes a;
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (publicmatrixbytes_len a) in
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 ct)
(S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se));
pop_frame () | val crypto_kem_enc_ct:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se /\ live h ct /\
disjoint ct mu /\ disjoint ct pk /\ disjoint ct seed_se)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se))
let crypto_kem_enc_ct a gen_a mu pk seed_se ct = | true | null | false | push_frame ();
let h0 = ST.get () in
FP.expand_crypto_publickeybytes a;
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (publicmatrixbytes_len a) in
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
let h1 = ST.get () in
LSeq.eq_intro (as_seq h1 ct)
(S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se));
pop_frame () | {
"checked_file": "Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Frodo.Params.crypto_publickeybytes",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.uint8",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Spec.Frodo.KEM.Encaps.crypto_kem_enc_ct",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.Frodo.KEM.Encaps.clear_matrix3",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ct0",
"Hacl.Impl.Frodo.KEM.Encaps.get_sp_ep_epp_matrices",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Matrix.matrix_create",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Params.params_n",
"Lib.IntTypes.U8",
"Hacl.Impl.Frodo.Params.publicmatrixbytes_len",
"Lib.Buffer.sub",
"Hacl.Impl.Frodo.Params.bytes_seed_a",
"FStar.UInt32.__uint_to_t",
"Spec.Frodo.Params.expand_crypto_publickeybytes",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 =
push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se))
let get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix =
push_frame ();
[@inline_let] let s_bytes_len = secretmatrixbytes_len a in
let r = create (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) (u8 0) in
KG.frodo_shake_r a (u8 0x96) seed_se (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) r;
frodo_sample_matrix a params_nbar (params_n a) (sub r 0ul s_bytes_len) sp_matrix;
frodo_sample_matrix a params_nbar (params_n a) (sub r s_bytes_len s_bytes_len) ep_matrix;
frodo_sample_matrix a params_nbar params_nbar (sub r (2ul *! s_bytes_len) (2ul *! params_nbar *! params_nbar)) epp_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2))
let crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
let h0 = ST.get () in
crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1;
let h1 = ST.get () in
crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 ct) 0 (v (ct1bytes_len a)))
(LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)));
LSeq.lemma_concat2
(v (ct1bytes_len a)) (LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)))
(v (ct2bytes_len a)) (LSeq.sub (as_seq h2 ct) (v (ct1bytes_len a)) (v (ct2bytes_len a))) (as_seq h2 ct)
inline_for_extraction noextract
val clear_matrix3:
a:FP.frodo_alg
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint sp_matrix ep_matrix /\ disjoint sp_matrix epp_matrix /\
disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 ->
modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1)
let clear_matrix3 a sp_matrix ep_matrix epp_matrix =
clear_matrix sp_matrix;
clear_matrix ep_matrix;
clear_matrix epp_matrix
inline_for_extraction noextract
val crypto_kem_enc_ct:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se /\ live h ct /\
disjoint ct mu /\ disjoint ct pk /\ disjoint ct seed_se)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se))
#push-options "--z3rlimit 200" | false | false | Hacl.Impl.Frodo.KEM.Encaps.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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val crypto_kem_enc_ct:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se /\ live h ct /\
disjoint ct mu /\ disjoint ct pk /\ disjoint ct seed_se)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se)) | [] | Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ct | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
mu: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
pk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_publickeybytes a) ->
seed_se: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 281,
"start_col": 2,
"start_line": 264
} |
Prims.Tot | val uint128_to_uint64: a:U128.t -> b:U64.t{U64.v b == U128.v a % pow2 64} | [
{
"abbrev": true,
"full_module": "FStar.UInt128",
"short_module": "U128"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint128_to_uint64 a = U128.uint128_to_uint64 a | val uint128_to_uint64: a:U128.t -> b:U64.t{U64.v b == U128.v a % pow2 64}
let uint128_to_uint64 a = | false | null | false | U128.uint128_to_uint64 a | {
"checked_file": "FStar.Int.Cast.Full.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Int.Cast.Full.fst"
} | [
"total"
] | [
"FStar.UInt128.t",
"FStar.UInt128.uint128_to_uint64",
"FStar.UInt64.t",
"Prims.eq2",
"Prims.int",
"FStar.UInt64.v",
"Prims.op_Modulus",
"FStar.UInt128.v",
"Prims.pow2"
] | [] | (*
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.Int.Cast.Full
include FStar.Int.Cast
module U64 = FStar.UInt64
module U128 = FStar.UInt128
inline_for_extraction noextract
val uint64_to_uint128: a:U64.t -> b:U128.t{U128.v b == U64.v a}
inline_for_extraction noextract
let uint64_to_uint128 a = U128.uint64_to_uint128 a
inline_for_extraction noextract
val uint128_to_uint64: a:U128.t -> b:U64.t{U64.v b == U128.v a % pow2 64} | false | false | FStar.Int.Cast.Full.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 uint128_to_uint64: a:U128.t -> b:U64.t{U64.v b == U128.v a % pow2 64} | [] | FStar.Int.Cast.Full.uint128_to_uint64 | {
"file_name": "ulib/FStar.Int.Cast.Full.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt128.t -> b: FStar.UInt64.t{FStar.UInt64.v b == FStar.UInt128.v a % Prims.pow2 64} | {
"end_col": 50,
"end_line": 31,
"start_col": 26,
"start_line": 31
} |
Prims.Tot | val uint64_to_uint128: a:U64.t -> b:U128.t{U128.v b == U64.v a} | [
{
"abbrev": true,
"full_module": "FStar.UInt128",
"short_module": "U128"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Int.Cast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint64_to_uint128 a = U128.uint64_to_uint128 a | val uint64_to_uint128: a:U64.t -> b:U128.t{U128.v b == U64.v a}
let uint64_to_uint128 a = | false | null | false | U128.uint64_to_uint128 a | {
"checked_file": "FStar.Int.Cast.Full.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt128.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Int.Cast.Full.fst"
} | [
"total"
] | [
"FStar.UInt64.t",
"FStar.UInt128.uint64_to_uint128",
"FStar.UInt128.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt128.n",
"FStar.UInt64.n",
"FStar.UInt128.v",
"FStar.UInt64.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.Int.Cast.Full
include FStar.Int.Cast
module U64 = FStar.UInt64
module U128 = FStar.UInt128
inline_for_extraction noextract
val uint64_to_uint128: a:U64.t -> b:U128.t{U128.v b == U64.v a} | false | false | FStar.Int.Cast.Full.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 uint64_to_uint128: a:U64.t -> b:U128.t{U128.v b == U64.v a} | [] | FStar.Int.Cast.Full.uint64_to_uint128 | {
"file_name": "ulib/FStar.Int.Cast.Full.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.UInt64.t -> b: FStar.UInt128.t{FStar.UInt128.v b == FStar.UInt64.v a} | {
"end_col": 50,
"end_line": 26,
"start_col": 26,
"start_line": 26
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let auto_squash (p: Type) = squash p | let auto_squash (p: Type) = | false | null | false | squash p | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.squash"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier. | false | true | prims.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 auto_squash : p: Type -> Type0 | [] | Prims.auto_squash | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: Type -> Type0 | {
"end_col": 36,
"end_line": 109,
"start_col": 28,
"start_line": 109
} |
|
Prims.Tot | val l_False:logical | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let l_False:logical = squash empty | val l_False:logical
let l_False:logical = | false | null | false | squash empty | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.squash",
"Prims.empty"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *) | false | true | prims.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 l_False:logical | [] | Prims.l_False | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 34,
"end_line": 138,
"start_col": 22,
"start_line": 138
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0 | let pure_post' (a pre: Type) = | false | null | false | _: a{pre} -> GTot Type0 | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the | false | true | prims.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 pure_post' : a: Type -> pre: Type -> Type | [] | Prims.pure_post' | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> pre: Type -> Type | {
"end_col": 54,
"end_line": 294,
"start_col": 31,
"start_line": 294
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pure_wp_monotonic = pure_wp_monotonic0 | let pure_wp_monotonic = | false | null | false | pure_wp_monotonic0 | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.pure_wp_monotonic0"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q) | false | false | prims.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 pure_wp_monotonic : a: Type -> wp: Prims.pure_wp' a -> Prims.logical | [] | Prims.pure_wp_monotonic | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> wp: Prims.pure_wp' a -> Prims.logical | {
"end_col": 42,
"end_line": 316,
"start_col": 24,
"start_line": 316
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let purewp_id (a: Type) (wp: pure_wp a) = wp | let purewp_id (a: Type) (wp: pure_wp a) = | false | null | false | wp | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.pure_wp"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0
let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp}
(** This predicate is an internal detail, used to optimize the
encoding of some quantifiers to SMT by omitting their typing
guards. This is safe to use only when the quantifier serves to
introduce a local macro---use with caution. *)
assume
type guard_free : Type0 -> Type0
(** The return combinator for the PURE effect requires
proving the postcondition only on [x]
Clients should not use it directly,
instead use FStar.Pervasives.pure_return *)
unfold
let pure_return0 (a: Type) (x: a) : pure_wp a =
fun (p: pure_post a) ->
forall (return_val: a). return_val == x ==> p return_val
(** Sequential composition for the PURE effect
Clients should not use it directly,
instead use FStar.Pervasives.pure_bind_wp *)
unfold
let pure_bind_wp0
(a b: Type)
(wp1: pure_wp a)
(wp2: (a -> GTot (pure_wp b)))
: pure_wp b
= fun (p: pure_post b) ->
wp1 (fun (bind_result_1: a) -> wp2 bind_result_1 p)
(** Conditional composition for the PURE effect
The combinator is optimized to make use of how the typechecker generates VC
for conditionals.
The more intuitive form of the combinator would have been:
[(p ==> wp_then post) /\ (~p ==> wp_else post)]
However, the way the typechecker constructs the VC, [wp_then] is already
weakened with [p].
Hence, here we only weaken [wp_else]
Clients should not use it directly,
instead use FStar.Pervasives.pure_if_then_else *)
unfold
let pure_if_then_else0 (a p: Type) (wp_then wp_else: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
wp_then post /\ (~p ==> wp_else post)
(** Conditional composition for the PURE effect, while trying to avoid
duplicating the postcondition by giving it a local name [k].
Note the use of [guard_free] here: [k] is just meant to be a macro
for [post].
Clients should not use it directly,
instead use FStar.Pervasives.pure_ite_wp *)
unfold
let pure_ite_wp0 (a: Type) (wp: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
forall (k: pure_post a). (forall (x: a). {:pattern (guard_free (k x))} post x ==> k x) ==> wp k
(** Subsumption for the PURE effect *)
unfold
let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = forall (p: pure_post a). wp1 p ==> wp2 p
(** Closing a PURE WP under a binder for [b]
Clients should not use it directly,
instead use FStar.Pervasives.pure_close_wp *)
unfold
let pure_close_wp0 (a b: Type) (wp: (b -> GTot (pure_wp a))) : pure_wp a = fun (p: pure_post a) -> forall (b: b). wp b p
(** Trivial WP for PURE: Prove the WP with the trivial postcondition *)
unfold
let pure_trivial (a: Type) (wp: pure_wp a) = wp (fun (trivial_result: a) -> True)
(** Introduces the PURE effect.
The definition of the PURE effect is fixed.
NO USER SHOULD EVER CHANGE THIS. *)
total
new_effect {
PURE : a: Type -> wp: pure_wp a -> Effect
with
return_wp = pure_return0
; bind_wp = pure_bind_wp0
; if_then_else = pure_if_then_else0
; ite_wp = pure_ite_wp0
; stronger = pure_stronger
; close_wp = pure_close_wp0
; trivial = pure_trivial
}
(** [Pure] is a Hoare-style counterpart of [PURE]
Note the type of post, which allows to assume the precondition
for the well-formedness of the postcondition. c.f. #57 *)
effect Pure (a: Type) (pre: pure_pre) (post: pure_post' a pre) =
PURE a
(fun (p: pure_post a) -> pre /\ (forall (pure_result: a). post pure_result ==> p pure_result))
(** [Admit] is an effect abbreviation for a computation that
disregards the verification condition of its continuation *)
effect Admit (a: Type) = PURE a (fun (p: pure_post a) -> True)
(** The primitive effect [Tot] is definitionally equal to an instance of [PURE] *)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_null_wp *)
unfold
let pure_null_wp0 (a: Type) : pure_wp a = fun (p: pure_post a) -> forall (any_result: a). p any_result
(** [Tot]: From here on, we have [Tot] as a defined symbol in F*. *)
effect Tot (a: Type) = PURE a (pure_null_wp0 a)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assert_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assert_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p /\ post ()
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assume_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assume_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p ==> post ()
(**** The [GHOST] effect *)
(** [GHOST] is logically equivalent to [PURE], but distinguished from
it nominally so that specific, computationally irrelevant
operations, are provided only in [GHOST] and are erased during
extraction *)
total
new_effect GHOST = PURE | false | false | prims.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 purewp_id : a: Type -> wp: Prims.pure_wp a -> Prims.pure_wp a | [] | Prims.purewp_id | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> wp: Prims.pure_wp a -> Prims.pure_wp a | {
"end_col": 44,
"end_line": 455,
"start_col": 42,
"start_line": 455
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pure_post (a: Type) = pure_post' a True | let pure_post (a: Type) = | false | null | false | pure_post' a True | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.pure_post'",
"Prims.l_True"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *) | false | true | prims.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 pure_post : a: Type -> Type | [] | Prims.pure_post | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> Type | {
"end_col": 43,
"end_line": 295,
"start_col": 26,
"start_line": 295
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = forall (p: pure_post a). wp1 p ==> wp2 p | let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = | false | null | false | forall (p: pure_post a). wp1 p ==> wp2 p | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.pure_wp",
"Prims.l_Forall",
"Prims.pure_post",
"Prims.l_imp",
"Prims.logical"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0
let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp}
(** This predicate is an internal detail, used to optimize the
encoding of some quantifiers to SMT by omitting their typing
guards. This is safe to use only when the quantifier serves to
introduce a local macro---use with caution. *)
assume
type guard_free : Type0 -> Type0
(** The return combinator for the PURE effect requires
proving the postcondition only on [x]
Clients should not use it directly,
instead use FStar.Pervasives.pure_return *)
unfold
let pure_return0 (a: Type) (x: a) : pure_wp a =
fun (p: pure_post a) ->
forall (return_val: a). return_val == x ==> p return_val
(** Sequential composition for the PURE effect
Clients should not use it directly,
instead use FStar.Pervasives.pure_bind_wp *)
unfold
let pure_bind_wp0
(a b: Type)
(wp1: pure_wp a)
(wp2: (a -> GTot (pure_wp b)))
: pure_wp b
= fun (p: pure_post b) ->
wp1 (fun (bind_result_1: a) -> wp2 bind_result_1 p)
(** Conditional composition for the PURE effect
The combinator is optimized to make use of how the typechecker generates VC
for conditionals.
The more intuitive form of the combinator would have been:
[(p ==> wp_then post) /\ (~p ==> wp_else post)]
However, the way the typechecker constructs the VC, [wp_then] is already
weakened with [p].
Hence, here we only weaken [wp_else]
Clients should not use it directly,
instead use FStar.Pervasives.pure_if_then_else *)
unfold
let pure_if_then_else0 (a p: Type) (wp_then wp_else: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
wp_then post /\ (~p ==> wp_else post)
(** Conditional composition for the PURE effect, while trying to avoid
duplicating the postcondition by giving it a local name [k].
Note the use of [guard_free] here: [k] is just meant to be a macro
for [post].
Clients should not use it directly,
instead use FStar.Pervasives.pure_ite_wp *)
unfold
let pure_ite_wp0 (a: Type) (wp: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
forall (k: pure_post a). (forall (x: a). {:pattern (guard_free (k x))} post x ==> k x) ==> wp k
(** Subsumption for the PURE effect *) | false | false | prims.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 pure_stronger : a: Type -> wp1: Prims.pure_wp a -> wp2: Prims.pure_wp a -> Prims.logical | [] | Prims.pure_stronger | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> wp1: Prims.pure_wp a -> wp2: Prims.pure_wp a -> Prims.logical | {
"end_col": 91,
"end_line": 385,
"start_col": 51,
"start_line": 385
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pure_wp' (a: Type) = pure_post a -> GTot pure_pre | let pure_wp' (a: Type) = | false | null | false | pure_post a -> GTot pure_pre | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.pure_post",
"Prims.pure_pre"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type, | false | true | prims.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 pure_wp' : a: Type -> Type | [] | Prims.pure_wp' | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> Type | {
"end_col": 53,
"end_line": 304,
"start_col": 25,
"start_line": 304
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pure_trivial (a: Type) (wp: pure_wp a) = wp (fun (trivial_result: a) -> True) | let pure_trivial (a: Type) (wp: pure_wp a) = | false | null | false | wp (fun (trivial_result: a) -> True) | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.pure_wp",
"Prims.l_True",
"Prims.pure_pre"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0
let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp}
(** This predicate is an internal detail, used to optimize the
encoding of some quantifiers to SMT by omitting their typing
guards. This is safe to use only when the quantifier serves to
introduce a local macro---use with caution. *)
assume
type guard_free : Type0 -> Type0
(** The return combinator for the PURE effect requires
proving the postcondition only on [x]
Clients should not use it directly,
instead use FStar.Pervasives.pure_return *)
unfold
let pure_return0 (a: Type) (x: a) : pure_wp a =
fun (p: pure_post a) ->
forall (return_val: a). return_val == x ==> p return_val
(** Sequential composition for the PURE effect
Clients should not use it directly,
instead use FStar.Pervasives.pure_bind_wp *)
unfold
let pure_bind_wp0
(a b: Type)
(wp1: pure_wp a)
(wp2: (a -> GTot (pure_wp b)))
: pure_wp b
= fun (p: pure_post b) ->
wp1 (fun (bind_result_1: a) -> wp2 bind_result_1 p)
(** Conditional composition for the PURE effect
The combinator is optimized to make use of how the typechecker generates VC
for conditionals.
The more intuitive form of the combinator would have been:
[(p ==> wp_then post) /\ (~p ==> wp_else post)]
However, the way the typechecker constructs the VC, [wp_then] is already
weakened with [p].
Hence, here we only weaken [wp_else]
Clients should not use it directly,
instead use FStar.Pervasives.pure_if_then_else *)
unfold
let pure_if_then_else0 (a p: Type) (wp_then wp_else: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
wp_then post /\ (~p ==> wp_else post)
(** Conditional composition for the PURE effect, while trying to avoid
duplicating the postcondition by giving it a local name [k].
Note the use of [guard_free] here: [k] is just meant to be a macro
for [post].
Clients should not use it directly,
instead use FStar.Pervasives.pure_ite_wp *)
unfold
let pure_ite_wp0 (a: Type) (wp: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
forall (k: pure_post a). (forall (x: a). {:pattern (guard_free (k x))} post x ==> k x) ==> wp k
(** Subsumption for the PURE effect *)
unfold
let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = forall (p: pure_post a). wp1 p ==> wp2 p
(** Closing a PURE WP under a binder for [b]
Clients should not use it directly,
instead use FStar.Pervasives.pure_close_wp *)
unfold
let pure_close_wp0 (a b: Type) (wp: (b -> GTot (pure_wp a))) : pure_wp a = fun (p: pure_post a) -> forall (b: b). wp b p
(** Trivial WP for PURE: Prove the WP with the trivial postcondition *) | false | false | prims.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 pure_trivial : a: Type -> wp: Prims.pure_wp a -> Prims.pure_pre | [] | Prims.pure_trivial | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> wp: Prims.pure_wp a -> Prims.pure_pre | {
"end_col": 81,
"end_line": 396,
"start_col": 45,
"start_line": 396
} |
|
Prims.Tot | val returnM (a: Type) (x: a) : M a | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let returnM (a: Type) (x: a) : M a = x | val returnM (a: Type) (x: a) : M a
let returnM (a: Type) (x: a) : M a = | false | null | false | x | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0
let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp}
(** This predicate is an internal detail, used to optimize the
encoding of some quantifiers to SMT by omitting their typing
guards. This is safe to use only when the quantifier serves to
introduce a local macro---use with caution. *)
assume
type guard_free : Type0 -> Type0
(** The return combinator for the PURE effect requires
proving the postcondition only on [x]
Clients should not use it directly,
instead use FStar.Pervasives.pure_return *)
unfold
let pure_return0 (a: Type) (x: a) : pure_wp a =
fun (p: pure_post a) ->
forall (return_val: a). return_val == x ==> p return_val
(** Sequential composition for the PURE effect
Clients should not use it directly,
instead use FStar.Pervasives.pure_bind_wp *)
unfold
let pure_bind_wp0
(a b: Type)
(wp1: pure_wp a)
(wp2: (a -> GTot (pure_wp b)))
: pure_wp b
= fun (p: pure_post b) ->
wp1 (fun (bind_result_1: a) -> wp2 bind_result_1 p)
(** Conditional composition for the PURE effect
The combinator is optimized to make use of how the typechecker generates VC
for conditionals.
The more intuitive form of the combinator would have been:
[(p ==> wp_then post) /\ (~p ==> wp_else post)]
However, the way the typechecker constructs the VC, [wp_then] is already
weakened with [p].
Hence, here we only weaken [wp_else]
Clients should not use it directly,
instead use FStar.Pervasives.pure_if_then_else *)
unfold
let pure_if_then_else0 (a p: Type) (wp_then wp_else: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
wp_then post /\ (~p ==> wp_else post)
(** Conditional composition for the PURE effect, while trying to avoid
duplicating the postcondition by giving it a local name [k].
Note the use of [guard_free] here: [k] is just meant to be a macro
for [post].
Clients should not use it directly,
instead use FStar.Pervasives.pure_ite_wp *)
unfold
let pure_ite_wp0 (a: Type) (wp: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
forall (k: pure_post a). (forall (x: a). {:pattern (guard_free (k x))} post x ==> k x) ==> wp k
(** Subsumption for the PURE effect *)
unfold
let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = forall (p: pure_post a). wp1 p ==> wp2 p
(** Closing a PURE WP under a binder for [b]
Clients should not use it directly,
instead use FStar.Pervasives.pure_close_wp *)
unfold
let pure_close_wp0 (a b: Type) (wp: (b -> GTot (pure_wp a))) : pure_wp a = fun (p: pure_post a) -> forall (b: b). wp b p
(** Trivial WP for PURE: Prove the WP with the trivial postcondition *)
unfold
let pure_trivial (a: Type) (wp: pure_wp a) = wp (fun (trivial_result: a) -> True)
(** Introduces the PURE effect.
The definition of the PURE effect is fixed.
NO USER SHOULD EVER CHANGE THIS. *)
total
new_effect {
PURE : a: Type -> wp: pure_wp a -> Effect
with
return_wp = pure_return0
; bind_wp = pure_bind_wp0
; if_then_else = pure_if_then_else0
; ite_wp = pure_ite_wp0
; stronger = pure_stronger
; close_wp = pure_close_wp0
; trivial = pure_trivial
}
(** [Pure] is a Hoare-style counterpart of [PURE]
Note the type of post, which allows to assume the precondition
for the well-formedness of the postcondition. c.f. #57 *)
effect Pure (a: Type) (pre: pure_pre) (post: pure_post' a pre) =
PURE a
(fun (p: pure_post a) -> pre /\ (forall (pure_result: a). post pure_result ==> p pure_result))
(** [Admit] is an effect abbreviation for a computation that
disregards the verification condition of its continuation *)
effect Admit (a: Type) = PURE a (fun (p: pure_post a) -> True)
(** The primitive effect [Tot] is definitionally equal to an instance of [PURE] *)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_null_wp *)
unfold
let pure_null_wp0 (a: Type) : pure_wp a = fun (p: pure_post a) -> forall (any_result: a). p any_result
(** [Tot]: From here on, we have [Tot] as a defined symbol in F*. *)
effect Tot (a: Type) = PURE a (pure_null_wp0 a)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assert_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assert_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p /\ post ()
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assume_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assume_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p ==> post ()
(**** The [GHOST] effect *)
(** [GHOST] is logically equivalent to [PURE], but distinguished from
it nominally so that specific, computationally irrelevant
operations, are provided only in [GHOST] and are erased during
extraction *)
total
new_effect GHOST = PURE
unfold
let purewp_id (a: Type) (wp: pure_wp a) = wp
(** [PURE] computations can be lifted to the [GHOST] effect (but not
vice versa) using just the identity lifting on pure wps *)
sub_effect PURE ~> GHOST { lift_wp = purewp_id }
(** [Ghost] is a the Hoare-style counterpart of [GHOST] *)
effect Ghost (a: Type) (pre: Type) (post: pure_post' a pre) =
GHOST a
(fun (p: pure_post a) -> pre /\ (forall (ghost_result: a). post ghost_result ==> p ghost_result)
)
(** As with [Tot], the primitive effect [GTot] is definitionally equal
to an instance of GHOST *)
effect GTot (a: Type) = GHOST a (pure_null_wp0 a)
(***** End trusted primitives *****)
(** This point onward, F* fully verifies all the definitions *)
(** [===] heterogeneous equality *)
let ( === ) (#a #b: Type) (x: a) (y: b) : logical = a == b /\ x == y
(** Dependent pairs [dtuple2] in concrete syntax is [x:a & b x].
Its values can be constructed with the concrete syntax [(| x, y |)] *)
unopteq
type dtuple2 (a: Type) (b: (a -> GTot Type)) =
| Mkdtuple2 : _1: a -> _2: b _1 -> dtuple2 a b
(** Squashed existential quantification, or dependent sums,
are written [exists (x:a). p x] : specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Exists (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a & p x)
(** Primitive type of mathematical integers, mapped to zarith in OCaml
extraction and to the SMT sort of integers *)
assume new
type int : eqtype
(**** Basic operators on booleans and integers *)
(** [&&] boolean conjunction *)
[@@ smt_theory_symbol]
assume
val op_AmpAmp: bool -> bool -> Tot bool
(** [||] boolean disjunction *)
[@@ smt_theory_symbol]
assume
val op_BarBar: bool -> bool -> Tot bool
(** [not] boolean negation *)
[@@ smt_theory_symbol]
assume
val op_Negation: bool -> Tot bool
(** Integer multiplication, no special symbol. See FStar.Mul *)
[@@ smt_theory_symbol]
assume
val op_Multiply: int -> int -> Tot int
(** [-] integer subtraction *)
[@@ smt_theory_symbol]
assume
val op_Subtraction: int -> int -> Tot int
(** [+] integer addition *)
[@@ smt_theory_symbol]
assume
val op_Addition: int -> int -> Tot int
(** [-] prefix unary integer negation *)
[@@ smt_theory_symbol]
assume
val op_Minus: int -> Tot int
(** [<=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThanOrEqual: int -> int -> Tot bool
(** [>] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThan: int -> int -> Tot bool
(** [>=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThanOrEqual: int -> int -> Tot bool
(** [<] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThan: int -> int -> Tot bool
(** [=] decidable equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_Equality: #a: eqtype -> a -> a -> Tot bool
(** [<>] decidable dis-equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_disEquality: #a: eqtype -> a -> a -> Tot bool
(** The extensible open inductive type of exceptions *)
assume new
type exn : Type0
(** [array]: TODO: should be removed.
See FStar.Seq, LowStar.Buffer, etc. *)
assume new
type array : Type -> Type0
(** String concatenation and its abbreviation as [^]. TODO, both
should be removed in favor of what is present in FStar.String *)
assume
val strcat: string -> string -> Tot string
inline_for_extraction unfold
let op_Hat s1 s2 = strcat s1 s2
(** The inductive type of polymorphic lists *)
type list (a: Type) =
| Nil : list a
| Cons : hd: a -> tl: list a -> list a
(** The [M] marker is interpreted by the Dijkstra Monads for Free
construction. It has a "double meaning", either as an alias for
reasoning about the direct definitions, or as a marker for places
where a CPS transformation should happen. *)
effect M (a: Type) = Tot a (attributes cps) | false | false | prims.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 returnM (a: Type) (x: a) : M a | [] | Prims.returnM | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> x: a -> Prims.M a | {
"end_col": 38,
"end_line": 604,
"start_col": 37,
"start_line": 604
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q) | let pure_wp_monotonic0 (a: Type) (wp: pure_wp' a) = | false | null | false | forall (p: pure_post a) (q: pure_post a). (forall (x: a). p x ==> q x) ==> (wp p ==> wp q) | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.pure_wp'",
"Prims.l_Forall",
"Prims.pure_post",
"Prims.l_imp",
"Prims.logical"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *) | false | false | prims.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 pure_wp_monotonic0 : a: Type -> wp: Prims.pure_wp' a -> Prims.logical | [] | Prims.pure_wp_monotonic0 | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> wp: Prims.pure_wp' a -> Prims.logical | {
"end_col": 75,
"end_line": 313,
"start_col": 2,
"start_line": 313
} |
|
Prims.Tot | val l_True:logical | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let l_True:logical = squash trivial | val l_True:logical
let l_True:logical = | false | null | false | squash trivial | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.squash",
"Prims.trivial"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *) | false | true | prims.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 l_True:logical | [] | Prims.l_True | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 35,
"end_line": 132,
"start_col": 21,
"start_line": 132
} |
Prims.Tot | [
{
"abbrev": false,
"full_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_Hat s1 s2 = strcat s1 s2 | let op_Hat s1 s2 = | false | null | false | strcat s1 s2 | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.string",
"Prims.strcat"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0
let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp}
(** This predicate is an internal detail, used to optimize the
encoding of some quantifiers to SMT by omitting their typing
guards. This is safe to use only when the quantifier serves to
introduce a local macro---use with caution. *)
assume
type guard_free : Type0 -> Type0
(** The return combinator for the PURE effect requires
proving the postcondition only on [x]
Clients should not use it directly,
instead use FStar.Pervasives.pure_return *)
unfold
let pure_return0 (a: Type) (x: a) : pure_wp a =
fun (p: pure_post a) ->
forall (return_val: a). return_val == x ==> p return_val
(** Sequential composition for the PURE effect
Clients should not use it directly,
instead use FStar.Pervasives.pure_bind_wp *)
unfold
let pure_bind_wp0
(a b: Type)
(wp1: pure_wp a)
(wp2: (a -> GTot (pure_wp b)))
: pure_wp b
= fun (p: pure_post b) ->
wp1 (fun (bind_result_1: a) -> wp2 bind_result_1 p)
(** Conditional composition for the PURE effect
The combinator is optimized to make use of how the typechecker generates VC
for conditionals.
The more intuitive form of the combinator would have been:
[(p ==> wp_then post) /\ (~p ==> wp_else post)]
However, the way the typechecker constructs the VC, [wp_then] is already
weakened with [p].
Hence, here we only weaken [wp_else]
Clients should not use it directly,
instead use FStar.Pervasives.pure_if_then_else *)
unfold
let pure_if_then_else0 (a p: Type) (wp_then wp_else: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
wp_then post /\ (~p ==> wp_else post)
(** Conditional composition for the PURE effect, while trying to avoid
duplicating the postcondition by giving it a local name [k].
Note the use of [guard_free] here: [k] is just meant to be a macro
for [post].
Clients should not use it directly,
instead use FStar.Pervasives.pure_ite_wp *)
unfold
let pure_ite_wp0 (a: Type) (wp: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
forall (k: pure_post a). (forall (x: a). {:pattern (guard_free (k x))} post x ==> k x) ==> wp k
(** Subsumption for the PURE effect *)
unfold
let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = forall (p: pure_post a). wp1 p ==> wp2 p
(** Closing a PURE WP under a binder for [b]
Clients should not use it directly,
instead use FStar.Pervasives.pure_close_wp *)
unfold
let pure_close_wp0 (a b: Type) (wp: (b -> GTot (pure_wp a))) : pure_wp a = fun (p: pure_post a) -> forall (b: b). wp b p
(** Trivial WP for PURE: Prove the WP with the trivial postcondition *)
unfold
let pure_trivial (a: Type) (wp: pure_wp a) = wp (fun (trivial_result: a) -> True)
(** Introduces the PURE effect.
The definition of the PURE effect is fixed.
NO USER SHOULD EVER CHANGE THIS. *)
total
new_effect {
PURE : a: Type -> wp: pure_wp a -> Effect
with
return_wp = pure_return0
; bind_wp = pure_bind_wp0
; if_then_else = pure_if_then_else0
; ite_wp = pure_ite_wp0
; stronger = pure_stronger
; close_wp = pure_close_wp0
; trivial = pure_trivial
}
(** [Pure] is a Hoare-style counterpart of [PURE]
Note the type of post, which allows to assume the precondition
for the well-formedness of the postcondition. c.f. #57 *)
effect Pure (a: Type) (pre: pure_pre) (post: pure_post' a pre) =
PURE a
(fun (p: pure_post a) -> pre /\ (forall (pure_result: a). post pure_result ==> p pure_result))
(** [Admit] is an effect abbreviation for a computation that
disregards the verification condition of its continuation *)
effect Admit (a: Type) = PURE a (fun (p: pure_post a) -> True)
(** The primitive effect [Tot] is definitionally equal to an instance of [PURE] *)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_null_wp *)
unfold
let pure_null_wp0 (a: Type) : pure_wp a = fun (p: pure_post a) -> forall (any_result: a). p any_result
(** [Tot]: From here on, we have [Tot] as a defined symbol in F*. *)
effect Tot (a: Type) = PURE a (pure_null_wp0 a)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assert_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assert_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p /\ post ()
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assume_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assume_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p ==> post ()
(**** The [GHOST] effect *)
(** [GHOST] is logically equivalent to [PURE], but distinguished from
it nominally so that specific, computationally irrelevant
operations, are provided only in [GHOST] and are erased during
extraction *)
total
new_effect GHOST = PURE
unfold
let purewp_id (a: Type) (wp: pure_wp a) = wp
(** [PURE] computations can be lifted to the [GHOST] effect (but not
vice versa) using just the identity lifting on pure wps *)
sub_effect PURE ~> GHOST { lift_wp = purewp_id }
(** [Ghost] is a the Hoare-style counterpart of [GHOST] *)
effect Ghost (a: Type) (pre: Type) (post: pure_post' a pre) =
GHOST a
(fun (p: pure_post a) -> pre /\ (forall (ghost_result: a). post ghost_result ==> p ghost_result)
)
(** As with [Tot], the primitive effect [GTot] is definitionally equal
to an instance of GHOST *)
effect GTot (a: Type) = GHOST a (pure_null_wp0 a)
(***** End trusted primitives *****)
(** This point onward, F* fully verifies all the definitions *)
(** [===] heterogeneous equality *)
let ( === ) (#a #b: Type) (x: a) (y: b) : logical = a == b /\ x == y
(** Dependent pairs [dtuple2] in concrete syntax is [x:a & b x].
Its values can be constructed with the concrete syntax [(| x, y |)] *)
unopteq
type dtuple2 (a: Type) (b: (a -> GTot Type)) =
| Mkdtuple2 : _1: a -> _2: b _1 -> dtuple2 a b
(** Squashed existential quantification, or dependent sums,
are written [exists (x:a). p x] : specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Exists (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a & p x)
(** Primitive type of mathematical integers, mapped to zarith in OCaml
extraction and to the SMT sort of integers *)
assume new
type int : eqtype
(**** Basic operators on booleans and integers *)
(** [&&] boolean conjunction *)
[@@ smt_theory_symbol]
assume
val op_AmpAmp: bool -> bool -> Tot bool
(** [||] boolean disjunction *)
[@@ smt_theory_symbol]
assume
val op_BarBar: bool -> bool -> Tot bool
(** [not] boolean negation *)
[@@ smt_theory_symbol]
assume
val op_Negation: bool -> Tot bool
(** Integer multiplication, no special symbol. See FStar.Mul *)
[@@ smt_theory_symbol]
assume
val op_Multiply: int -> int -> Tot int
(** [-] integer subtraction *)
[@@ smt_theory_symbol]
assume
val op_Subtraction: int -> int -> Tot int
(** [+] integer addition *)
[@@ smt_theory_symbol]
assume
val op_Addition: int -> int -> Tot int
(** [-] prefix unary integer negation *)
[@@ smt_theory_symbol]
assume
val op_Minus: int -> Tot int
(** [<=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThanOrEqual: int -> int -> Tot bool
(** [>] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThan: int -> int -> Tot bool
(** [>=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThanOrEqual: int -> int -> Tot bool
(** [<] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThan: int -> int -> Tot bool
(** [=] decidable equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_Equality: #a: eqtype -> a -> a -> Tot bool
(** [<>] decidable dis-equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_disEquality: #a: eqtype -> a -> a -> Tot bool
(** The extensible open inductive type of exceptions *)
assume new
type exn : Type0
(** [array]: TODO: should be removed.
See FStar.Seq, LowStar.Buffer, etc. *)
assume new
type array : Type -> Type0
(** String concatenation and its abbreviation as [^]. TODO, both
should be removed in favor of what is present in FStar.String *)
assume
val strcat: string -> string -> Tot string | false | true | prims.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Hat : s1: Prims.string -> s2: Prims.string -> Prims.string | [] | Prims.op_Hat | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s1: Prims.string -> s2: Prims.string -> Prims.string | {
"end_col": 31,
"end_line": 590,
"start_col": 19,
"start_line": 590
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp} | let pure_wp (a: Type) = | false | null | false | wp: pure_wp' a {pure_wp_monotonic a wp} | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.pure_wp'",
"Prims.pure_wp_monotonic"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0 | false | true | prims.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 pure_wp : a: Type -> Type | [] | Prims.pure_wp | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> Type | {
"end_col": 61,
"end_line": 318,
"start_col": 24,
"start_line": 318
} |
|
Prims.Tot | val abs (x: int) : Tot int | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let abs (x: int) : Tot int = if x >= 0 then x else - x | val abs (x: int) : Tot int
let abs (x: int) : Tot int = | false | null | false | if x >= 0 then x else - x | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.int",
"Prims.op_GreaterThanOrEqual",
"Prims.bool",
"Prims.op_Minus"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0
let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp}
(** This predicate is an internal detail, used to optimize the
encoding of some quantifiers to SMT by omitting their typing
guards. This is safe to use only when the quantifier serves to
introduce a local macro---use with caution. *)
assume
type guard_free : Type0 -> Type0
(** The return combinator for the PURE effect requires
proving the postcondition only on [x]
Clients should not use it directly,
instead use FStar.Pervasives.pure_return *)
unfold
let pure_return0 (a: Type) (x: a) : pure_wp a =
fun (p: pure_post a) ->
forall (return_val: a). return_val == x ==> p return_val
(** Sequential composition for the PURE effect
Clients should not use it directly,
instead use FStar.Pervasives.pure_bind_wp *)
unfold
let pure_bind_wp0
(a b: Type)
(wp1: pure_wp a)
(wp2: (a -> GTot (pure_wp b)))
: pure_wp b
= fun (p: pure_post b) ->
wp1 (fun (bind_result_1: a) -> wp2 bind_result_1 p)
(** Conditional composition for the PURE effect
The combinator is optimized to make use of how the typechecker generates VC
for conditionals.
The more intuitive form of the combinator would have been:
[(p ==> wp_then post) /\ (~p ==> wp_else post)]
However, the way the typechecker constructs the VC, [wp_then] is already
weakened with [p].
Hence, here we only weaken [wp_else]
Clients should not use it directly,
instead use FStar.Pervasives.pure_if_then_else *)
unfold
let pure_if_then_else0 (a p: Type) (wp_then wp_else: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
wp_then post /\ (~p ==> wp_else post)
(** Conditional composition for the PURE effect, while trying to avoid
duplicating the postcondition by giving it a local name [k].
Note the use of [guard_free] here: [k] is just meant to be a macro
for [post].
Clients should not use it directly,
instead use FStar.Pervasives.pure_ite_wp *)
unfold
let pure_ite_wp0 (a: Type) (wp: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
forall (k: pure_post a). (forall (x: a). {:pattern (guard_free (k x))} post x ==> k x) ==> wp k
(** Subsumption for the PURE effect *)
unfold
let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = forall (p: pure_post a). wp1 p ==> wp2 p
(** Closing a PURE WP under a binder for [b]
Clients should not use it directly,
instead use FStar.Pervasives.pure_close_wp *)
unfold
let pure_close_wp0 (a b: Type) (wp: (b -> GTot (pure_wp a))) : pure_wp a = fun (p: pure_post a) -> forall (b: b). wp b p
(** Trivial WP for PURE: Prove the WP with the trivial postcondition *)
unfold
let pure_trivial (a: Type) (wp: pure_wp a) = wp (fun (trivial_result: a) -> True)
(** Introduces the PURE effect.
The definition of the PURE effect is fixed.
NO USER SHOULD EVER CHANGE THIS. *)
total
new_effect {
PURE : a: Type -> wp: pure_wp a -> Effect
with
return_wp = pure_return0
; bind_wp = pure_bind_wp0
; if_then_else = pure_if_then_else0
; ite_wp = pure_ite_wp0
; stronger = pure_stronger
; close_wp = pure_close_wp0
; trivial = pure_trivial
}
(** [Pure] is a Hoare-style counterpart of [PURE]
Note the type of post, which allows to assume the precondition
for the well-formedness of the postcondition. c.f. #57 *)
effect Pure (a: Type) (pre: pure_pre) (post: pure_post' a pre) =
PURE a
(fun (p: pure_post a) -> pre /\ (forall (pure_result: a). post pure_result ==> p pure_result))
(** [Admit] is an effect abbreviation for a computation that
disregards the verification condition of its continuation *)
effect Admit (a: Type) = PURE a (fun (p: pure_post a) -> True)
(** The primitive effect [Tot] is definitionally equal to an instance of [PURE] *)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_null_wp *)
unfold
let pure_null_wp0 (a: Type) : pure_wp a = fun (p: pure_post a) -> forall (any_result: a). p any_result
(** [Tot]: From here on, we have [Tot] as a defined symbol in F*. *)
effect Tot (a: Type) = PURE a (pure_null_wp0 a)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assert_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assert_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p /\ post ()
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assume_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assume_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p ==> post ()
(**** The [GHOST] effect *)
(** [GHOST] is logically equivalent to [PURE], but distinguished from
it nominally so that specific, computationally irrelevant
operations, are provided only in [GHOST] and are erased during
extraction *)
total
new_effect GHOST = PURE
unfold
let purewp_id (a: Type) (wp: pure_wp a) = wp
(** [PURE] computations can be lifted to the [GHOST] effect (but not
vice versa) using just the identity lifting on pure wps *)
sub_effect PURE ~> GHOST { lift_wp = purewp_id }
(** [Ghost] is a the Hoare-style counterpart of [GHOST] *)
effect Ghost (a: Type) (pre: Type) (post: pure_post' a pre) =
GHOST a
(fun (p: pure_post a) -> pre /\ (forall (ghost_result: a). post ghost_result ==> p ghost_result)
)
(** As with [Tot], the primitive effect [GTot] is definitionally equal
to an instance of GHOST *)
effect GTot (a: Type) = GHOST a (pure_null_wp0 a)
(***** End trusted primitives *****)
(** This point onward, F* fully verifies all the definitions *)
(** [===] heterogeneous equality *)
let ( === ) (#a #b: Type) (x: a) (y: b) : logical = a == b /\ x == y
(** Dependent pairs [dtuple2] in concrete syntax is [x:a & b x].
Its values can be constructed with the concrete syntax [(| x, y |)] *)
unopteq
type dtuple2 (a: Type) (b: (a -> GTot Type)) =
| Mkdtuple2 : _1: a -> _2: b _1 -> dtuple2 a b
(** Squashed existential quantification, or dependent sums,
are written [exists (x:a). p x] : specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Exists (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a & p x)
(** Primitive type of mathematical integers, mapped to zarith in OCaml
extraction and to the SMT sort of integers *)
assume new
type int : eqtype
(**** Basic operators on booleans and integers *)
(** [&&] boolean conjunction *)
[@@ smt_theory_symbol]
assume
val op_AmpAmp: bool -> bool -> Tot bool
(** [||] boolean disjunction *)
[@@ smt_theory_symbol]
assume
val op_BarBar: bool -> bool -> Tot bool
(** [not] boolean negation *)
[@@ smt_theory_symbol]
assume
val op_Negation: bool -> Tot bool
(** Integer multiplication, no special symbol. See FStar.Mul *)
[@@ smt_theory_symbol]
assume
val op_Multiply: int -> int -> Tot int
(** [-] integer subtraction *)
[@@ smt_theory_symbol]
assume
val op_Subtraction: int -> int -> Tot int
(** [+] integer addition *)
[@@ smt_theory_symbol]
assume
val op_Addition: int -> int -> Tot int
(** [-] prefix unary integer negation *)
[@@ smt_theory_symbol]
assume
val op_Minus: int -> Tot int
(** [<=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThanOrEqual: int -> int -> Tot bool
(** [>] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThan: int -> int -> Tot bool
(** [>=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThanOrEqual: int -> int -> Tot bool
(** [<] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThan: int -> int -> Tot bool
(** [=] decidable equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_Equality: #a: eqtype -> a -> a -> Tot bool
(** [<>] decidable dis-equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_disEquality: #a: eqtype -> a -> a -> Tot bool
(** The extensible open inductive type of exceptions *)
assume new
type exn : Type0
(** [array]: TODO: should be removed.
See FStar.Seq, LowStar.Buffer, etc. *)
assume new
type array : Type -> Type0
(** String concatenation and its abbreviation as [^]. TODO, both
should be removed in favor of what is present in FStar.String *)
assume
val strcat: string -> string -> Tot string
inline_for_extraction unfold
let op_Hat s1 s2 = strcat s1 s2
(** The inductive type of polymorphic lists *)
type list (a: Type) =
| Nil : list a
| Cons : hd: a -> tl: list a -> list a
(** The [M] marker is interpreted by the Dijkstra Monads for Free
construction. It has a "double meaning", either as an alias for
reasoning about the direct definitions, or as a marker for places
where a CPS transformation should happen. *)
effect M (a: Type) = Tot a (attributes cps)
(** Returning a value into the [M] effect *)
let returnM (a: Type) (x: a) : M a = x
(** [as_requires] turns a WP into a precondition, by applying it to
a trivial postcondition *)
unfold
let as_requires (#a: Type) (wp: pure_wp a) : pure_pre = wp (fun x -> True)
(** [as_ensures] turns a WP into a postcondition, relying on a kind of
double negation translation. *)
unfold
let as_ensures (#a: Type) (wp: pure_wp a) : pure_post a = fun (x:a) -> ~(wp (fun y -> (y =!= x)))
(** The keyword term-level keyword [assume] is desugared to [_assume].
It explicitly provides an escape hatch to assume a given property
[p]. *)
[@@ warn_on_use "Uses an axiom"]
assume
val _assume (p: Type) : Pure unit (requires (True)) (ensures (fun x -> p))
(** [admit] is another escape hatch: It discards the continuation and
returns a value of any type *)
[@@ warn_on_use "Uses an axiom"]
assume
val admit: #a: Type -> unit -> Admit a
(** [magic] is another escape hatch: It retains the continuation but
returns a value of any type *)
[@@ warn_on_use "Uses an axiom"]
assume
val magic: #a: Type -> unit -> Tot a
(** [unsafe_coerce] is another escape hatch: It coerces an [a] to a
[b]. *)
[@@ warn_on_use "Uses an axiom"]
irreducible
let unsafe_coerce (#a #b: Type) (x: a) : b =
admit ();
x
(** [admitP]: TODO: Unused ... remove? *)
[@@ warn_on_use "Uses an axiom"]
assume
val admitP (p: Type) : Pure unit True (fun x -> p)
(** The keyword term-level keyword [assert] is desugared to [_assert].
It force a proof of a property [p], then assuming [p] for the
continuation. *)
val _assert (p: Type) : Pure unit (requires p) (ensures (fun x -> p))
let _assert p = ()
(** Logically equivalent to assert; TODO remove? *)
val cut (p: Type) : Pure unit (requires p) (fun x -> p)
let cut p = ()
(** The type of non-negative integers *)
type nat = i: int{i >= 0}
(** The type of positive integers *)
type pos = i: int{i > 0}
(** The type of non-zero integers *)
type nonzero = i: int{i <> 0}
/// Arbitrary precision ints are compiled to zarith (big_ints) in
/// OCaml and to .NET BigInteger in F#. Both the modulus and division
/// operations are Euclidean and are mapped to the corresponding
/// theory symbols in the SMT encoding
(** Euclidean modulus *)
[@@ smt_theory_symbol]
assume
val op_Modulus: int -> nonzero -> Tot int
(** Euclidean division, written [/] *)
[@@ smt_theory_symbol]
assume
val op_Division: int -> nonzero -> Tot int
(** [pow2 x] is [2^x]:
TODO: maybe move this to FStar.Int *)
let rec pow2 (x: nat) : Tot pos =
match x with
| 0 -> 1
| _ -> 2 `op_Multiply` (pow2 (x - 1))
(** [min] computes the minimum of two [int]s *)
let min x y = if x <= y then x else y | false | true | prims.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 abs (x: int) : Tot int | [] | Prims.abs | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.int -> Prims.int | {
"end_col": 54,
"end_line": 696,
"start_col": 29,
"start_line": 696
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pure_pre = Type0 | let pure_pre = | false | null | false | Type0 | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *) | false | true | prims.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 pure_pre : Type | [] | Prims.pure_pre | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type | {
"end_col": 20,
"end_line": 288,
"start_col": 15,
"start_line": 288
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let __cache_version_number__ = 62 | let __cache_version_number__ = | false | null | false | 62 | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0
let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp}
(** This predicate is an internal detail, used to optimize the
encoding of some quantifiers to SMT by omitting their typing
guards. This is safe to use only when the quantifier serves to
introduce a local macro---use with caution. *)
assume
type guard_free : Type0 -> Type0
(** The return combinator for the PURE effect requires
proving the postcondition only on [x]
Clients should not use it directly,
instead use FStar.Pervasives.pure_return *)
unfold
let pure_return0 (a: Type) (x: a) : pure_wp a =
fun (p: pure_post a) ->
forall (return_val: a). return_val == x ==> p return_val
(** Sequential composition for the PURE effect
Clients should not use it directly,
instead use FStar.Pervasives.pure_bind_wp *)
unfold
let pure_bind_wp0
(a b: Type)
(wp1: pure_wp a)
(wp2: (a -> GTot (pure_wp b)))
: pure_wp b
= fun (p: pure_post b) ->
wp1 (fun (bind_result_1: a) -> wp2 bind_result_1 p)
(** Conditional composition for the PURE effect
The combinator is optimized to make use of how the typechecker generates VC
for conditionals.
The more intuitive form of the combinator would have been:
[(p ==> wp_then post) /\ (~p ==> wp_else post)]
However, the way the typechecker constructs the VC, [wp_then] is already
weakened with [p].
Hence, here we only weaken [wp_else]
Clients should not use it directly,
instead use FStar.Pervasives.pure_if_then_else *)
unfold
let pure_if_then_else0 (a p: Type) (wp_then wp_else: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
wp_then post /\ (~p ==> wp_else post)
(** Conditional composition for the PURE effect, while trying to avoid
duplicating the postcondition by giving it a local name [k].
Note the use of [guard_free] here: [k] is just meant to be a macro
for [post].
Clients should not use it directly,
instead use FStar.Pervasives.pure_ite_wp *)
unfold
let pure_ite_wp0 (a: Type) (wp: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
forall (k: pure_post a). (forall (x: a). {:pattern (guard_free (k x))} post x ==> k x) ==> wp k
(** Subsumption for the PURE effect *)
unfold
let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = forall (p: pure_post a). wp1 p ==> wp2 p
(** Closing a PURE WP under a binder for [b]
Clients should not use it directly,
instead use FStar.Pervasives.pure_close_wp *)
unfold
let pure_close_wp0 (a b: Type) (wp: (b -> GTot (pure_wp a))) : pure_wp a = fun (p: pure_post a) -> forall (b: b). wp b p
(** Trivial WP for PURE: Prove the WP with the trivial postcondition *)
unfold
let pure_trivial (a: Type) (wp: pure_wp a) = wp (fun (trivial_result: a) -> True)
(** Introduces the PURE effect.
The definition of the PURE effect is fixed.
NO USER SHOULD EVER CHANGE THIS. *)
total
new_effect {
PURE : a: Type -> wp: pure_wp a -> Effect
with
return_wp = pure_return0
; bind_wp = pure_bind_wp0
; if_then_else = pure_if_then_else0
; ite_wp = pure_ite_wp0
; stronger = pure_stronger
; close_wp = pure_close_wp0
; trivial = pure_trivial
}
(** [Pure] is a Hoare-style counterpart of [PURE]
Note the type of post, which allows to assume the precondition
for the well-formedness of the postcondition. c.f. #57 *)
effect Pure (a: Type) (pre: pure_pre) (post: pure_post' a pre) =
PURE a
(fun (p: pure_post a) -> pre /\ (forall (pure_result: a). post pure_result ==> p pure_result))
(** [Admit] is an effect abbreviation for a computation that
disregards the verification condition of its continuation *)
effect Admit (a: Type) = PURE a (fun (p: pure_post a) -> True)
(** The primitive effect [Tot] is definitionally equal to an instance of [PURE] *)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_null_wp *)
unfold
let pure_null_wp0 (a: Type) : pure_wp a = fun (p: pure_post a) -> forall (any_result: a). p any_result
(** [Tot]: From here on, we have [Tot] as a defined symbol in F*. *)
effect Tot (a: Type) = PURE a (pure_null_wp0 a)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assert_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assert_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p /\ post ()
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assume_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assume_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p ==> post ()
(**** The [GHOST] effect *)
(** [GHOST] is logically equivalent to [PURE], but distinguished from
it nominally so that specific, computationally irrelevant
operations, are provided only in [GHOST] and are erased during
extraction *)
total
new_effect GHOST = PURE
unfold
let purewp_id (a: Type) (wp: pure_wp a) = wp
(** [PURE] computations can be lifted to the [GHOST] effect (but not
vice versa) using just the identity lifting on pure wps *)
sub_effect PURE ~> GHOST { lift_wp = purewp_id }
(** [Ghost] is a the Hoare-style counterpart of [GHOST] *)
effect Ghost (a: Type) (pre: Type) (post: pure_post' a pre) =
GHOST a
(fun (p: pure_post a) -> pre /\ (forall (ghost_result: a). post ghost_result ==> p ghost_result)
)
(** As with [Tot], the primitive effect [GTot] is definitionally equal
to an instance of GHOST *)
effect GTot (a: Type) = GHOST a (pure_null_wp0 a)
(***** End trusted primitives *****)
(** This point onward, F* fully verifies all the definitions *)
(** [===] heterogeneous equality *)
let ( === ) (#a #b: Type) (x: a) (y: b) : logical = a == b /\ x == y
(** Dependent pairs [dtuple2] in concrete syntax is [x:a & b x].
Its values can be constructed with the concrete syntax [(| x, y |)] *)
unopteq
type dtuple2 (a: Type) (b: (a -> GTot Type)) =
| Mkdtuple2 : _1: a -> _2: b _1 -> dtuple2 a b
(** Squashed existential quantification, or dependent sums,
are written [exists (x:a). p x] : specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Exists (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a & p x)
(** Primitive type of mathematical integers, mapped to zarith in OCaml
extraction and to the SMT sort of integers *)
assume new
type int : eqtype
(**** Basic operators on booleans and integers *)
(** [&&] boolean conjunction *)
[@@ smt_theory_symbol]
assume
val op_AmpAmp: bool -> bool -> Tot bool
(** [||] boolean disjunction *)
[@@ smt_theory_symbol]
assume
val op_BarBar: bool -> bool -> Tot bool
(** [not] boolean negation *)
[@@ smt_theory_symbol]
assume
val op_Negation: bool -> Tot bool
(** Integer multiplication, no special symbol. See FStar.Mul *)
[@@ smt_theory_symbol]
assume
val op_Multiply: int -> int -> Tot int
(** [-] integer subtraction *)
[@@ smt_theory_symbol]
assume
val op_Subtraction: int -> int -> Tot int
(** [+] integer addition *)
[@@ smt_theory_symbol]
assume
val op_Addition: int -> int -> Tot int
(** [-] prefix unary integer negation *)
[@@ smt_theory_symbol]
assume
val op_Minus: int -> Tot int
(** [<=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThanOrEqual: int -> int -> Tot bool
(** [>] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThan: int -> int -> Tot bool
(** [>=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThanOrEqual: int -> int -> Tot bool
(** [<] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThan: int -> int -> Tot bool
(** [=] decidable equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_Equality: #a: eqtype -> a -> a -> Tot bool
(** [<>] decidable dis-equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_disEquality: #a: eqtype -> a -> a -> Tot bool
(** The extensible open inductive type of exceptions *)
assume new
type exn : Type0
(** [array]: TODO: should be removed.
See FStar.Seq, LowStar.Buffer, etc. *)
assume new
type array : Type -> Type0
(** String concatenation and its abbreviation as [^]. TODO, both
should be removed in favor of what is present in FStar.String *)
assume
val strcat: string -> string -> Tot string
inline_for_extraction unfold
let op_Hat s1 s2 = strcat s1 s2
(** The inductive type of polymorphic lists *)
type list (a: Type) =
| Nil : list a
| Cons : hd: a -> tl: list a -> list a
(** The [M] marker is interpreted by the Dijkstra Monads for Free
construction. It has a "double meaning", either as an alias for
reasoning about the direct definitions, or as a marker for places
where a CPS transformation should happen. *)
effect M (a: Type) = Tot a (attributes cps)
(** Returning a value into the [M] effect *)
let returnM (a: Type) (x: a) : M a = x
(** [as_requires] turns a WP into a precondition, by applying it to
a trivial postcondition *)
unfold
let as_requires (#a: Type) (wp: pure_wp a) : pure_pre = wp (fun x -> True)
(** [as_ensures] turns a WP into a postcondition, relying on a kind of
double negation translation. *)
unfold
let as_ensures (#a: Type) (wp: pure_wp a) : pure_post a = fun (x:a) -> ~(wp (fun y -> (y =!= x)))
(** The keyword term-level keyword [assume] is desugared to [_assume].
It explicitly provides an escape hatch to assume a given property
[p]. *)
[@@ warn_on_use "Uses an axiom"]
assume
val _assume (p: Type) : Pure unit (requires (True)) (ensures (fun x -> p))
(** [admit] is another escape hatch: It discards the continuation and
returns a value of any type *)
[@@ warn_on_use "Uses an axiom"]
assume
val admit: #a: Type -> unit -> Admit a
(** [magic] is another escape hatch: It retains the continuation but
returns a value of any type *)
[@@ warn_on_use "Uses an axiom"]
assume
val magic: #a: Type -> unit -> Tot a
(** [unsafe_coerce] is another escape hatch: It coerces an [a] to a
[b]. *)
[@@ warn_on_use "Uses an axiom"]
irreducible
let unsafe_coerce (#a #b: Type) (x: a) : b =
admit ();
x
(** [admitP]: TODO: Unused ... remove? *)
[@@ warn_on_use "Uses an axiom"]
assume
val admitP (p: Type) : Pure unit True (fun x -> p)
(** The keyword term-level keyword [assert] is desugared to [_assert].
It force a proof of a property [p], then assuming [p] for the
continuation. *)
val _assert (p: Type) : Pure unit (requires p) (ensures (fun x -> p))
let _assert p = ()
(** Logically equivalent to assert; TODO remove? *)
val cut (p: Type) : Pure unit (requires p) (fun x -> p)
let cut p = ()
(** The type of non-negative integers *)
type nat = i: int{i >= 0}
(** The type of positive integers *)
type pos = i: int{i > 0}
(** The type of non-zero integers *)
type nonzero = i: int{i <> 0}
/// Arbitrary precision ints are compiled to zarith (big_ints) in
/// OCaml and to .NET BigInteger in F#. Both the modulus and division
/// operations are Euclidean and are mapped to the corresponding
/// theory symbols in the SMT encoding
(** Euclidean modulus *)
[@@ smt_theory_symbol]
assume
val op_Modulus: int -> nonzero -> Tot int
(** Euclidean division, written [/] *)
[@@ smt_theory_symbol]
assume
val op_Division: int -> nonzero -> Tot int
(** [pow2 x] is [2^x]:
TODO: maybe move this to FStar.Int *)
let rec pow2 (x: nat) : Tot pos =
match x with
| 0 -> 1
| _ -> 2 `op_Multiply` (pow2 (x - 1))
(** [min] computes the minimum of two [int]s *)
let min x y = if x <= y then x else y
(** [abs] computes the absolute value of an [int] *)
let abs (x: int) : Tot int = if x >= 0 then x else - x
(** A primitive printer for booleans:
TODO: unnecessary, this could easily be defined *)
assume
val string_of_bool: bool -> Tot string
(** A primitive printer for [int] *)
assume
val string_of_int: int -> Tot string
(** THIS IS MEANT TO BE KEPT IN SYNC WITH FStar.CheckedFiles.fs
Incrementing this forces all .checked files to be invalidated *) | false | true | prims.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 __cache_version_number__ : Prims.int | [] | Prims.__cache_version_number__ | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.int | {
"end_col": 33,
"end_line": 711,
"start_col": 31,
"start_line": 711
} |
|
Prims.Tot | val as_requires (#a: Type) (wp: pure_wp a) : pure_pre | [
{
"abbrev": false,
"full_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_requires (#a: Type) (wp: pure_wp a) : pure_pre = wp (fun x -> True) | val as_requires (#a: Type) (wp: pure_wp a) : pure_pre
let as_requires (#a: Type) (wp: pure_wp a) : pure_pre = | false | null | false | wp (fun x -> True) | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.pure_wp",
"Prims.l_True",
"Prims.pure_pre"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0
let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp}
(** This predicate is an internal detail, used to optimize the
encoding of some quantifiers to SMT by omitting their typing
guards. This is safe to use only when the quantifier serves to
introduce a local macro---use with caution. *)
assume
type guard_free : Type0 -> Type0
(** The return combinator for the PURE effect requires
proving the postcondition only on [x]
Clients should not use it directly,
instead use FStar.Pervasives.pure_return *)
unfold
let pure_return0 (a: Type) (x: a) : pure_wp a =
fun (p: pure_post a) ->
forall (return_val: a). return_val == x ==> p return_val
(** Sequential composition for the PURE effect
Clients should not use it directly,
instead use FStar.Pervasives.pure_bind_wp *)
unfold
let pure_bind_wp0
(a b: Type)
(wp1: pure_wp a)
(wp2: (a -> GTot (pure_wp b)))
: pure_wp b
= fun (p: pure_post b) ->
wp1 (fun (bind_result_1: a) -> wp2 bind_result_1 p)
(** Conditional composition for the PURE effect
The combinator is optimized to make use of how the typechecker generates VC
for conditionals.
The more intuitive form of the combinator would have been:
[(p ==> wp_then post) /\ (~p ==> wp_else post)]
However, the way the typechecker constructs the VC, [wp_then] is already
weakened with [p].
Hence, here we only weaken [wp_else]
Clients should not use it directly,
instead use FStar.Pervasives.pure_if_then_else *)
unfold
let pure_if_then_else0 (a p: Type) (wp_then wp_else: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
wp_then post /\ (~p ==> wp_else post)
(** Conditional composition for the PURE effect, while trying to avoid
duplicating the postcondition by giving it a local name [k].
Note the use of [guard_free] here: [k] is just meant to be a macro
for [post].
Clients should not use it directly,
instead use FStar.Pervasives.pure_ite_wp *)
unfold
let pure_ite_wp0 (a: Type) (wp: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
forall (k: pure_post a). (forall (x: a). {:pattern (guard_free (k x))} post x ==> k x) ==> wp k
(** Subsumption for the PURE effect *)
unfold
let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = forall (p: pure_post a). wp1 p ==> wp2 p
(** Closing a PURE WP under a binder for [b]
Clients should not use it directly,
instead use FStar.Pervasives.pure_close_wp *)
unfold
let pure_close_wp0 (a b: Type) (wp: (b -> GTot (pure_wp a))) : pure_wp a = fun (p: pure_post a) -> forall (b: b). wp b p
(** Trivial WP for PURE: Prove the WP with the trivial postcondition *)
unfold
let pure_trivial (a: Type) (wp: pure_wp a) = wp (fun (trivial_result: a) -> True)
(** Introduces the PURE effect.
The definition of the PURE effect is fixed.
NO USER SHOULD EVER CHANGE THIS. *)
total
new_effect {
PURE : a: Type -> wp: pure_wp a -> Effect
with
return_wp = pure_return0
; bind_wp = pure_bind_wp0
; if_then_else = pure_if_then_else0
; ite_wp = pure_ite_wp0
; stronger = pure_stronger
; close_wp = pure_close_wp0
; trivial = pure_trivial
}
(** [Pure] is a Hoare-style counterpart of [PURE]
Note the type of post, which allows to assume the precondition
for the well-formedness of the postcondition. c.f. #57 *)
effect Pure (a: Type) (pre: pure_pre) (post: pure_post' a pre) =
PURE a
(fun (p: pure_post a) -> pre /\ (forall (pure_result: a). post pure_result ==> p pure_result))
(** [Admit] is an effect abbreviation for a computation that
disregards the verification condition of its continuation *)
effect Admit (a: Type) = PURE a (fun (p: pure_post a) -> True)
(** The primitive effect [Tot] is definitionally equal to an instance of [PURE] *)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_null_wp *)
unfold
let pure_null_wp0 (a: Type) : pure_wp a = fun (p: pure_post a) -> forall (any_result: a). p any_result
(** [Tot]: From here on, we have [Tot] as a defined symbol in F*. *)
effect Tot (a: Type) = PURE a (pure_null_wp0 a)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assert_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assert_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p /\ post ()
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assume_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assume_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p ==> post ()
(**** The [GHOST] effect *)
(** [GHOST] is logically equivalent to [PURE], but distinguished from
it nominally so that specific, computationally irrelevant
operations, are provided only in [GHOST] and are erased during
extraction *)
total
new_effect GHOST = PURE
unfold
let purewp_id (a: Type) (wp: pure_wp a) = wp
(** [PURE] computations can be lifted to the [GHOST] effect (but not
vice versa) using just the identity lifting on pure wps *)
sub_effect PURE ~> GHOST { lift_wp = purewp_id }
(** [Ghost] is a the Hoare-style counterpart of [GHOST] *)
effect Ghost (a: Type) (pre: Type) (post: pure_post' a pre) =
GHOST a
(fun (p: pure_post a) -> pre /\ (forall (ghost_result: a). post ghost_result ==> p ghost_result)
)
(** As with [Tot], the primitive effect [GTot] is definitionally equal
to an instance of GHOST *)
effect GTot (a: Type) = GHOST a (pure_null_wp0 a)
(***** End trusted primitives *****)
(** This point onward, F* fully verifies all the definitions *)
(** [===] heterogeneous equality *)
let ( === ) (#a #b: Type) (x: a) (y: b) : logical = a == b /\ x == y
(** Dependent pairs [dtuple2] in concrete syntax is [x:a & b x].
Its values can be constructed with the concrete syntax [(| x, y |)] *)
unopteq
type dtuple2 (a: Type) (b: (a -> GTot Type)) =
| Mkdtuple2 : _1: a -> _2: b _1 -> dtuple2 a b
(** Squashed existential quantification, or dependent sums,
are written [exists (x:a). p x] : specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Exists (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a & p x)
(** Primitive type of mathematical integers, mapped to zarith in OCaml
extraction and to the SMT sort of integers *)
assume new
type int : eqtype
(**** Basic operators on booleans and integers *)
(** [&&] boolean conjunction *)
[@@ smt_theory_symbol]
assume
val op_AmpAmp: bool -> bool -> Tot bool
(** [||] boolean disjunction *)
[@@ smt_theory_symbol]
assume
val op_BarBar: bool -> bool -> Tot bool
(** [not] boolean negation *)
[@@ smt_theory_symbol]
assume
val op_Negation: bool -> Tot bool
(** Integer multiplication, no special symbol. See FStar.Mul *)
[@@ smt_theory_symbol]
assume
val op_Multiply: int -> int -> Tot int
(** [-] integer subtraction *)
[@@ smt_theory_symbol]
assume
val op_Subtraction: int -> int -> Tot int
(** [+] integer addition *)
[@@ smt_theory_symbol]
assume
val op_Addition: int -> int -> Tot int
(** [-] prefix unary integer negation *)
[@@ smt_theory_symbol]
assume
val op_Minus: int -> Tot int
(** [<=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThanOrEqual: int -> int -> Tot bool
(** [>] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThan: int -> int -> Tot bool
(** [>=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThanOrEqual: int -> int -> Tot bool
(** [<] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThan: int -> int -> Tot bool
(** [=] decidable equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_Equality: #a: eqtype -> a -> a -> Tot bool
(** [<>] decidable dis-equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_disEquality: #a: eqtype -> a -> a -> Tot bool
(** The extensible open inductive type of exceptions *)
assume new
type exn : Type0
(** [array]: TODO: should be removed.
See FStar.Seq, LowStar.Buffer, etc. *)
assume new
type array : Type -> Type0
(** String concatenation and its abbreviation as [^]. TODO, both
should be removed in favor of what is present in FStar.String *)
assume
val strcat: string -> string -> Tot string
inline_for_extraction unfold
let op_Hat s1 s2 = strcat s1 s2
(** The inductive type of polymorphic lists *)
type list (a: Type) =
| Nil : list a
| Cons : hd: a -> tl: list a -> list a
(** The [M] marker is interpreted by the Dijkstra Monads for Free
construction. It has a "double meaning", either as an alias for
reasoning about the direct definitions, or as a marker for places
where a CPS transformation should happen. *)
effect M (a: Type) = Tot a (attributes cps)
(** Returning a value into the [M] effect *)
let returnM (a: Type) (x: a) : M a = x
(** [as_requires] turns a WP into a precondition, by applying it to
a trivial postcondition *) | false | false | prims.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 as_requires (#a: Type) (wp: pure_wp a) : pure_pre | [] | Prims.as_requires | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | wp: Prims.pure_wp a -> Prims.pure_pre | {
"end_col": 74,
"end_line": 609,
"start_col": 56,
"start_line": 609
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2 | let subtype_of (p1 p2: Type) = | false | null | false | forall (x: p1). has_type x p2 | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.has_type",
"Prims.logical"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element | false | true | prims.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 subtype_of : p1: Type -> p2: Type -> Prims.logical | [] | Prims.subtype_of | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p1: Type -> p2: Type -> Prims.logical | {
"end_col": 60,
"end_line": 270,
"start_col": 31,
"start_line": 270
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let min x y = if x <= y then x else y | let min x y = | false | null | false | if x <= y then x else y | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.int",
"Prims.op_LessThanOrEqual",
"Prims.bool"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0
let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp}
(** This predicate is an internal detail, used to optimize the
encoding of some quantifiers to SMT by omitting their typing
guards. This is safe to use only when the quantifier serves to
introduce a local macro---use with caution. *)
assume
type guard_free : Type0 -> Type0
(** The return combinator for the PURE effect requires
proving the postcondition only on [x]
Clients should not use it directly,
instead use FStar.Pervasives.pure_return *)
unfold
let pure_return0 (a: Type) (x: a) : pure_wp a =
fun (p: pure_post a) ->
forall (return_val: a). return_val == x ==> p return_val
(** Sequential composition for the PURE effect
Clients should not use it directly,
instead use FStar.Pervasives.pure_bind_wp *)
unfold
let pure_bind_wp0
(a b: Type)
(wp1: pure_wp a)
(wp2: (a -> GTot (pure_wp b)))
: pure_wp b
= fun (p: pure_post b) ->
wp1 (fun (bind_result_1: a) -> wp2 bind_result_1 p)
(** Conditional composition for the PURE effect
The combinator is optimized to make use of how the typechecker generates VC
for conditionals.
The more intuitive form of the combinator would have been:
[(p ==> wp_then post) /\ (~p ==> wp_else post)]
However, the way the typechecker constructs the VC, [wp_then] is already
weakened with [p].
Hence, here we only weaken [wp_else]
Clients should not use it directly,
instead use FStar.Pervasives.pure_if_then_else *)
unfold
let pure_if_then_else0 (a p: Type) (wp_then wp_else: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
wp_then post /\ (~p ==> wp_else post)
(** Conditional composition for the PURE effect, while trying to avoid
duplicating the postcondition by giving it a local name [k].
Note the use of [guard_free] here: [k] is just meant to be a macro
for [post].
Clients should not use it directly,
instead use FStar.Pervasives.pure_ite_wp *)
unfold
let pure_ite_wp0 (a: Type) (wp: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
forall (k: pure_post a). (forall (x: a). {:pattern (guard_free (k x))} post x ==> k x) ==> wp k
(** Subsumption for the PURE effect *)
unfold
let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = forall (p: pure_post a). wp1 p ==> wp2 p
(** Closing a PURE WP under a binder for [b]
Clients should not use it directly,
instead use FStar.Pervasives.pure_close_wp *)
unfold
let pure_close_wp0 (a b: Type) (wp: (b -> GTot (pure_wp a))) : pure_wp a = fun (p: pure_post a) -> forall (b: b). wp b p
(** Trivial WP for PURE: Prove the WP with the trivial postcondition *)
unfold
let pure_trivial (a: Type) (wp: pure_wp a) = wp (fun (trivial_result: a) -> True)
(** Introduces the PURE effect.
The definition of the PURE effect is fixed.
NO USER SHOULD EVER CHANGE THIS. *)
total
new_effect {
PURE : a: Type -> wp: pure_wp a -> Effect
with
return_wp = pure_return0
; bind_wp = pure_bind_wp0
; if_then_else = pure_if_then_else0
; ite_wp = pure_ite_wp0
; stronger = pure_stronger
; close_wp = pure_close_wp0
; trivial = pure_trivial
}
(** [Pure] is a Hoare-style counterpart of [PURE]
Note the type of post, which allows to assume the precondition
for the well-formedness of the postcondition. c.f. #57 *)
effect Pure (a: Type) (pre: pure_pre) (post: pure_post' a pre) =
PURE a
(fun (p: pure_post a) -> pre /\ (forall (pure_result: a). post pure_result ==> p pure_result))
(** [Admit] is an effect abbreviation for a computation that
disregards the verification condition of its continuation *)
effect Admit (a: Type) = PURE a (fun (p: pure_post a) -> True)
(** The primitive effect [Tot] is definitionally equal to an instance of [PURE] *)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_null_wp *)
unfold
let pure_null_wp0 (a: Type) : pure_wp a = fun (p: pure_post a) -> forall (any_result: a). p any_result
(** [Tot]: From here on, we have [Tot] as a defined symbol in F*. *)
effect Tot (a: Type) = PURE a (pure_null_wp0 a)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assert_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assert_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p /\ post ()
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assume_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assume_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p ==> post ()
(**** The [GHOST] effect *)
(** [GHOST] is logically equivalent to [PURE], but distinguished from
it nominally so that specific, computationally irrelevant
operations, are provided only in [GHOST] and are erased during
extraction *)
total
new_effect GHOST = PURE
unfold
let purewp_id (a: Type) (wp: pure_wp a) = wp
(** [PURE] computations can be lifted to the [GHOST] effect (but not
vice versa) using just the identity lifting on pure wps *)
sub_effect PURE ~> GHOST { lift_wp = purewp_id }
(** [Ghost] is a the Hoare-style counterpart of [GHOST] *)
effect Ghost (a: Type) (pre: Type) (post: pure_post' a pre) =
GHOST a
(fun (p: pure_post a) -> pre /\ (forall (ghost_result: a). post ghost_result ==> p ghost_result)
)
(** As with [Tot], the primitive effect [GTot] is definitionally equal
to an instance of GHOST *)
effect GTot (a: Type) = GHOST a (pure_null_wp0 a)
(***** End trusted primitives *****)
(** This point onward, F* fully verifies all the definitions *)
(** [===] heterogeneous equality *)
let ( === ) (#a #b: Type) (x: a) (y: b) : logical = a == b /\ x == y
(** Dependent pairs [dtuple2] in concrete syntax is [x:a & b x].
Its values can be constructed with the concrete syntax [(| x, y |)] *)
unopteq
type dtuple2 (a: Type) (b: (a -> GTot Type)) =
| Mkdtuple2 : _1: a -> _2: b _1 -> dtuple2 a b
(** Squashed existential quantification, or dependent sums,
are written [exists (x:a). p x] : specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Exists (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a & p x)
(** Primitive type of mathematical integers, mapped to zarith in OCaml
extraction and to the SMT sort of integers *)
assume new
type int : eqtype
(**** Basic operators on booleans and integers *)
(** [&&] boolean conjunction *)
[@@ smt_theory_symbol]
assume
val op_AmpAmp: bool -> bool -> Tot bool
(** [||] boolean disjunction *)
[@@ smt_theory_symbol]
assume
val op_BarBar: bool -> bool -> Tot bool
(** [not] boolean negation *)
[@@ smt_theory_symbol]
assume
val op_Negation: bool -> Tot bool
(** Integer multiplication, no special symbol. See FStar.Mul *)
[@@ smt_theory_symbol]
assume
val op_Multiply: int -> int -> Tot int
(** [-] integer subtraction *)
[@@ smt_theory_symbol]
assume
val op_Subtraction: int -> int -> Tot int
(** [+] integer addition *)
[@@ smt_theory_symbol]
assume
val op_Addition: int -> int -> Tot int
(** [-] prefix unary integer negation *)
[@@ smt_theory_symbol]
assume
val op_Minus: int -> Tot int
(** [<=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThanOrEqual: int -> int -> Tot bool
(** [>] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThan: int -> int -> Tot bool
(** [>=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThanOrEqual: int -> int -> Tot bool
(** [<] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThan: int -> int -> Tot bool
(** [=] decidable equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_Equality: #a: eqtype -> a -> a -> Tot bool
(** [<>] decidable dis-equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_disEquality: #a: eqtype -> a -> a -> Tot bool
(** The extensible open inductive type of exceptions *)
assume new
type exn : Type0
(** [array]: TODO: should be removed.
See FStar.Seq, LowStar.Buffer, etc. *)
assume new
type array : Type -> Type0
(** String concatenation and its abbreviation as [^]. TODO, both
should be removed in favor of what is present in FStar.String *)
assume
val strcat: string -> string -> Tot string
inline_for_extraction unfold
let op_Hat s1 s2 = strcat s1 s2
(** The inductive type of polymorphic lists *)
type list (a: Type) =
| Nil : list a
| Cons : hd: a -> tl: list a -> list a
(** The [M] marker is interpreted by the Dijkstra Monads for Free
construction. It has a "double meaning", either as an alias for
reasoning about the direct definitions, or as a marker for places
where a CPS transformation should happen. *)
effect M (a: Type) = Tot a (attributes cps)
(** Returning a value into the [M] effect *)
let returnM (a: Type) (x: a) : M a = x
(** [as_requires] turns a WP into a precondition, by applying it to
a trivial postcondition *)
unfold
let as_requires (#a: Type) (wp: pure_wp a) : pure_pre = wp (fun x -> True)
(** [as_ensures] turns a WP into a postcondition, relying on a kind of
double negation translation. *)
unfold
let as_ensures (#a: Type) (wp: pure_wp a) : pure_post a = fun (x:a) -> ~(wp (fun y -> (y =!= x)))
(** The keyword term-level keyword [assume] is desugared to [_assume].
It explicitly provides an escape hatch to assume a given property
[p]. *)
[@@ warn_on_use "Uses an axiom"]
assume
val _assume (p: Type) : Pure unit (requires (True)) (ensures (fun x -> p))
(** [admit] is another escape hatch: It discards the continuation and
returns a value of any type *)
[@@ warn_on_use "Uses an axiom"]
assume
val admit: #a: Type -> unit -> Admit a
(** [magic] is another escape hatch: It retains the continuation but
returns a value of any type *)
[@@ warn_on_use "Uses an axiom"]
assume
val magic: #a: Type -> unit -> Tot a
(** [unsafe_coerce] is another escape hatch: It coerces an [a] to a
[b]. *)
[@@ warn_on_use "Uses an axiom"]
irreducible
let unsafe_coerce (#a #b: Type) (x: a) : b =
admit ();
x
(** [admitP]: TODO: Unused ... remove? *)
[@@ warn_on_use "Uses an axiom"]
assume
val admitP (p: Type) : Pure unit True (fun x -> p)
(** The keyword term-level keyword [assert] is desugared to [_assert].
It force a proof of a property [p], then assuming [p] for the
continuation. *)
val _assert (p: Type) : Pure unit (requires p) (ensures (fun x -> p))
let _assert p = ()
(** Logically equivalent to assert; TODO remove? *)
val cut (p: Type) : Pure unit (requires p) (fun x -> p)
let cut p = ()
(** The type of non-negative integers *)
type nat = i: int{i >= 0}
(** The type of positive integers *)
type pos = i: int{i > 0}
(** The type of non-zero integers *)
type nonzero = i: int{i <> 0}
/// Arbitrary precision ints are compiled to zarith (big_ints) in
/// OCaml and to .NET BigInteger in F#. Both the modulus and division
/// operations are Euclidean and are mapped to the corresponding
/// theory symbols in the SMT encoding
(** Euclidean modulus *)
[@@ smt_theory_symbol]
assume
val op_Modulus: int -> nonzero -> Tot int
(** Euclidean division, written [/] *)
[@@ smt_theory_symbol]
assume
val op_Division: int -> nonzero -> Tot int
(** [pow2 x] is [2^x]:
TODO: maybe move this to FStar.Int *)
let rec pow2 (x: nat) : Tot pos =
match x with
| 0 -> 1
| _ -> 2 `op_Multiply` (pow2 (x - 1)) | false | true | prims.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 min : x: Prims.int -> y: Prims.int -> Prims.int | [] | Prims.min | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.int -> y: Prims.int -> Prims.int | {
"end_col": 37,
"end_line": 693,
"start_col": 14,
"start_line": 693
} |
|
Prims.Tot | val as_ensures (#a: Type) (wp: pure_wp a) : pure_post a | [
{
"abbrev": false,
"full_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_ensures (#a: Type) (wp: pure_wp a) : pure_post a = fun (x:a) -> ~(wp (fun y -> (y =!= x))) | val as_ensures (#a: Type) (wp: pure_wp a) : pure_post a
let as_ensures (#a: Type) (wp: pure_wp a) : pure_post a = | false | null | false | fun (x: a) -> ~(wp (fun y -> (y =!= x))) | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.pure_wp",
"Prims.l_not",
"Prims.l_True",
"Prims.eq2",
"Prims.pure_post"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0
let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp}
(** This predicate is an internal detail, used to optimize the
encoding of some quantifiers to SMT by omitting their typing
guards. This is safe to use only when the quantifier serves to
introduce a local macro---use with caution. *)
assume
type guard_free : Type0 -> Type0
(** The return combinator for the PURE effect requires
proving the postcondition only on [x]
Clients should not use it directly,
instead use FStar.Pervasives.pure_return *)
unfold
let pure_return0 (a: Type) (x: a) : pure_wp a =
fun (p: pure_post a) ->
forall (return_val: a). return_val == x ==> p return_val
(** Sequential composition for the PURE effect
Clients should not use it directly,
instead use FStar.Pervasives.pure_bind_wp *)
unfold
let pure_bind_wp0
(a b: Type)
(wp1: pure_wp a)
(wp2: (a -> GTot (pure_wp b)))
: pure_wp b
= fun (p: pure_post b) ->
wp1 (fun (bind_result_1: a) -> wp2 bind_result_1 p)
(** Conditional composition for the PURE effect
The combinator is optimized to make use of how the typechecker generates VC
for conditionals.
The more intuitive form of the combinator would have been:
[(p ==> wp_then post) /\ (~p ==> wp_else post)]
However, the way the typechecker constructs the VC, [wp_then] is already
weakened with [p].
Hence, here we only weaken [wp_else]
Clients should not use it directly,
instead use FStar.Pervasives.pure_if_then_else *)
unfold
let pure_if_then_else0 (a p: Type) (wp_then wp_else: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
wp_then post /\ (~p ==> wp_else post)
(** Conditional composition for the PURE effect, while trying to avoid
duplicating the postcondition by giving it a local name [k].
Note the use of [guard_free] here: [k] is just meant to be a macro
for [post].
Clients should not use it directly,
instead use FStar.Pervasives.pure_ite_wp *)
unfold
let pure_ite_wp0 (a: Type) (wp: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
forall (k: pure_post a). (forall (x: a). {:pattern (guard_free (k x))} post x ==> k x) ==> wp k
(** Subsumption for the PURE effect *)
unfold
let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = forall (p: pure_post a). wp1 p ==> wp2 p
(** Closing a PURE WP under a binder for [b]
Clients should not use it directly,
instead use FStar.Pervasives.pure_close_wp *)
unfold
let pure_close_wp0 (a b: Type) (wp: (b -> GTot (pure_wp a))) : pure_wp a = fun (p: pure_post a) -> forall (b: b). wp b p
(** Trivial WP for PURE: Prove the WP with the trivial postcondition *)
unfold
let pure_trivial (a: Type) (wp: pure_wp a) = wp (fun (trivial_result: a) -> True)
(** Introduces the PURE effect.
The definition of the PURE effect is fixed.
NO USER SHOULD EVER CHANGE THIS. *)
total
new_effect {
PURE : a: Type -> wp: pure_wp a -> Effect
with
return_wp = pure_return0
; bind_wp = pure_bind_wp0
; if_then_else = pure_if_then_else0
; ite_wp = pure_ite_wp0
; stronger = pure_stronger
; close_wp = pure_close_wp0
; trivial = pure_trivial
}
(** [Pure] is a Hoare-style counterpart of [PURE]
Note the type of post, which allows to assume the precondition
for the well-formedness of the postcondition. c.f. #57 *)
effect Pure (a: Type) (pre: pure_pre) (post: pure_post' a pre) =
PURE a
(fun (p: pure_post a) -> pre /\ (forall (pure_result: a). post pure_result ==> p pure_result))
(** [Admit] is an effect abbreviation for a computation that
disregards the verification condition of its continuation *)
effect Admit (a: Type) = PURE a (fun (p: pure_post a) -> True)
(** The primitive effect [Tot] is definitionally equal to an instance of [PURE] *)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_null_wp *)
unfold
let pure_null_wp0 (a: Type) : pure_wp a = fun (p: pure_post a) -> forall (any_result: a). p any_result
(** [Tot]: From here on, we have [Tot] as a defined symbol in F*. *)
effect Tot (a: Type) = PURE a (pure_null_wp0 a)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assert_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assert_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p /\ post ()
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assume_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assume_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p ==> post ()
(**** The [GHOST] effect *)
(** [GHOST] is logically equivalent to [PURE], but distinguished from
it nominally so that specific, computationally irrelevant
operations, are provided only in [GHOST] and are erased during
extraction *)
total
new_effect GHOST = PURE
unfold
let purewp_id (a: Type) (wp: pure_wp a) = wp
(** [PURE] computations can be lifted to the [GHOST] effect (but not
vice versa) using just the identity lifting on pure wps *)
sub_effect PURE ~> GHOST { lift_wp = purewp_id }
(** [Ghost] is a the Hoare-style counterpart of [GHOST] *)
effect Ghost (a: Type) (pre: Type) (post: pure_post' a pre) =
GHOST a
(fun (p: pure_post a) -> pre /\ (forall (ghost_result: a). post ghost_result ==> p ghost_result)
)
(** As with [Tot], the primitive effect [GTot] is definitionally equal
to an instance of GHOST *)
effect GTot (a: Type) = GHOST a (pure_null_wp0 a)
(***** End trusted primitives *****)
(** This point onward, F* fully verifies all the definitions *)
(** [===] heterogeneous equality *)
let ( === ) (#a #b: Type) (x: a) (y: b) : logical = a == b /\ x == y
(** Dependent pairs [dtuple2] in concrete syntax is [x:a & b x].
Its values can be constructed with the concrete syntax [(| x, y |)] *)
unopteq
type dtuple2 (a: Type) (b: (a -> GTot Type)) =
| Mkdtuple2 : _1: a -> _2: b _1 -> dtuple2 a b
(** Squashed existential quantification, or dependent sums,
are written [exists (x:a). p x] : specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Exists (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a & p x)
(** Primitive type of mathematical integers, mapped to zarith in OCaml
extraction and to the SMT sort of integers *)
assume new
type int : eqtype
(**** Basic operators on booleans and integers *)
(** [&&] boolean conjunction *)
[@@ smt_theory_symbol]
assume
val op_AmpAmp: bool -> bool -> Tot bool
(** [||] boolean disjunction *)
[@@ smt_theory_symbol]
assume
val op_BarBar: bool -> bool -> Tot bool
(** [not] boolean negation *)
[@@ smt_theory_symbol]
assume
val op_Negation: bool -> Tot bool
(** Integer multiplication, no special symbol. See FStar.Mul *)
[@@ smt_theory_symbol]
assume
val op_Multiply: int -> int -> Tot int
(** [-] integer subtraction *)
[@@ smt_theory_symbol]
assume
val op_Subtraction: int -> int -> Tot int
(** [+] integer addition *)
[@@ smt_theory_symbol]
assume
val op_Addition: int -> int -> Tot int
(** [-] prefix unary integer negation *)
[@@ smt_theory_symbol]
assume
val op_Minus: int -> Tot int
(** [<=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThanOrEqual: int -> int -> Tot bool
(** [>] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThan: int -> int -> Tot bool
(** [>=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThanOrEqual: int -> int -> Tot bool
(** [<] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThan: int -> int -> Tot bool
(** [=] decidable equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_Equality: #a: eqtype -> a -> a -> Tot bool
(** [<>] decidable dis-equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_disEquality: #a: eqtype -> a -> a -> Tot bool
(** The extensible open inductive type of exceptions *)
assume new
type exn : Type0
(** [array]: TODO: should be removed.
See FStar.Seq, LowStar.Buffer, etc. *)
assume new
type array : Type -> Type0
(** String concatenation and its abbreviation as [^]. TODO, both
should be removed in favor of what is present in FStar.String *)
assume
val strcat: string -> string -> Tot string
inline_for_extraction unfold
let op_Hat s1 s2 = strcat s1 s2
(** The inductive type of polymorphic lists *)
type list (a: Type) =
| Nil : list a
| Cons : hd: a -> tl: list a -> list a
(** The [M] marker is interpreted by the Dijkstra Monads for Free
construction. It has a "double meaning", either as an alias for
reasoning about the direct definitions, or as a marker for places
where a CPS transformation should happen. *)
effect M (a: Type) = Tot a (attributes cps)
(** Returning a value into the [M] effect *)
let returnM (a: Type) (x: a) : M a = x
(** [as_requires] turns a WP into a precondition, by applying it to
a trivial postcondition *)
unfold
let as_requires (#a: Type) (wp: pure_wp a) : pure_pre = wp (fun x -> True)
(** [as_ensures] turns a WP into a postcondition, relying on a kind of
double negation translation. *) | false | false | prims.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 as_ensures (#a: Type) (wp: pure_wp a) : pure_post a | [] | Prims.as_ensures | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | wp: Prims.pure_wp a -> Prims.pure_post a | {
"end_col": 97,
"end_line": 614,
"start_col": 58,
"start_line": 614
} |
Prims.Tot | val pow2 (x: nat) : Tot pos | [
{
"abbrev": false,
"full_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 pow2 (x: nat) : Tot pos =
match x with
| 0 -> 1
| _ -> 2 `op_Multiply` (pow2 (x - 1)) | val pow2 (x: nat) : Tot pos
let rec pow2 (x: nat) : Tot pos = | false | null | false | match x with
| 0 -> 1
| _ -> 2 `op_Multiply` (pow2 (x - 1)) | {
"checked_file": "prims.fst.checked",
"dependencies": [],
"interface_file": false,
"source_file": "prims.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.int",
"Prims.op_Multiply",
"Prims.pow2",
"Prims.op_Subtraction",
"Prims.pos"
] | [] | (*
Copyright 2008-2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Prims
/// This module is implicitly opened in the scope of all other modules.
///
/// It provides the very basic primitives on which F* is
/// built, including the definition of total functions, the basic
/// logical connectives, the PURE and GHOST effects and the like.
///
/// While some of the primitives have logical significance, others are
/// define various conveniences in the language, e.g., type of
/// attributes.
(***** Begin trusted primitives *****)
(** Primitives up to the definition of the GTot effect are trusted
Beyond that all definitions are fully verified *)
(** Type of attributes *)
assume new
type attribute : Type0
(** An attribute indicating that some definition must be processed by the
Dijkstra monads for free construction *)
assume
val cps:attribute
(** A predicate to express when a type supports decidable equality
The type-checker emits axioms for [hasEq] for each inductive type *)
assume
type hasEq : Type -> GTot Type0
(** A convenient abbreviation, [eqtype] is the type of types in
universe 0 which support decidable equality *)
type eqtype = a: Type0{hasEq a}
(** [bool] is a two element type with elements [true] and [false]. We
assume it is primitive, for convenient interop with other
languages, although it could easily be defined as an inductive type
with two cases, [BTrue | BFalse] *)
assume new
type bool : eqtype
(** [empty] is the empty inductive type. The type with no
inhabitants represents logical falsehood. Note, [empty] is
seldom used directly in F*. We instead use its "squashed" variant,
[False], see below. *)
type empty =
(** [trivial] is the singleton inductive type---it is trivially
inhabited. Like [empty], [trivial] is seldom used. We instead use
its "squashed" variants, [True] *)
type trivial = | T
(** [unit]: another singleton type, with its only inhabitant written [()]
we assume it is primitive, for convenient interop with other languages *)
assume new
type unit : eqtype
(** [squash p] is a central type in F*---[squash p] is the proof
irrelevant analog of [p] and is represented as a unit
refinement. Squashed proofs are typically discharged using an SMT
solver, without any proof terms explicitly reconstructed. As
such, one way to think of [squash p] is as the type of properties
proven using classical axioms without building proof terms.
Note, [squash p] is just a unit refinement, it resides in universe
0, lowering the universe of [p]. From this perspective, one may
also see [squash] as a coercion down to universe 0.
The type is marked [tac_opaque] to indicate to Meta-F* that
instances of [squash] should not be unfolded when evaluating
tactics (since many optimizations in F*'s SMT encoding rely
specifically on occurrences of [squash].
See FStar.Squash for various ways of manipulating squashed
types. *)
[@@ "tac_opaque"]
type squash (p: Type) : Type0 = x: unit{p}
(** [auto_squash] is equivalent to [squash]. However, F* will
automatically insert `auto_squash` when simplifying terms,
converting terms of the form `p /\ True` to `auto_squash p`.
We distinguish these automatically inserted squashes from explicit,
user-written squashes.
A user should not have to manipulate [auto_squash] at all, except
in rare circumstances when writing tactics to process proofs that
have already been partially simplified by F*'s simplifier.
*)
let auto_squash (p: Type) = squash p
(** The [logical] type is transitionary. It is just an abbreviation
for [Type0], but is used to classify uses of the basic squashed
logical connectives that follow. Some day, we plan to remove the
[logical] type, replacing it with [prop] (also defined below).
The type is marked [private] to intentionally prevent user code
from referencing this type, hopefully easing the removal of
[logical] in the future. *)
private
type logical = Type0
(** An attribute indicating that a symbol is an smt theory symbol and
hence may not be used in smt patterns. The typechecker warns if
such symbols are used in patterns *)
assume
val smt_theory_symbol:attribute
(** [l_True] has a special bit of syntactic sugar. It is written just
as "True" and rendered in the ide as [True]. It is a squashed version
of constructive truth, [trivial]. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_True:logical = squash trivial
(** [l_False] has a special bit of syntactic sugar. It is written just
as "False" and rendered in the ide as [Falsee]. It is a squashed version
of constructive falsehood, the empty type. *)
[@@ "tac_opaque"; smt_theory_symbol]
let l_False:logical = squash empty
(** The type of provable equalities, defined as the usual inductive
type with a single constructor for reflexivity. As with the other
connectives, we often work instead with the squashed version of
equality, below. *)
type equals (#a: Type) (x: a) : a -> Type = | Refl : equals x x
(** [eq2] is the squashed version of [equals]. It's a proof
irrelevant, homogeneous equality in Type#0 and is written with
an infix binary [==].
TODO: instead of hard-wiring the == syntax,
we should just rename eq2 to op_Equals_Equals
*)
[@@ "tac_opaque"; smt_theory_symbol]
type eq2 (#a: Type) (x: a) (y: a) : logical = squash (equals x y)
(** bool-to-type coercion: This is often automatically inserted type,
when using a boolean in context expecting a type. But,
occasionally, one may have to write [b2t] explicitly *)
type b2t (b: bool) : logical = (b == true)
(** constructive conjunction *)
type pair (p: Type) (q: Type) = | Pair : _1:p -> _2:q -> pair p q
(** squashed conjunction, specialized to [Type0], written with an
infix binary [/\] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_and (p: logical) (q: logical) : logical = squash (pair p q)
(** constructive disjunction *)
type sum (p: Type) (q: Type) =
| Left : v:p -> sum p q
| Right : v:q -> sum p q
(** squashed disjunction, specialized to [Type0], written with an
infix binary [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_or (p: logical) (q: logical) : logical = squash (sum p q)
(** squashed (non-dependent) implication, specialized to [Type0],
written with an infix binary [==>]. Note, [==>] binds weaker than
[/\] and [\/] *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_imp (p: logical) (q: logical) : logical = squash (p -> GTot q)
(* ^^^ NB: The GTot effect is primitive; *)
(* elaborated using GHOST a few lines below *)
(** squashed double implication, infix binary [<==>] *)
[@@ smt_theory_symbol]
type l_iff (p: logical) (q: logical) : logical = (p ==> q) /\ (q ==> p)
(** squashed negation, prefix unary [~] *)
[@@ smt_theory_symbol]
type l_not (p: logical) : logical = l_imp p False
(** l_ITE is a weak form of if-then-else at the level of
logical formulae. It's not much used.
TODO: Can we remove it *)
unfold
type l_ITE (p: logical) (q: logical) (r: logical) : logical = (p ==> q) /\ (~p ==> r)
(** One of the main axioms provided by prims is [precedes], a
built-in well-founded partial order over all terms. It's typically
written with an infix binary [<<].
The [<<] order includes:
* The [<] ordering on natural numbers
* The subterm ordering on inductive types
* [f x << D f] for data constructors D of an inductive t whose
arguments include a ghost or total function returning a t *)
assume
type precedes : #a: Type -> #b: Type -> a -> b -> Type0
(** The type of primitive strings of characters; See FStar.String *)
assume new
type string : eqtype
(** This attribute can be added to the declaration or definition of
any top-level symbol. It causes F* to report a warning on any
use of that symbol, printing the [msg] argument.
This is used, for instance to:
- tag every escape hatch, e.g., [assume], [admit], etc
Reports for uses of symbols tagged with this attribute
are controlled using the `--report_assumes` option
and warning number 334.
See tests/micro-benchmarks/WarnOnUse.fst
*)
assume
val warn_on_use (msg: string) : Tot unit
(** The [deprecated "s"] attribute: "s" is an alternative function
that should be printed in the warning it can be omitted if the use
case has no such function *)
assume
val deprecated (s: string) : Tot unit
(** Within the SMT encoding, we have a relation [(HasType e t)]
asserting that (the encoding of) [e] has a type corresponding to
(the encoding of) [t].
It is sometimes convenient, e.g., when writing triggers for
quantifiers, to have access to this relation at the source
level. The [has_type] predicate below reflects the SMT encodings
[HasType] relation. We also use it to define the type [prop] or
proof irrelevant propositions, below.
Note, unless you have a really good reason, you probably don't
want to use this [has_type] predicate. F*'s type theory certainly
does not internalize its own typing judgment *)
[@@deprecated "'has_type' is intended for internal use and debugging purposes only; \
do not rely on it for your proofs"]
assume
type has_type : #a: Type -> a -> Type -> Type0
(** Squashed universal quantification, or dependent products, written
[forall (x:a). p x], specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Forall (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a -> GTot (p x))
#push-options "--warn_error -288"
(** [p1 `subtype_of` p2] when every element of [p1] is also an element
of [p2]. *)
let subtype_of (p1 p2: Type) = forall (x: p1). has_type x p2
#pop-options
(** The type of squashed types.
Note, the [prop] type is a work in progress in F*. In particular,
we would like in the future to more systematically use [prop] for
proof-irrelevant propositions throughout the libraries. However,
we still use [Type0] in many places.
See https://github.com/FStarLang/FStar/issues/1048 for more
details and the current status of the work.
*)
type prop = a: Type0{a `subtype_of` unit}
(**** The PURE effect *)
(** The type of pure preconditions *)
let pure_pre = Type0
(** Pure postconditions, predicates on [a], on which the precondition
[pre] is also valid. This provides a way for postcondition formula
to be typed in a context where they can assume the validity of the
precondition. This is discussed extensively in Issue #57 *)
let pure_post' (a pre: Type) = _: a{pre} -> GTot Type0
let pure_post (a: Type) = pure_post' a True
(** A pure weakest precondition transforms postconditions on [a]-typed
results to pure preconditions
We require the weakest preconditions to satisfy the monotonicity
property over the postconditions
To enforce it, we first define a vanilla wp type,
and then refine it with the monotonicity condition *)
let pure_wp' (a: Type) = pure_post a -> GTot pure_pre
(** The monotonicity predicate is marked opaque_to_smt,
meaning that its definition is hidden from the SMT solver,
and if required, will need to be explicitly revealed
This has the advantage that clients that do not need to work with it
directly, don't have the (quantified) definition in their solver context *)
let pure_wp_monotonic0 (a:Type) (wp:pure_wp' a) =
forall (p q:pure_post a). (forall (x:a). p x ==> q x) ==> (wp p ==> wp q)
[@@ "opaque_to_smt"]
let pure_wp_monotonic = pure_wp_monotonic0
let pure_wp (a: Type) = wp:pure_wp' a{pure_wp_monotonic a wp}
(** This predicate is an internal detail, used to optimize the
encoding of some quantifiers to SMT by omitting their typing
guards. This is safe to use only when the quantifier serves to
introduce a local macro---use with caution. *)
assume
type guard_free : Type0 -> Type0
(** The return combinator for the PURE effect requires
proving the postcondition only on [x]
Clients should not use it directly,
instead use FStar.Pervasives.pure_return *)
unfold
let pure_return0 (a: Type) (x: a) : pure_wp a =
fun (p: pure_post a) ->
forall (return_val: a). return_val == x ==> p return_val
(** Sequential composition for the PURE effect
Clients should not use it directly,
instead use FStar.Pervasives.pure_bind_wp *)
unfold
let pure_bind_wp0
(a b: Type)
(wp1: pure_wp a)
(wp2: (a -> GTot (pure_wp b)))
: pure_wp b
= fun (p: pure_post b) ->
wp1 (fun (bind_result_1: a) -> wp2 bind_result_1 p)
(** Conditional composition for the PURE effect
The combinator is optimized to make use of how the typechecker generates VC
for conditionals.
The more intuitive form of the combinator would have been:
[(p ==> wp_then post) /\ (~p ==> wp_else post)]
However, the way the typechecker constructs the VC, [wp_then] is already
weakened with [p].
Hence, here we only weaken [wp_else]
Clients should not use it directly,
instead use FStar.Pervasives.pure_if_then_else *)
unfold
let pure_if_then_else0 (a p: Type) (wp_then wp_else: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
wp_then post /\ (~p ==> wp_else post)
(** Conditional composition for the PURE effect, while trying to avoid
duplicating the postcondition by giving it a local name [k].
Note the use of [guard_free] here: [k] is just meant to be a macro
for [post].
Clients should not use it directly,
instead use FStar.Pervasives.pure_ite_wp *)
unfold
let pure_ite_wp0 (a: Type) (wp: pure_wp a) : pure_wp a =
fun (post: pure_post a) ->
forall (k: pure_post a). (forall (x: a). {:pattern (guard_free (k x))} post x ==> k x) ==> wp k
(** Subsumption for the PURE effect *)
unfold
let pure_stronger (a: Type) (wp1 wp2: pure_wp a) = forall (p: pure_post a). wp1 p ==> wp2 p
(** Closing a PURE WP under a binder for [b]
Clients should not use it directly,
instead use FStar.Pervasives.pure_close_wp *)
unfold
let pure_close_wp0 (a b: Type) (wp: (b -> GTot (pure_wp a))) : pure_wp a = fun (p: pure_post a) -> forall (b: b). wp b p
(** Trivial WP for PURE: Prove the WP with the trivial postcondition *)
unfold
let pure_trivial (a: Type) (wp: pure_wp a) = wp (fun (trivial_result: a) -> True)
(** Introduces the PURE effect.
The definition of the PURE effect is fixed.
NO USER SHOULD EVER CHANGE THIS. *)
total
new_effect {
PURE : a: Type -> wp: pure_wp a -> Effect
with
return_wp = pure_return0
; bind_wp = pure_bind_wp0
; if_then_else = pure_if_then_else0
; ite_wp = pure_ite_wp0
; stronger = pure_stronger
; close_wp = pure_close_wp0
; trivial = pure_trivial
}
(** [Pure] is a Hoare-style counterpart of [PURE]
Note the type of post, which allows to assume the precondition
for the well-formedness of the postcondition. c.f. #57 *)
effect Pure (a: Type) (pre: pure_pre) (post: pure_post' a pre) =
PURE a
(fun (p: pure_post a) -> pre /\ (forall (pure_result: a). post pure_result ==> p pure_result))
(** [Admit] is an effect abbreviation for a computation that
disregards the verification condition of its continuation *)
effect Admit (a: Type) = PURE a (fun (p: pure_post a) -> True)
(** The primitive effect [Tot] is definitionally equal to an instance of [PURE] *)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_null_wp *)
unfold
let pure_null_wp0 (a: Type) : pure_wp a = fun (p: pure_post a) -> forall (any_result: a). p any_result
(** [Tot]: From here on, we have [Tot] as a defined symbol in F*. *)
effect Tot (a: Type) = PURE a (pure_null_wp0 a)
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assert_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assert_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p /\ post ()
(** Clients should not use it directly, instead use FStar.Pervasives.pure_assume_wp *)
[@@ "opaque_to_smt"]
unfold
let pure_assume_wp0 (p: Type) : pure_wp unit = fun (post: pure_post unit) -> p ==> post ()
(**** The [GHOST] effect *)
(** [GHOST] is logically equivalent to [PURE], but distinguished from
it nominally so that specific, computationally irrelevant
operations, are provided only in [GHOST] and are erased during
extraction *)
total
new_effect GHOST = PURE
unfold
let purewp_id (a: Type) (wp: pure_wp a) = wp
(** [PURE] computations can be lifted to the [GHOST] effect (but not
vice versa) using just the identity lifting on pure wps *)
sub_effect PURE ~> GHOST { lift_wp = purewp_id }
(** [Ghost] is a the Hoare-style counterpart of [GHOST] *)
effect Ghost (a: Type) (pre: Type) (post: pure_post' a pre) =
GHOST a
(fun (p: pure_post a) -> pre /\ (forall (ghost_result: a). post ghost_result ==> p ghost_result)
)
(** As with [Tot], the primitive effect [GTot] is definitionally equal
to an instance of GHOST *)
effect GTot (a: Type) = GHOST a (pure_null_wp0 a)
(***** End trusted primitives *****)
(** This point onward, F* fully verifies all the definitions *)
(** [===] heterogeneous equality *)
let ( === ) (#a #b: Type) (x: a) (y: b) : logical = a == b /\ x == y
(** Dependent pairs [dtuple2] in concrete syntax is [x:a & b x].
Its values can be constructed with the concrete syntax [(| x, y |)] *)
unopteq
type dtuple2 (a: Type) (b: (a -> GTot Type)) =
| Mkdtuple2 : _1: a -> _2: b _1 -> dtuple2 a b
(** Squashed existential quantification, or dependent sums,
are written [exists (x:a). p x] : specialized to Type0 *)
[@@ "tac_opaque"; smt_theory_symbol]
type l_Exists (#a: Type) (p: (a -> GTot Type0)) : logical = squash (x: a & p x)
(** Primitive type of mathematical integers, mapped to zarith in OCaml
extraction and to the SMT sort of integers *)
assume new
type int : eqtype
(**** Basic operators on booleans and integers *)
(** [&&] boolean conjunction *)
[@@ smt_theory_symbol]
assume
val op_AmpAmp: bool -> bool -> Tot bool
(** [||] boolean disjunction *)
[@@ smt_theory_symbol]
assume
val op_BarBar: bool -> bool -> Tot bool
(** [not] boolean negation *)
[@@ smt_theory_symbol]
assume
val op_Negation: bool -> Tot bool
(** Integer multiplication, no special symbol. See FStar.Mul *)
[@@ smt_theory_symbol]
assume
val op_Multiply: int -> int -> Tot int
(** [-] integer subtraction *)
[@@ smt_theory_symbol]
assume
val op_Subtraction: int -> int -> Tot int
(** [+] integer addition *)
[@@ smt_theory_symbol]
assume
val op_Addition: int -> int -> Tot int
(** [-] prefix unary integer negation *)
[@@ smt_theory_symbol]
assume
val op_Minus: int -> Tot int
(** [<=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThanOrEqual: int -> int -> Tot bool
(** [>] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThan: int -> int -> Tot bool
(** [>=] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_GreaterThanOrEqual: int -> int -> Tot bool
(** [<] integer comparison *)
[@@ smt_theory_symbol]
assume
val op_LessThan: int -> int -> Tot bool
(** [=] decidable equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_Equality: #a: eqtype -> a -> a -> Tot bool
(** [<>] decidable dis-equality on [eqtype] *)
[@@ smt_theory_symbol]
assume
val op_disEquality: #a: eqtype -> a -> a -> Tot bool
(** The extensible open inductive type of exceptions *)
assume new
type exn : Type0
(** [array]: TODO: should be removed.
See FStar.Seq, LowStar.Buffer, etc. *)
assume new
type array : Type -> Type0
(** String concatenation and its abbreviation as [^]. TODO, both
should be removed in favor of what is present in FStar.String *)
assume
val strcat: string -> string -> Tot string
inline_for_extraction unfold
let op_Hat s1 s2 = strcat s1 s2
(** The inductive type of polymorphic lists *)
type list (a: Type) =
| Nil : list a
| Cons : hd: a -> tl: list a -> list a
(** The [M] marker is interpreted by the Dijkstra Monads for Free
construction. It has a "double meaning", either as an alias for
reasoning about the direct definitions, or as a marker for places
where a CPS transformation should happen. *)
effect M (a: Type) = Tot a (attributes cps)
(** Returning a value into the [M] effect *)
let returnM (a: Type) (x: a) : M a = x
(** [as_requires] turns a WP into a precondition, by applying it to
a trivial postcondition *)
unfold
let as_requires (#a: Type) (wp: pure_wp a) : pure_pre = wp (fun x -> True)
(** [as_ensures] turns a WP into a postcondition, relying on a kind of
double negation translation. *)
unfold
let as_ensures (#a: Type) (wp: pure_wp a) : pure_post a = fun (x:a) -> ~(wp (fun y -> (y =!= x)))
(** The keyword term-level keyword [assume] is desugared to [_assume].
It explicitly provides an escape hatch to assume a given property
[p]. *)
[@@ warn_on_use "Uses an axiom"]
assume
val _assume (p: Type) : Pure unit (requires (True)) (ensures (fun x -> p))
(** [admit] is another escape hatch: It discards the continuation and
returns a value of any type *)
[@@ warn_on_use "Uses an axiom"]
assume
val admit: #a: Type -> unit -> Admit a
(** [magic] is another escape hatch: It retains the continuation but
returns a value of any type *)
[@@ warn_on_use "Uses an axiom"]
assume
val magic: #a: Type -> unit -> Tot a
(** [unsafe_coerce] is another escape hatch: It coerces an [a] to a
[b]. *)
[@@ warn_on_use "Uses an axiom"]
irreducible
let unsafe_coerce (#a #b: Type) (x: a) : b =
admit ();
x
(** [admitP]: TODO: Unused ... remove? *)
[@@ warn_on_use "Uses an axiom"]
assume
val admitP (p: Type) : Pure unit True (fun x -> p)
(** The keyword term-level keyword [assert] is desugared to [_assert].
It force a proof of a property [p], then assuming [p] for the
continuation. *)
val _assert (p: Type) : Pure unit (requires p) (ensures (fun x -> p))
let _assert p = ()
(** Logically equivalent to assert; TODO remove? *)
val cut (p: Type) : Pure unit (requires p) (fun x -> p)
let cut p = ()
(** The type of non-negative integers *)
type nat = i: int{i >= 0}
(** The type of positive integers *)
type pos = i: int{i > 0}
(** The type of non-zero integers *)
type nonzero = i: int{i <> 0}
/// Arbitrary precision ints are compiled to zarith (big_ints) in
/// OCaml and to .NET BigInteger in F#. Both the modulus and division
/// operations are Euclidean and are mapped to the corresponding
/// theory symbols in the SMT encoding
(** Euclidean modulus *)
[@@ smt_theory_symbol]
assume
val op_Modulus: int -> nonzero -> Tot int
(** Euclidean division, written [/] *)
[@@ smt_theory_symbol]
assume
val op_Division: int -> nonzero -> Tot int
(** [pow2 x] is [2^x]:
TODO: maybe move this to FStar.Int *) | false | true | prims.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 pow2 (x: nat) : Tot pos | [
"recursion"
] | Prims.pow2 | {
"file_name": "ulib/prims.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.nat -> Prims.pos | {
"end_col": 39,
"end_line": 690,
"start_col": 2,
"start_line": 688
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Steel.Effect.Common",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bind_req (a:Type)
(req_f: pure_pre)
(ens_f: pure_post a)
(pr:a -> prop)
(req_g: a -> pure_pre)
= req_f /\ (forall (x:a). ens_f x ==> pr x /\ req_g x) | let bind_req
(a: Type)
(req_f: pure_pre)
(ens_f: pure_post a)
(pr: (a -> prop))
(req_g: (a -> pure_pre))
= | false | null | false | req_f /\ (forall (x: a). ens_f x ==> pr x /\ req_g x) | {
"checked_file": "Steel.ST.Effect.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Effect.fsti"
} | [
"total"
] | [
"Prims.pure_pre",
"Prims.pure_post",
"Prims.prop",
"Prims.l_and",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.logical"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Effect
(** This module provides an effect ST, a specialization of
Steel.Effect.Steel removing selectors from the requires and
ensures indexes *)
open Steel.Memory
open FStar.Ghost
module Mem = Steel.Memory
module T = FStar.Tactics
include Steel.Effect.Common
#set-options "--warn_error -330" //turn off the experimental feature warning
#set-options "--ide_id_info_off"
val repr (a:Type)
(framed:bool)
(pre:pre_t)
(post:post_t a)
(req:pure_pre)
(ens:pure_post a)
: Type u#2
val return_ (a:Type)
(x:a)
(#[@@@ framing_implicit] p:a -> vprop)
: repr a true (return_pre (p x)) p True (fun v -> v == x)
unfold
let bind_req (a:Type)
(req_f: pure_pre)
(ens_f: pure_post a)
(pr:a -> prop) | false | false | Steel.ST.Effect.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bind_req : a: Type ->
req_f: Prims.pure_pre ->
ens_f: Prims.pure_post a ->
pr: (_: a -> Prims.prop) ->
req_g: (_: a -> Prims.pure_pre)
-> Prims.logical | [] | Steel.ST.Effect.bind_req | {
"file_name": "lib/steel/Steel.ST.Effect.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
a: Type ->
req_f: Prims.pure_pre ->
ens_f: Prims.pure_post a ->
pr: (_: a -> Prims.prop) ->
req_g: (_: a -> Prims.pure_pre)
-> Prims.logical | {
"end_col": 56,
"end_line": 50,
"start_col": 4,
"start_line": 50
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Steel.Effect.Common",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bind_ens (a:Type) (b:Type)
(ens_f: pure_post a)
(ens_g: a -> pure_post b)
= fun (y:b) -> exists (x:a). ens_f x /\ ens_g x y | let bind_ens (a b: Type) (ens_f: pure_post a) (ens_g: (a -> pure_post b)) = | false | null | false | fun (y: b) -> exists (x: a). ens_f x /\ ens_g x y | {
"checked_file": "Steel.ST.Effect.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Effect.fsti"
} | [
"total"
] | [
"Prims.pure_post",
"Prims.l_Exists",
"Prims.l_and",
"Prims.logical"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Effect
(** This module provides an effect ST, a specialization of
Steel.Effect.Steel removing selectors from the requires and
ensures indexes *)
open Steel.Memory
open FStar.Ghost
module Mem = Steel.Memory
module T = FStar.Tactics
include Steel.Effect.Common
#set-options "--warn_error -330" //turn off the experimental feature warning
#set-options "--ide_id_info_off"
val repr (a:Type)
(framed:bool)
(pre:pre_t)
(post:post_t a)
(req:pure_pre)
(ens:pure_post a)
: Type u#2
val return_ (a:Type)
(x:a)
(#[@@@ framing_implicit] p:a -> vprop)
: repr a true (return_pre (p x)) p True (fun v -> v == x)
unfold
let bind_req (a:Type)
(req_f: pure_pre)
(ens_f: pure_post a)
(pr:a -> prop)
(req_g: a -> pure_pre)
= req_f /\ (forall (x:a). ens_f x ==> pr x /\ req_g x)
unfold
let bind_ens (a:Type) (b:Type)
(ens_f: pure_post a) | false | false | Steel.ST.Effect.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bind_ens : a: Type -> b: Type -> ens_f: Prims.pure_post a -> ens_g: (_: a -> Prims.pure_post b) -> y: b
-> Prims.logical | [] | Steel.ST.Effect.bind_ens | {
"file_name": "lib/steel/Steel.ST.Effect.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | a: Type -> b: Type -> ens_f: Prims.pure_post a -> ens_g: (_: a -> Prims.pure_post b) -> y: b
-> Prims.logical | {
"end_col": 51,
"end_line": 57,
"start_col": 4,
"start_line": 57
} |
|
Prims.Tot | val if_then_else_req (p: Type0) (req_then req_else: pure_pre) : pure_pre | [
{
"abbrev": false,
"full_module": "Steel.Effect.Common",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let if_then_else_req (p:Type0) (req_then req_else:pure_pre)
: pure_pre
= (p ==> req_then) /\
((~ p) ==> req_else) | val if_then_else_req (p: Type0) (req_then req_else: pure_pre) : pure_pre
let if_then_else_req (p: Type0) (req_then req_else: pure_pre) : pure_pre = | false | null | false | (p ==> req_then) /\ ((~p) ==> req_else) | {
"checked_file": "Steel.ST.Effect.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Effect.fsti"
} | [
"total"
] | [
"Prims.pure_pre",
"Prims.l_and",
"Prims.l_imp",
"Prims.l_not"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Effect
(** This module provides an effect ST, a specialization of
Steel.Effect.Steel removing selectors from the requires and
ensures indexes *)
open Steel.Memory
open FStar.Ghost
module Mem = Steel.Memory
module T = FStar.Tactics
include Steel.Effect.Common
#set-options "--warn_error -330" //turn off the experimental feature warning
#set-options "--ide_id_info_off"
val repr (a:Type)
(framed:bool)
(pre:pre_t)
(post:post_t a)
(req:pure_pre)
(ens:pure_post a)
: Type u#2
val return_ (a:Type)
(x:a)
(#[@@@ framing_implicit] p:a -> vprop)
: repr a true (return_pre (p x)) p True (fun v -> v == x)
unfold
let bind_req (a:Type)
(req_f: pure_pre)
(ens_f: pure_post a)
(pr:a -> prop)
(req_g: a -> pure_pre)
= req_f /\ (forall (x:a). ens_f x ==> pr x /\ req_g x)
unfold
let bind_ens (a:Type) (b:Type)
(ens_f: pure_post a)
(ens_g: a -> pure_post b)
= fun (y:b) -> exists (x:a). ens_f x /\ ens_g x y
val bind (a:Type) (b:Type)
(#framed_f:eqtype_as_type bool)
(#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t)
(#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] req_f:pure_pre)
(#[@@@ framing_implicit] ens_f:pure_post a)
(#[@@@ framing_implicit] pre_g:a -> pre_t)
(#[@@@ framing_implicit] post_g:a -> post_t b)
(#[@@@ framing_implicit] req_g:a -> pure_pre)
(#[@@@ framing_implicit] ens_g:(a -> pure_post b))
(#[@@@ framing_implicit] frame_f:vprop)
(#[@@@ framing_implicit] frame_g:a -> vprop)
(#[@@@ framing_implicit] post:post_t b)
(#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f))
(#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g))
(#[@@@ framing_implicit] pr:a -> prop)
(#[@@@ framing_implicit] p1:squash
(can_be_split_forall_dep pr
(fun x -> post_f x `star` frame_f)
(fun x -> pre_g x `star` frame_g x)))
(#[@@@ framing_implicit] p2:squash
(can_be_split_post (fun x y -> post_g x y `star` frame_g x) post))
(f:repr a framed_f pre_f post_f req_f ens_f)
(g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x)))
: repr b
true
(pre_f `star` frame_f)
post
(bind_req a req_f ens_f pr req_g)
(bind_ens a b ens_f ens_g)
val subcomp (a:Type)
(#framed_f:eqtype_as_type bool)
(#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t)
(#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] req_f:pure_pre)
(#[@@@ framing_implicit] ens_f:pure_post a)
(#[@@@ framing_implicit] pre_g:pre_t)
(#[@@@ framing_implicit] post_g:post_t a)
(#[@@@ framing_implicit] req_g:pure_pre)
(#[@@@ framing_implicit] ens_g:pure_post a)
(#[@@@ framing_implicit] frame:vprop)
(#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame))
(#[@@@ framing_implicit] p1:squash (can_be_split pre_g (pre_f `star` frame)))
(#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame)))
(f:repr a framed_f pre_f post_f req_f ens_f)
: Pure (repr a framed_g pre_g post_g req_g ens_g)
(requires
req_g ==> (req_f /\ (forall x. ens_f x ==> ens_g x)))
(ensures fun _ -> True)
/// Logical precondition for the if_then_else combinator
unfold
let if_then_else_req (p:Type0) (req_then req_else:pure_pre) | false | true | Steel.ST.Effect.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val if_then_else_req (p: Type0) (req_then req_else: pure_pre) : pure_pre | [] | Steel.ST.Effect.if_then_else_req | {
"file_name": "lib/steel/Steel.ST.Effect.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Type0 -> req_then: Prims.pure_pre -> req_else: Prims.pure_pre -> Prims.pure_pre | {
"end_col": 25,
"end_line": 117,
"start_col": 5,
"start_line": 116
} |
Prims.Tot | val if_then_else_ens (a: Type) (p: Type0) (ens_then ens_else: pure_post a) : pure_post a | [
{
"abbrev": false,
"full_module": "Steel.Effect.Common",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let if_then_else_ens (a:Type)
(p:Type0)
(ens_then ens_else : pure_post a)
: pure_post a
= fun (x:a) ->
(p ==> ens_then x) /\
(~p ==> ens_else x) | val if_then_else_ens (a: Type) (p: Type0) (ens_then ens_else: pure_post a) : pure_post a
let if_then_else_ens (a: Type) (p: Type0) (ens_then ens_else: pure_post a) : pure_post a = | false | null | false | fun (x: a) -> (p ==> ens_then x) /\ (~p ==> ens_else x) | {
"checked_file": "Steel.ST.Effect.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Effect.fsti"
} | [
"total"
] | [
"Prims.pure_post",
"Prims.l_and",
"Prims.l_imp",
"Prims.l_not"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Effect
(** This module provides an effect ST, a specialization of
Steel.Effect.Steel removing selectors from the requires and
ensures indexes *)
open Steel.Memory
open FStar.Ghost
module Mem = Steel.Memory
module T = FStar.Tactics
include Steel.Effect.Common
#set-options "--warn_error -330" //turn off the experimental feature warning
#set-options "--ide_id_info_off"
val repr (a:Type)
(framed:bool)
(pre:pre_t)
(post:post_t a)
(req:pure_pre)
(ens:pure_post a)
: Type u#2
val return_ (a:Type)
(x:a)
(#[@@@ framing_implicit] p:a -> vprop)
: repr a true (return_pre (p x)) p True (fun v -> v == x)
unfold
let bind_req (a:Type)
(req_f: pure_pre)
(ens_f: pure_post a)
(pr:a -> prop)
(req_g: a -> pure_pre)
= req_f /\ (forall (x:a). ens_f x ==> pr x /\ req_g x)
unfold
let bind_ens (a:Type) (b:Type)
(ens_f: pure_post a)
(ens_g: a -> pure_post b)
= fun (y:b) -> exists (x:a). ens_f x /\ ens_g x y
val bind (a:Type) (b:Type)
(#framed_f:eqtype_as_type bool)
(#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t)
(#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] req_f:pure_pre)
(#[@@@ framing_implicit] ens_f:pure_post a)
(#[@@@ framing_implicit] pre_g:a -> pre_t)
(#[@@@ framing_implicit] post_g:a -> post_t b)
(#[@@@ framing_implicit] req_g:a -> pure_pre)
(#[@@@ framing_implicit] ens_g:(a -> pure_post b))
(#[@@@ framing_implicit] frame_f:vprop)
(#[@@@ framing_implicit] frame_g:a -> vprop)
(#[@@@ framing_implicit] post:post_t b)
(#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f))
(#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g))
(#[@@@ framing_implicit] pr:a -> prop)
(#[@@@ framing_implicit] p1:squash
(can_be_split_forall_dep pr
(fun x -> post_f x `star` frame_f)
(fun x -> pre_g x `star` frame_g x)))
(#[@@@ framing_implicit] p2:squash
(can_be_split_post (fun x y -> post_g x y `star` frame_g x) post))
(f:repr a framed_f pre_f post_f req_f ens_f)
(g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x)))
: repr b
true
(pre_f `star` frame_f)
post
(bind_req a req_f ens_f pr req_g)
(bind_ens a b ens_f ens_g)
val subcomp (a:Type)
(#framed_f:eqtype_as_type bool)
(#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t)
(#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] req_f:pure_pre)
(#[@@@ framing_implicit] ens_f:pure_post a)
(#[@@@ framing_implicit] pre_g:pre_t)
(#[@@@ framing_implicit] post_g:post_t a)
(#[@@@ framing_implicit] req_g:pure_pre)
(#[@@@ framing_implicit] ens_g:pure_post a)
(#[@@@ framing_implicit] frame:vprop)
(#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame))
(#[@@@ framing_implicit] p1:squash (can_be_split pre_g (pre_f `star` frame)))
(#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame)))
(f:repr a framed_f pre_f post_f req_f ens_f)
: Pure (repr a framed_g pre_g post_g req_g ens_g)
(requires
req_g ==> (req_f /\ (forall x. ens_f x ==> ens_g x)))
(ensures fun _ -> True)
/// Logical precondition for the if_then_else combinator
unfold
let if_then_else_req (p:Type0) (req_then req_else:pure_pre)
: pure_pre
= (p ==> req_then) /\
((~ p) ==> req_else)
/// Logical precondition for the if_then_else combinator
unfold
let if_then_else_ens (a:Type)
(p:Type0)
(ens_then ens_else : pure_post a) | false | false | Steel.ST.Effect.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val if_then_else_ens (a: Type) (p: Type0) (ens_then ens_else: pure_post a) : pure_post a | [] | Steel.ST.Effect.if_then_else_ens | {
"file_name": "lib/steel/Steel.ST.Effect.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | a: Type -> p: Type0 -> ens_then: Prims.pure_post a -> ens_else: Prims.pure_post a
-> Prims.pure_post a | {
"end_col": 25,
"end_line": 127,
"start_col": 4,
"start_line": 125
} |
Prims.Tot | val bind_pure_st_req (#a: Type) (wp: pure_wp a) (req: (a -> pure_pre)) : pure_pre | [
{
"abbrev": false,
"full_module": "Steel.Effect.Common",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bind_pure_st_req (#a:Type)
(wp:pure_wp a)
(req:a -> pure_pre)
: pure_pre
= wp req | val bind_pure_st_req (#a: Type) (wp: pure_wp a) (req: (a -> pure_pre)) : pure_pre
let bind_pure_st_req (#a: Type) (wp: pure_wp a) (req: (a -> pure_pre)) : pure_pre = | false | null | false | wp req | {
"checked_file": "Steel.ST.Effect.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Effect.fsti"
} | [
"total"
] | [
"Prims.pure_wp",
"Prims.pure_pre"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Effect
(** This module provides an effect ST, a specialization of
Steel.Effect.Steel removing selectors from the requires and
ensures indexes *)
open Steel.Memory
open FStar.Ghost
module Mem = Steel.Memory
module T = FStar.Tactics
include Steel.Effect.Common
#set-options "--warn_error -330" //turn off the experimental feature warning
#set-options "--ide_id_info_off"
val repr (a:Type)
(framed:bool)
(pre:pre_t)
(post:post_t a)
(req:pure_pre)
(ens:pure_post a)
: Type u#2
val return_ (a:Type)
(x:a)
(#[@@@ framing_implicit] p:a -> vprop)
: repr a true (return_pre (p x)) p True (fun v -> v == x)
unfold
let bind_req (a:Type)
(req_f: pure_pre)
(ens_f: pure_post a)
(pr:a -> prop)
(req_g: a -> pure_pre)
= req_f /\ (forall (x:a). ens_f x ==> pr x /\ req_g x)
unfold
let bind_ens (a:Type) (b:Type)
(ens_f: pure_post a)
(ens_g: a -> pure_post b)
= fun (y:b) -> exists (x:a). ens_f x /\ ens_g x y
val bind (a:Type) (b:Type)
(#framed_f:eqtype_as_type bool)
(#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t)
(#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] req_f:pure_pre)
(#[@@@ framing_implicit] ens_f:pure_post a)
(#[@@@ framing_implicit] pre_g:a -> pre_t)
(#[@@@ framing_implicit] post_g:a -> post_t b)
(#[@@@ framing_implicit] req_g:a -> pure_pre)
(#[@@@ framing_implicit] ens_g:(a -> pure_post b))
(#[@@@ framing_implicit] frame_f:vprop)
(#[@@@ framing_implicit] frame_g:a -> vprop)
(#[@@@ framing_implicit] post:post_t b)
(#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f))
(#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g))
(#[@@@ framing_implicit] pr:a -> prop)
(#[@@@ framing_implicit] p1:squash
(can_be_split_forall_dep pr
(fun x -> post_f x `star` frame_f)
(fun x -> pre_g x `star` frame_g x)))
(#[@@@ framing_implicit] p2:squash
(can_be_split_post (fun x y -> post_g x y `star` frame_g x) post))
(f:repr a framed_f pre_f post_f req_f ens_f)
(g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x)))
: repr b
true
(pre_f `star` frame_f)
post
(bind_req a req_f ens_f pr req_g)
(bind_ens a b ens_f ens_g)
val subcomp (a:Type)
(#framed_f:eqtype_as_type bool)
(#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t)
(#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] req_f:pure_pre)
(#[@@@ framing_implicit] ens_f:pure_post a)
(#[@@@ framing_implicit] pre_g:pre_t)
(#[@@@ framing_implicit] post_g:post_t a)
(#[@@@ framing_implicit] req_g:pure_pre)
(#[@@@ framing_implicit] ens_g:pure_post a)
(#[@@@ framing_implicit] frame:vprop)
(#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame))
(#[@@@ framing_implicit] p1:squash (can_be_split pre_g (pre_f `star` frame)))
(#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame)))
(f:repr a framed_f pre_f post_f req_f ens_f)
: Pure (repr a framed_g pre_g post_g req_g ens_g)
(requires
req_g ==> (req_f /\ (forall x. ens_f x ==> ens_g x)))
(ensures fun _ -> True)
/// Logical precondition for the if_then_else combinator
unfold
let if_then_else_req (p:Type0) (req_then req_else:pure_pre)
: pure_pre
= (p ==> req_then) /\
((~ p) ==> req_else)
/// Logical precondition for the if_then_else combinator
unfold
let if_then_else_ens (a:Type)
(p:Type0)
(ens_then ens_else : pure_post a)
: pure_post a
= fun (x:a) ->
(p ==> ens_then x) /\
(~p ==> ens_else x)
let if_then_else (a:Type)
(#framed_f:eqtype_as_type bool)
(#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t)
(#[@@@ framing_implicit] pre_g:pre_t)
(#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] post_g:post_t a)
(#[@@@ framing_implicit] req_then:pure_pre)
(#[@@@ framing_implicit] ens_then:pure_post a)
(#[@@@ framing_implicit] req_else:pure_pre)
(#[@@@ framing_implicit] ens_else:pure_post a)
(#[@@@ framing_implicit] frame_f : vprop)
(#[@@@ framing_implicit] frame_g : vprop)
(#[@@@ framing_implicit] me1 : squash (maybe_emp framed_f frame_f))
(#[@@@ framing_implicit] me2 : squash (maybe_emp framed_g frame_g))
(#[@@@ framing_implicit] s_pre: squash (can_be_split (pre_f `star` frame_f) (pre_g `star` frame_g)))
(#[@@@ framing_implicit] s_post: squash (equiv_forall (fun x -> post_f x `star` frame_f) (fun x -> post_g x `star` frame_g)))
(f:repr a framed_f pre_f post_f req_then ens_then)
(g:repr a framed_g pre_g post_g req_else ens_else)
(p:bool)
: Type
= repr a true
(pre_f `star` frame_f)
(fun x -> post_f x `star` frame_f)
(if_then_else_req p req_then req_else)
(if_then_else_ens a p ens_then ens_else)
/// Assembling the combinators defined above into an actual effect
///
/// If the effect appears at the top-level, make sure it is constrained as per STTop
[@@ ite_soundness_by ite_attr;
top_level_effect "Steel.ST.Effect.STTop";
primitive_extraction ]
reflectable
effect {
STBase
(a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:pure_pre) (ens:pure_post a)
with { repr = repr;
return = return_;
bind = bind;
subcomp = subcomp;
if_then_else = if_then_else }
}
effect ST (a:Type) (pre:pre_t) (post:post_t a) (req:pure_pre) (ens:pure_post a) =
STBase a false pre post req ens
effect STF (a:Type) (pre:pre_t) (post:post_t a) (req:pure_pre) (ens:pure_post a) =
STBase a true pre post req ens
//
// Trivial preconditions for top-level effect
//
effect STTop (a:Type) (framed:bool) (post:post_t a) (ens:pure_post a) =
STBase a framed emp post True ens
/// Logical precondition of a Pure and a Steel computation composition.
/// The current state (memory) must satisfy the precondition of the Steel computation,
/// and the wp of the PURE computation `as_requires wp` must also be satisfied
unfold
let bind_pure_st_req (#a:Type)
(wp:pure_wp a)
(req:a -> pure_pre) | false | false | Steel.ST.Effect.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bind_pure_st_req (#a: Type) (wp: pure_wp a) (req: (a -> pure_pre)) : pure_pre | [] | Steel.ST.Effect.bind_pure_st_req | {
"file_name": "lib/steel/Steel.ST.Effect.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | wp: Prims.pure_wp a -> req: (_: a -> Prims.pure_pre) -> Prims.pure_pre | {
"end_col": 9,
"end_line": 194,
"start_col": 3,
"start_line": 194
} |
Prims.Tot | val bind_pure_st_ens (#a #b: Type) (wp: pure_wp a) (ens: (a -> pure_post b)) : pure_post b | [
{
"abbrev": false,
"full_module": "Steel.Effect.Common",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bind_pure_st_ens (#a:Type)
(#b:Type)
(wp:pure_wp a)
(ens: a -> pure_post b)
: pure_post b
= fun (r:b) -> as_requires wp /\ (exists (x:a). as_ensures wp x /\ ens x r) | val bind_pure_st_ens (#a #b: Type) (wp: pure_wp a) (ens: (a -> pure_post b)) : pure_post b
let bind_pure_st_ens (#a #b: Type) (wp: pure_wp a) (ens: (a -> pure_post b)) : pure_post b = | false | null | false | fun (r: b) -> as_requires wp /\ (exists (x: a). as_ensures wp x /\ ens x r) | {
"checked_file": "Steel.ST.Effect.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.Effect.fsti"
} | [
"total"
] | [
"Prims.pure_wp",
"Prims.pure_post",
"Prims.l_and",
"Prims.as_requires",
"Prims.l_Exists",
"Prims.as_ensures"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.Effect
(** This module provides an effect ST, a specialization of
Steel.Effect.Steel removing selectors from the requires and
ensures indexes *)
open Steel.Memory
open FStar.Ghost
module Mem = Steel.Memory
module T = FStar.Tactics
include Steel.Effect.Common
#set-options "--warn_error -330" //turn off the experimental feature warning
#set-options "--ide_id_info_off"
val repr (a:Type)
(framed:bool)
(pre:pre_t)
(post:post_t a)
(req:pure_pre)
(ens:pure_post a)
: Type u#2
val return_ (a:Type)
(x:a)
(#[@@@ framing_implicit] p:a -> vprop)
: repr a true (return_pre (p x)) p True (fun v -> v == x)
unfold
let bind_req (a:Type)
(req_f: pure_pre)
(ens_f: pure_post a)
(pr:a -> prop)
(req_g: a -> pure_pre)
= req_f /\ (forall (x:a). ens_f x ==> pr x /\ req_g x)
unfold
let bind_ens (a:Type) (b:Type)
(ens_f: pure_post a)
(ens_g: a -> pure_post b)
= fun (y:b) -> exists (x:a). ens_f x /\ ens_g x y
val bind (a:Type) (b:Type)
(#framed_f:eqtype_as_type bool)
(#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t)
(#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] req_f:pure_pre)
(#[@@@ framing_implicit] ens_f:pure_post a)
(#[@@@ framing_implicit] pre_g:a -> pre_t)
(#[@@@ framing_implicit] post_g:a -> post_t b)
(#[@@@ framing_implicit] req_g:a -> pure_pre)
(#[@@@ framing_implicit] ens_g:(a -> pure_post b))
(#[@@@ framing_implicit] frame_f:vprop)
(#[@@@ framing_implicit] frame_g:a -> vprop)
(#[@@@ framing_implicit] post:post_t b)
(#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f))
(#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g))
(#[@@@ framing_implicit] pr:a -> prop)
(#[@@@ framing_implicit] p1:squash
(can_be_split_forall_dep pr
(fun x -> post_f x `star` frame_f)
(fun x -> pre_g x `star` frame_g x)))
(#[@@@ framing_implicit] p2:squash
(can_be_split_post (fun x y -> post_g x y `star` frame_g x) post))
(f:repr a framed_f pre_f post_f req_f ens_f)
(g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x)))
: repr b
true
(pre_f `star` frame_f)
post
(bind_req a req_f ens_f pr req_g)
(bind_ens a b ens_f ens_g)
val subcomp (a:Type)
(#framed_f:eqtype_as_type bool)
(#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t)
(#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] req_f:pure_pre)
(#[@@@ framing_implicit] ens_f:pure_post a)
(#[@@@ framing_implicit] pre_g:pre_t)
(#[@@@ framing_implicit] post_g:post_t a)
(#[@@@ framing_implicit] req_g:pure_pre)
(#[@@@ framing_implicit] ens_g:pure_post a)
(#[@@@ framing_implicit] frame:vprop)
(#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame))
(#[@@@ framing_implicit] p1:squash (can_be_split pre_g (pre_f `star` frame)))
(#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame)))
(f:repr a framed_f pre_f post_f req_f ens_f)
: Pure (repr a framed_g pre_g post_g req_g ens_g)
(requires
req_g ==> (req_f /\ (forall x. ens_f x ==> ens_g x)))
(ensures fun _ -> True)
/// Logical precondition for the if_then_else combinator
unfold
let if_then_else_req (p:Type0) (req_then req_else:pure_pre)
: pure_pre
= (p ==> req_then) /\
((~ p) ==> req_else)
/// Logical precondition for the if_then_else combinator
unfold
let if_then_else_ens (a:Type)
(p:Type0)
(ens_then ens_else : pure_post a)
: pure_post a
= fun (x:a) ->
(p ==> ens_then x) /\
(~p ==> ens_else x)
let if_then_else (a:Type)
(#framed_f:eqtype_as_type bool)
(#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t)
(#[@@@ framing_implicit] pre_g:pre_t)
(#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] post_g:post_t a)
(#[@@@ framing_implicit] req_then:pure_pre)
(#[@@@ framing_implicit] ens_then:pure_post a)
(#[@@@ framing_implicit] req_else:pure_pre)
(#[@@@ framing_implicit] ens_else:pure_post a)
(#[@@@ framing_implicit] frame_f : vprop)
(#[@@@ framing_implicit] frame_g : vprop)
(#[@@@ framing_implicit] me1 : squash (maybe_emp framed_f frame_f))
(#[@@@ framing_implicit] me2 : squash (maybe_emp framed_g frame_g))
(#[@@@ framing_implicit] s_pre: squash (can_be_split (pre_f `star` frame_f) (pre_g `star` frame_g)))
(#[@@@ framing_implicit] s_post: squash (equiv_forall (fun x -> post_f x `star` frame_f) (fun x -> post_g x `star` frame_g)))
(f:repr a framed_f pre_f post_f req_then ens_then)
(g:repr a framed_g pre_g post_g req_else ens_else)
(p:bool)
: Type
= repr a true
(pre_f `star` frame_f)
(fun x -> post_f x `star` frame_f)
(if_then_else_req p req_then req_else)
(if_then_else_ens a p ens_then ens_else)
/// Assembling the combinators defined above into an actual effect
///
/// If the effect appears at the top-level, make sure it is constrained as per STTop
[@@ ite_soundness_by ite_attr;
top_level_effect "Steel.ST.Effect.STTop";
primitive_extraction ]
reflectable
effect {
STBase
(a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:pure_pre) (ens:pure_post a)
with { repr = repr;
return = return_;
bind = bind;
subcomp = subcomp;
if_then_else = if_then_else }
}
effect ST (a:Type) (pre:pre_t) (post:post_t a) (req:pure_pre) (ens:pure_post a) =
STBase a false pre post req ens
effect STF (a:Type) (pre:pre_t) (post:post_t a) (req:pure_pre) (ens:pure_post a) =
STBase a true pre post req ens
//
// Trivial preconditions for top-level effect
//
effect STTop (a:Type) (framed:bool) (post:post_t a) (ens:pure_post a) =
STBase a framed emp post True ens
/// Logical precondition of a Pure and a Steel computation composition.
/// The current state (memory) must satisfy the precondition of the Steel computation,
/// and the wp of the PURE computation `as_requires wp` must also be satisfied
unfold
let bind_pure_st_req (#a:Type)
(wp:pure_wp a)
(req:a -> pure_pre)
: pure_pre
= wp req
/// Logical postcondition of a Pure and a Steel composition.
/// There exists an intermediate value (the output of the Pure computation) such that
/// the postcondition of the pure computation is satisfied.
unfold
let bind_pure_st_ens (#a:Type)
(#b:Type)
(wp:pure_wp a)
(ens: a -> pure_post b) | false | false | Steel.ST.Effect.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bind_pure_st_ens (#a #b: Type) (wp: pure_wp a) (ens: (a -> pure_post b)) : pure_post b | [] | Steel.ST.Effect.bind_pure_st_ens | {
"file_name": "lib/steel/Steel.ST.Effect.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | wp: Prims.pure_wp a -> ens: (_: a -> Prims.pure_post b) -> Prims.pure_post b | {
"end_col": 79,
"end_line": 205,
"start_col": 6,
"start_line": 205
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "C",
"short_module": null
},
{
"abbrev": false,
"full_module": "C",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let zero_free (s: Seq.seq C.char) =
forall (i: nat). {:pattern (Seq.index s i)}
i < Seq.length s - 1 ==> Seq.index s i <> C.char_of_uint8 0uy | let zero_free (s: Seq.seq C.char) = | false | null | false | forall (i: nat). {:pattern (Seq.index s i)}
i < Seq.length s - 1 ==> Seq.index s i <> C.char_of_uint8 0uy | {
"checked_file": "C.String.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.String.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.fst.checked"
],
"interface_file": false,
"source_file": "C.String.fsti"
} | [
"total"
] | [
"FStar.Seq.Base.seq",
"C.char",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"FStar.Seq.Base.length",
"Prims.op_disEquality",
"FStar.Seq.Base.index",
"C.char_of_uint8",
"FStar.UInt8.__uint_to_t",
"Prims.logical"
] | [] | module C.String
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module B = LowStar.Buffer
module M = LowStar.Modifies
open FStar.HyperStack.ST | false | true | C.String.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val zero_free : s: FStar.Seq.Base.seq C.char -> Prims.logical | [] | C.String.zero_free | {
"file_name": "krmllib/C.String.fsti",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | s: FStar.Seq.Base.seq C.char -> Prims.logical | {
"end_col": 65,
"end_line": 13,
"start_col": 2,
"start_line": 12
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "C",
"short_module": null
},
{
"abbrev": false,
"full_module": "C",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let well_formed (s:Seq.seq C.char) =
let l = Seq.length s in
l <= FStar.UInt.max_int 32 /\
l >= 1 /\
Seq.index s (l - 1) = C.char_of_uint8 0uy /\
zero_free s | let well_formed (s: Seq.seq C.char) = | false | null | false | let l = Seq.length s in
l <= FStar.UInt.max_int 32 /\ l >= 1 /\ Seq.index s (l - 1) = C.char_of_uint8 0uy /\ zero_free s | {
"checked_file": "C.String.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.String.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.fst.checked"
],
"interface_file": false,
"source_file": "C.String.fsti"
} | [
"total"
] | [
"FStar.Seq.Base.seq",
"C.char",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt.max_int",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Equality",
"FStar.Seq.Base.index",
"Prims.op_Subtraction",
"C.char_of_uint8",
"FStar.UInt8.__uint_to_t",
"C.String.zero_free",
"Prims.nat",
"FStar.Seq.Base.length",
"Prims.logical"
] | [] | module C.String
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module B = LowStar.Buffer
module M = LowStar.Modifies
open FStar.HyperStack.ST
let zero_free (s: Seq.seq C.char) =
forall (i: nat). {:pattern (Seq.index s i)}
i < Seq.length s - 1 ==> Seq.index s i <> C.char_of_uint8 0uy | false | true | C.String.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val well_formed : s: FStar.Seq.Base.seq C.char -> Prims.logical | [] | C.String.well_formed | {
"file_name": "krmllib/C.String.fsti",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | s: FStar.Seq.Base.seq C.char -> Prims.logical | {
"end_col": 13,
"end_line": 20,
"start_col": 36,
"start_line": 15
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op64 = IOpEx IOp64 | let op64 = | false | null | false | IOpEx IOp64 | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Vale.X64.Instruction_s.IOpEx",
"Vale.X64.Instruction_s.IOp64"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o) | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op64 : Vale.X64.Instruction_s.instr_operand | [] | Vale.X64.Instruction_s.op64 | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.X64.Instruction_s.instr_operand | {
"end_col": 43,
"end_line": 42,
"start_col": 32,
"start_line": 42
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let opXmm = IOpEx IOpXmm | let opXmm = | false | null | false | IOpEx IOpXmm | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Vale.X64.Instruction_s.IOpEx",
"Vale.X64.Instruction_s.IOpXmm"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o) | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val opXmm : Vale.X64.Instruction_s.instr_operand | [] | Vale.X64.Instruction_s.opXmm | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.X64.Instruction_s.instr_operand | {
"end_col": 45,
"end_line": 43,
"start_col": 33,
"start_line": 43
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let opFlagsCf = IOpIm IOpFlagsCf | let opFlagsCf = | false | null | false | IOpIm IOpFlagsCf | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Vale.X64.Instruction_s.IOpIm",
"Vale.X64.Instruction_s.IOpFlagsCf"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o)
[@instr_attr] unfold let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r)) | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val opFlagsCf : Vale.X64.Instruction_s.instr_operand | [] | Vale.X64.Instruction_s.opFlagsCf | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.X64.Instruction_s.instr_operand | {
"end_col": 53,
"end_line": 47,
"start_col": 37,
"start_line": 47
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let opFlagsOf = IOpIm IOpFlagsOf | let opFlagsOf = | false | null | false | IOpIm IOpFlagsOf | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Vale.X64.Instruction_s.IOpIm",
"Vale.X64.Instruction_s.IOpFlagsOf"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o)
[@instr_attr] unfold let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r))
[@instr_attr] unfold let oneXmm (o:operand128) = IOpIm (IOpXmmOne o) | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val opFlagsOf : Vale.X64.Instruction_s.instr_operand | [] | Vale.X64.Instruction_s.opFlagsOf | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.X64.Instruction_s.instr_operand | {
"end_col": 53,
"end_line": 48,
"start_col": 37,
"start_line": 48
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let oneXmm (o:operand128) = IOpIm (IOpXmmOne o) | let oneXmm (o: operand128) = | false | null | false | IOpIm (IOpXmmOne o) | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Vale.X64.Machine_s.operand128",
"Vale.X64.Instruction_s.IOpIm",
"Vale.X64.Instruction_s.IOpXmmOne",
"Vale.X64.Instruction_s.instr_operand"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o) | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val oneXmm : o: Vale.X64.Machine_s.operand128 -> Vale.X64.Instruction_s.instr_operand | [] | Vale.X64.Instruction_s.oneXmm | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | o: Vale.X64.Machine_s.operand128 -> Vale.X64.Instruction_s.instr_operand | {
"end_col": 68,
"end_line": 46,
"start_col": 49,
"start_line": 46
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let out (o:instr_operand) = (Out, o) | let out (o: instr_operand) = | false | null | false | (Out, o) | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Vale.X64.Instruction_s.instr_operand",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.Instruction_s.Out",
"FStar.Pervasives.Native.tuple2"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val out : o: Vale.X64.Instruction_s.instr_operand
-> Vale.X64.Instruction_s.instr_operand_inout * Vale.X64.Instruction_s.instr_operand | [] | Vale.X64.Instruction_s.out | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | o: Vale.X64.Instruction_s.instr_operand
-> Vale.X64.Instruction_s.instr_operand_inout * Vale.X64.Instruction_s.instr_operand | {
"end_col": 57,
"end_line": 41,
"start_col": 49,
"start_line": 41
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inOut (o:instr_operand) = (InOut, o) | let inOut (o: instr_operand) = | false | null | false | (InOut, o) | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Vale.X64.Instruction_s.instr_operand",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.Instruction_s.InOut",
"FStar.Pervasives.Native.tuple2"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inOut : o: Vale.X64.Instruction_s.instr_operand
-> Vale.X64.Instruction_s.instr_operand_inout * Vale.X64.Instruction_s.instr_operand | [] | Vale.X64.Instruction_s.inOut | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | o: Vale.X64.Instruction_s.instr_operand
-> Vale.X64.Instruction_s.instr_operand_inout * Vale.X64.Instruction_s.instr_operand | {
"end_col": 61,
"end_line": 40,
"start_col": 51,
"start_line": 40
} |
|
Prims.Tot | val instr_eval_t (outs: list instr_out) (args: list instr_operand) : Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let instr_eval_t (outs:list instr_out) (args:list instr_operand) : Type0 =
instr_inouts_t outs outs args | val instr_eval_t (outs: list instr_out) (args: list instr_operand) : Type0
let instr_eval_t (outs: list instr_out) (args: list instr_operand) : Type0 = | false | null | false | instr_inouts_t outs outs args | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_inouts_t"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o)
[@instr_attr] unfold let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r))
[@instr_attr] unfold let oneXmm (o:operand128) = IOpIm (IOpXmmOne o)
[@instr_attr] unfold let opFlagsCf = IOpIm IOpFlagsCf
[@instr_attr] unfold let opFlagsOf = IOpIm IOpFlagsOf
[@instr_attr]
let instr_val_t (o:instr_operand) : Type0 =
match o with
| IOpEx IOp64 | IOpIm (IOp64One _) -> nat64
| IOpEx IOpXmm | IOpIm (IOpXmmOne _) -> quad32
| IOpIm IOpFlagsCf -> bool
| IOpIm IOpFlagsOf -> bool
[@instr_attr]
let rec instr_ret_t (outs:list instr_out) : Type0 =
match outs with
| [] -> unit
| [(_, o)] -> instr_val_t o
| (_, o)::outs -> instr_val_t o & instr_ret_t outs
[@instr_attr]
let rec instr_args_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match args with
| [] -> option (instr_ret_t outs)
| i::args -> arrow (instr_val_t i) (instr_args_t outs args)
[@instr_attr]
let rec instr_inouts_t (outs inouts:list instr_out) (args:list instr_operand) : Type0 =
match inouts with
| [] -> instr_args_t outs args
| (Out, _)::inouts -> instr_inouts_t outs inouts args
| (InOut, i)::inouts -> arrow (instr_val_t i) (instr_inouts_t outs inouts args)
(*
An instr evaluator is a function of type:
in_outs1 ... -> in_outsi -> args1 -> ...> argsj -> (outs1 & (... & outsk) ...)
where in_outs = [(b, o) in outs | b = InOut]
*)
[@instr_attr] | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val instr_eval_t (outs: list instr_out) (args: list instr_operand) : Type0 | [] | Vale.X64.Instruction_s.instr_eval_t | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand
-> Type0 | {
"end_col": 31,
"end_line": 85,
"start_col": 2,
"start_line": 85
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let arrow (a b:Type) = a -> b | let arrow (a b: Type) = | false | null | false | a -> b | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val arrow : a: Type -> b: Type -> Type | [] | Vale.X64.Instruction_s.arrow | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Type -> b: Type -> Type | {
"end_col": 29,
"end_line": 37,
"start_col": 23,
"start_line": 37
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let instr_out = instr_operand_inout & instr_operand | let instr_out = | false | null | false | instr_operand_inout & instr_operand | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.Instruction_s.instr_operand"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val instr_out : Type0 | [] | Vale.X64.Instruction_s.instr_out | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 51,
"end_line": 32,
"start_col": 16,
"start_line": 32
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let one64 (o:operand64) = IOpIm (IOp64One o) | let one64 (o: operand64) = | false | null | false | IOpIm (IOp64One o) | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Vale.X64.Machine_s.operand64",
"Vale.X64.Instruction_s.IOpIm",
"Vale.X64.Instruction_s.IOp64One",
"Vale.X64.Instruction_s.instr_operand"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64 | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val one64 : o: Vale.X64.Machine_s.operand64 -> Vale.X64.Instruction_s.instr_operand | [] | Vale.X64.Instruction_s.one64 | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | o: Vale.X64.Machine_s.operand64 -> Vale.X64.Instruction_s.instr_operand | {
"end_col": 65,
"end_line": 44,
"start_col": 47,
"start_line": 44
} |
|
Prims.Tot | val normal (#a: Type) (x: a) : a | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x | val normal (#a: Type) (x: a) : a
let normal (#a: Type) (x: a) : a = | false | null | false | norm [zeta; iota; delta_attr [`%instr_attr]] x | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand | false | false | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val normal (#a: Type) (x: a) : a | [] | Vale.X64.Instruction_s.normal | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: a -> a | {
"end_col": 86,
"end_line": 35,
"start_col": 40,
"start_line": 35
} |
Prims.Tot | val coerce (#b #a: Type) (x: a{a == b}) : b | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let coerce (#b #a:Type) (x:a{a == b}) : b = x | val coerce (#b #a: Type) (x: a{a == b}) : b
let coerce (#b #a: Type) (x: a{a == b}) : b = | false | null | false | x | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Prims.eq2"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x | false | false | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val coerce (#b #a: Type) (x: a{a == b}) : b | [] | Vale.X64.Instruction_s.coerce | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: a{a == b} -> b | {
"end_col": 66,
"end_line": 38,
"start_col": 65,
"start_line": 38
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r)) | let one64Reg (r: reg_64) = | false | null | false | IOpIm (IOp64One (OReg r)) | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Vale.X64.Machine_s.reg_64",
"Vale.X64.Instruction_s.IOpIm",
"Vale.X64.Instruction_s.IOp64One",
"Vale.X64.Machine_s.OReg",
"Vale.X64.Machine_s.nat64",
"Vale.X64.Instruction_s.instr_operand"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val one64Reg : r: Vale.X64.Machine_s.reg_64 -> Vale.X64.Instruction_s.instr_operand | [] | Vale.X64.Instruction_s.one64Reg | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | r: Vale.X64.Machine_s.reg_64 -> Vale.X64.Instruction_s.instr_operand | {
"end_col": 72,
"end_line": 45,
"start_col": 47,
"start_line": 45
} |
|
Prims.Tot | val instr_operand_t (arg: instr_operand_explicit) : Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let instr_operand_t (arg:instr_operand_explicit) : Type0 =
match arg with
| IOp64 -> operand64
| IOpXmm -> operand128 | val instr_operand_t (arg: instr_operand_explicit) : Type0
let instr_operand_t (arg: instr_operand_explicit) : Type0 = | false | null | false | match arg with
| IOp64 -> operand64
| IOpXmm -> operand128 | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Machine_s.operand64",
"Vale.X64.Machine_s.operand128"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o)
[@instr_attr] unfold let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r))
[@instr_attr] unfold let oneXmm (o:operand128) = IOpIm (IOpXmmOne o)
[@instr_attr] unfold let opFlagsCf = IOpIm IOpFlagsCf
[@instr_attr] unfold let opFlagsOf = IOpIm IOpFlagsOf
[@instr_attr]
let instr_val_t (o:instr_operand) : Type0 =
match o with
| IOpEx IOp64 | IOpIm (IOp64One _) -> nat64
| IOpEx IOpXmm | IOpIm (IOpXmmOne _) -> quad32
| IOpIm IOpFlagsCf -> bool
| IOpIm IOpFlagsOf -> bool
[@instr_attr]
let rec instr_ret_t (outs:list instr_out) : Type0 =
match outs with
| [] -> unit
| [(_, o)] -> instr_val_t o
| (_, o)::outs -> instr_val_t o & instr_ret_t outs
[@instr_attr]
let rec instr_args_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match args with
| [] -> option (instr_ret_t outs)
| i::args -> arrow (instr_val_t i) (instr_args_t outs args)
[@instr_attr]
let rec instr_inouts_t (outs inouts:list instr_out) (args:list instr_operand) : Type0 =
match inouts with
| [] -> instr_args_t outs args
| (Out, _)::inouts -> instr_inouts_t outs inouts args
| (InOut, i)::inouts -> arrow (instr_val_t i) (instr_inouts_t outs inouts args)
(*
An instr evaluator is a function of type:
in_outs1 ... -> in_outsi -> args1 -> ...> argsj -> (outs1 & (... & outsk) ...)
where in_outs = [(b, o) in outs | b = InOut]
*)
[@instr_attr]
let instr_eval_t (outs:list instr_out) (args:list instr_operand) : Type0 =
instr_inouts_t outs outs args
[@instr_attr] | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val instr_operand_t (arg: instr_operand_explicit) : Type0 | [] | Vale.X64.Instruction_s.instr_operand_t | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | arg: Vale.X64.Instruction_s.instr_operand_explicit -> Type0 | {
"end_col": 24,
"end_line": 91,
"start_col": 2,
"start_line": 89
} |
Prims.Tot | val instr_args_t (outs: list instr_out) (args: list instr_operand) : Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec instr_args_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match args with
| [] -> option (instr_ret_t outs)
| i::args -> arrow (instr_val_t i) (instr_args_t outs args) | val instr_args_t (outs: list instr_out) (args: list instr_operand) : Type0
let rec instr_args_t (outs: list instr_out) (args: list instr_operand) : Type0 = | false | null | false | match args with
| [] -> option (instr_ret_t outs)
| i :: args -> arrow (instr_val_t i) (instr_args_t outs args) | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"FStar.Pervasives.Native.option",
"Vale.X64.Instruction_s.instr_ret_t",
"Vale.X64.Instruction_s.arrow",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.X64.Instruction_s.instr_args_t"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o)
[@instr_attr] unfold let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r))
[@instr_attr] unfold let oneXmm (o:operand128) = IOpIm (IOpXmmOne o)
[@instr_attr] unfold let opFlagsCf = IOpIm IOpFlagsCf
[@instr_attr] unfold let opFlagsOf = IOpIm IOpFlagsOf
[@instr_attr]
let instr_val_t (o:instr_operand) : Type0 =
match o with
| IOpEx IOp64 | IOpIm (IOp64One _) -> nat64
| IOpEx IOpXmm | IOpIm (IOpXmmOne _) -> quad32
| IOpIm IOpFlagsCf -> bool
| IOpIm IOpFlagsOf -> bool
[@instr_attr]
let rec instr_ret_t (outs:list instr_out) : Type0 =
match outs with
| [] -> unit
| [(_, o)] -> instr_val_t o
| (_, o)::outs -> instr_val_t o & instr_ret_t outs
[@instr_attr] | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val instr_args_t (outs: list instr_out) (args: list instr_operand) : Type0 | [
"recursion"
] | Vale.X64.Instruction_s.instr_args_t | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand
-> Type0 | {
"end_col": 61,
"end_line": 69,
"start_col": 2,
"start_line": 67
} |
Prims.Tot | val instr_operands_t (outs: list instr_out) (args: list instr_operand) : Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec instr_operands_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match outs with
| [] -> instr_operands_t_args args
| (_, IOpEx i)::outs -> instr_operand_t i & instr_operands_t outs args
| (_, IOpIm _)::outs -> instr_operands_t outs args | val instr_operands_t (outs: list instr_out) (args: list instr_operand) : Type0
let rec instr_operands_t (outs: list instr_out) (args: list instr_operand) : Type0 = | false | null | false | match outs with
| [] -> instr_operands_t_args args
| (_, IOpEx i) :: outs -> instr_operand_t i & instr_operands_t outs args
| (_, IOpIm _) :: outs -> instr_operands_t outs args | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_operands_t_args",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.Instruction_s.instr_operand_explicit",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Instruction_s.instr_operand_implicit"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o)
[@instr_attr] unfold let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r))
[@instr_attr] unfold let oneXmm (o:operand128) = IOpIm (IOpXmmOne o)
[@instr_attr] unfold let opFlagsCf = IOpIm IOpFlagsCf
[@instr_attr] unfold let opFlagsOf = IOpIm IOpFlagsOf
[@instr_attr]
let instr_val_t (o:instr_operand) : Type0 =
match o with
| IOpEx IOp64 | IOpIm (IOp64One _) -> nat64
| IOpEx IOpXmm | IOpIm (IOpXmmOne _) -> quad32
| IOpIm IOpFlagsCf -> bool
| IOpIm IOpFlagsOf -> bool
[@instr_attr]
let rec instr_ret_t (outs:list instr_out) : Type0 =
match outs with
| [] -> unit
| [(_, o)] -> instr_val_t o
| (_, o)::outs -> instr_val_t o & instr_ret_t outs
[@instr_attr]
let rec instr_args_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match args with
| [] -> option (instr_ret_t outs)
| i::args -> arrow (instr_val_t i) (instr_args_t outs args)
[@instr_attr]
let rec instr_inouts_t (outs inouts:list instr_out) (args:list instr_operand) : Type0 =
match inouts with
| [] -> instr_args_t outs args
| (Out, _)::inouts -> instr_inouts_t outs inouts args
| (InOut, i)::inouts -> arrow (instr_val_t i) (instr_inouts_t outs inouts args)
(*
An instr evaluator is a function of type:
in_outs1 ... -> in_outsi -> args1 -> ...> argsj -> (outs1 & (... & outsk) ...)
where in_outs = [(b, o) in outs | b = InOut]
*)
[@instr_attr]
let instr_eval_t (outs:list instr_out) (args:list instr_operand) : Type0 =
instr_inouts_t outs outs args
[@instr_attr]
let instr_operand_t (arg:instr_operand_explicit) : Type0 =
match arg with
| IOp64 -> operand64
| IOpXmm -> operand128
[@instr_attr]
let rec instr_operands_t_args (args:list instr_operand) : Type0 =
match args with
| [] -> unit
| (IOpEx i)::args -> instr_operand_t i & instr_operands_t_args args
| (IOpIm _)::args -> instr_operands_t_args args
[@instr_attr] | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val instr_operands_t (outs: list instr_out) (args: list instr_operand) : Type0 | [
"recursion"
] | Vale.X64.Instruction_s.instr_operands_t | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand
-> Type0 | {
"end_col": 52,
"end_line": 105,
"start_col": 2,
"start_line": 102
} |
Prims.Tot | val instr_val_t (o: instr_operand) : Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let instr_val_t (o:instr_operand) : Type0 =
match o with
| IOpEx IOp64 | IOpIm (IOp64One _) -> nat64
| IOpEx IOpXmm | IOpIm (IOpXmmOne _) -> quad32
| IOpIm IOpFlagsCf -> bool
| IOpIm IOpFlagsOf -> bool | val instr_val_t (o: instr_operand) : Type0
let instr_val_t (o: instr_operand) : Type0 = | false | null | false | match o with
| IOpEx IOp64 | IOpIm (IOp64One _) -> nat64
| IOpEx IOpXmm | IOpIm (IOpXmmOne _) -> quad32
| IOpIm IOpFlagsCf -> bool
| IOpIm IOpFlagsOf -> bool | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Machine_s.nat64",
"Vale.X64.Machine_s.operand64",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Machine_s.operand128",
"Prims.bool"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o)
[@instr_attr] unfold let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r))
[@instr_attr] unfold let oneXmm (o:operand128) = IOpIm (IOpXmmOne o)
[@instr_attr] unfold let opFlagsCf = IOpIm IOpFlagsCf
[@instr_attr] unfold let opFlagsOf = IOpIm IOpFlagsOf
[@instr_attr] | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val instr_val_t (o: instr_operand) : Type0 | [] | Vale.X64.Instruction_s.instr_val_t | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | o: Vale.X64.Instruction_s.instr_operand -> Type0 | {
"end_col": 28,
"end_line": 56,
"start_col": 2,
"start_line": 52
} |
Prims.Tot | val instr_ret_t (outs: list instr_out) : Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec instr_ret_t (outs:list instr_out) : Type0 =
match outs with
| [] -> unit
| [(_, o)] -> instr_val_t o
| (_, o)::outs -> instr_val_t o & instr_ret_t outs | val instr_ret_t (outs: list instr_out) : Type0
let rec instr_ret_t (outs: list instr_out) : Type0 = | false | null | false | match outs with
| [] -> unit
| [_, o] -> instr_val_t o
| (_, o) :: outs -> instr_val_t o & instr_ret_t outs | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Prims.unit",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_val_t",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.instr_ret_t"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o)
[@instr_attr] unfold let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r))
[@instr_attr] unfold let oneXmm (o:operand128) = IOpIm (IOpXmmOne o)
[@instr_attr] unfold let opFlagsCf = IOpIm IOpFlagsCf
[@instr_attr] unfold let opFlagsOf = IOpIm IOpFlagsOf
[@instr_attr]
let instr_val_t (o:instr_operand) : Type0 =
match o with
| IOpEx IOp64 | IOpIm (IOp64One _) -> nat64
| IOpEx IOpXmm | IOpIm (IOpXmmOne _) -> quad32
| IOpIm IOpFlagsCf -> bool
| IOpIm IOpFlagsOf -> bool
[@instr_attr] | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val instr_ret_t (outs: list instr_out) : Type0 | [
"recursion"
] | Vale.X64.Instruction_s.instr_ret_t | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | outs: Prims.list Vale.X64.Instruction_s.instr_out -> Type0 | {
"end_col": 52,
"end_line": 63,
"start_col": 2,
"start_line": 60
} |
Prims.Tot | val instr_inouts_t (outs inouts: list instr_out) (args: list instr_operand) : Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec instr_inouts_t (outs inouts:list instr_out) (args:list instr_operand) : Type0 =
match inouts with
| [] -> instr_args_t outs args
| (Out, _)::inouts -> instr_inouts_t outs inouts args
| (InOut, i)::inouts -> arrow (instr_val_t i) (instr_inouts_t outs inouts args) | val instr_inouts_t (outs inouts: list instr_out) (args: list instr_operand) : Type0
let rec instr_inouts_t (outs inouts: list instr_out) (args: list instr_operand) : Type0 = | false | null | false | match inouts with
| [] -> instr_args_t outs args
| (Out, _) :: inouts -> instr_inouts_t outs inouts args
| (InOut, i) :: inouts -> arrow (instr_val_t i) (instr_inouts_t outs inouts args) | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_args_t",
"Vale.X64.Instruction_s.instr_inouts_t",
"Vale.X64.Instruction_s.arrow",
"Vale.X64.Instruction_s.instr_val_t"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o)
[@instr_attr] unfold let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r))
[@instr_attr] unfold let oneXmm (o:operand128) = IOpIm (IOpXmmOne o)
[@instr_attr] unfold let opFlagsCf = IOpIm IOpFlagsCf
[@instr_attr] unfold let opFlagsOf = IOpIm IOpFlagsOf
[@instr_attr]
let instr_val_t (o:instr_operand) : Type0 =
match o with
| IOpEx IOp64 | IOpIm (IOp64One _) -> nat64
| IOpEx IOpXmm | IOpIm (IOpXmmOne _) -> quad32
| IOpIm IOpFlagsCf -> bool
| IOpIm IOpFlagsOf -> bool
[@instr_attr]
let rec instr_ret_t (outs:list instr_out) : Type0 =
match outs with
| [] -> unit
| [(_, o)] -> instr_val_t o
| (_, o)::outs -> instr_val_t o & instr_ret_t outs
[@instr_attr]
let rec instr_args_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match args with
| [] -> option (instr_ret_t outs)
| i::args -> arrow (instr_val_t i) (instr_args_t outs args)
[@instr_attr] | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val instr_inouts_t (outs inouts: list instr_out) (args: list instr_operand) : Type0 | [
"recursion"
] | Vale.X64.Instruction_s.instr_inouts_t | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
inouts: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand
-> Type0 | {
"end_col": 81,
"end_line": 76,
"start_col": 2,
"start_line": 73
} |
Prims.Tot | val instr_operands_t_args (args: list instr_operand) : Type0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec instr_operands_t_args (args:list instr_operand) : Type0 =
match args with
| [] -> unit
| (IOpEx i)::args -> instr_operand_t i & instr_operands_t_args args
| (IOpIm _)::args -> instr_operands_t_args args | val instr_operands_t_args (args: list instr_operand) : Type0
let rec instr_operands_t_args (args: list instr_operand) : Type0 = | false | null | false | match args with
| [] -> unit
| IOpEx i :: args -> instr_operand_t i & instr_operands_t_args args
| IOpIm _ :: args -> instr_operands_t_args args | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_operand",
"Prims.unit",
"Vale.X64.Instruction_s.instr_operand_explicit",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.Instruction_s.instr_operands_t_args",
"Vale.X64.Instruction_s.instr_operand_implicit"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o)
[@instr_attr] unfold let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r))
[@instr_attr] unfold let oneXmm (o:operand128) = IOpIm (IOpXmmOne o)
[@instr_attr] unfold let opFlagsCf = IOpIm IOpFlagsCf
[@instr_attr] unfold let opFlagsOf = IOpIm IOpFlagsOf
[@instr_attr]
let instr_val_t (o:instr_operand) : Type0 =
match o with
| IOpEx IOp64 | IOpIm (IOp64One _) -> nat64
| IOpEx IOpXmm | IOpIm (IOpXmmOne _) -> quad32
| IOpIm IOpFlagsCf -> bool
| IOpIm IOpFlagsOf -> bool
[@instr_attr]
let rec instr_ret_t (outs:list instr_out) : Type0 =
match outs with
| [] -> unit
| [(_, o)] -> instr_val_t o
| (_, o)::outs -> instr_val_t o & instr_ret_t outs
[@instr_attr]
let rec instr_args_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match args with
| [] -> option (instr_ret_t outs)
| i::args -> arrow (instr_val_t i) (instr_args_t outs args)
[@instr_attr]
let rec instr_inouts_t (outs inouts:list instr_out) (args:list instr_operand) : Type0 =
match inouts with
| [] -> instr_args_t outs args
| (Out, _)::inouts -> instr_inouts_t outs inouts args
| (InOut, i)::inouts -> arrow (instr_val_t i) (instr_inouts_t outs inouts args)
(*
An instr evaluator is a function of type:
in_outs1 ... -> in_outsi -> args1 -> ...> argsj -> (outs1 & (... & outsk) ...)
where in_outs = [(b, o) in outs | b = InOut]
*)
[@instr_attr]
let instr_eval_t (outs:list instr_out) (args:list instr_operand) : Type0 =
instr_inouts_t outs outs args
[@instr_attr]
let instr_operand_t (arg:instr_operand_explicit) : Type0 =
match arg with
| IOp64 -> operand64
| IOpXmm -> operand128
[@instr_attr] | false | true | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val instr_operands_t_args (args: list instr_operand) : Type0 | [
"recursion"
] | Vale.X64.Instruction_s.instr_operands_t_args | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | args: Prims.list Vale.X64.Instruction_s.instr_operand -> Type0 | {
"end_col": 49,
"end_line": 98,
"start_col": 2,
"start_line": 95
} |
Prims.Tot | val instr_dep
(outs: list instr_out)
(args: list instr_operand)
(havoc_flags: flag_havoc)
(f: normal (instr_eval_t outs args))
: Type0 | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let instr_dep
(outs:list instr_out) (args:list instr_operand) (havoc_flags:flag_havoc)
(f:normal (instr_eval_t outs args))
: Type0 =
i:(instr_t outs args havoc_flags){instr_eval i == f} | val instr_dep
(outs: list instr_out)
(args: list instr_operand)
(havoc_flags: flag_havoc)
(f: normal (instr_eval_t outs args))
: Type0
let instr_dep
(outs: list instr_out)
(args: list instr_operand)
(havoc_flags: flag_havoc)
(f: normal (instr_eval_t outs args))
: Type0 = | false | null | false | i: (instr_t outs args havoc_flags){instr_eval i == f} | {
"checked_file": "Vale.X64.Instruction_s.fsti.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instruction_s.fsti"
} | [
"total"
] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.flag_havoc",
"Vale.X64.Instruction_s.normal",
"Vale.X64.Instruction_s.instr_eval_t",
"Vale.X64.Instruction_s.instr_t",
"Prims.eq2",
"Vale.X64.Instruction_s.instr_args_t",
"Vale.X64.Instruction_s.instr_inouts_t",
"Vale.X64.Instruction_s.arrow",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.X64.Instruction_s.instr_eval"
] | [] | module Vale.X64.Instruction_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
(*
An generic instruction has:
- zero or more input operands
- zero or more output operands or input/output operands
- a possible effect on the status flags
Some of the operands may be hard-coded to a particular register; other operands are flexible.
For example, the Intel 64-bit MUL instruction, which executes "(RDX:RAX) := RAX * src" has:
- one hard-coded input/output operand, the flags
- note: the instruction can havoc the flags in addition to or instead of specifying a flags operand
- one hard-coded output operand, RDX
- one hard-coded input/output operand, RAX
- one flexible input operand (src)
*)
type instr_operand_inout = | InOut | Out
type instr_operand_explicit = // flexible operand
| IOp64 : instr_operand_explicit
| IOpXmm : instr_operand_explicit
type instr_operand_implicit = // hard-coded operand
| IOp64One : o:operand64 -> instr_operand_implicit
| IOpXmmOne : o:operand128 -> instr_operand_implicit
| IOpFlagsCf : instr_operand_implicit
| IOpFlagsOf : instr_operand_implicit
type instr_operand =
| IOpEx : instr_operand_explicit -> instr_operand
| IOpIm : instr_operand_implicit -> instr_operand
let instr_out = instr_operand_inout & instr_operand
irreducible let instr_attr = ()
unfold let normal (#a:Type) (x:a) : a = norm [zeta; iota; delta_attr [`%instr_attr]] x
let arrow (a b:Type) = a -> b
[@instr_attr] unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
[@instr_attr] unfold let inOut (o:instr_operand) = (InOut, o)
[@instr_attr] unfold let out (o:instr_operand) = (Out, o)
[@instr_attr] unfold let op64 = IOpEx IOp64
[@instr_attr] unfold let opXmm = IOpEx IOpXmm
[@instr_attr] unfold let one64 (o:operand64) = IOpIm (IOp64One o)
[@instr_attr] unfold let one64Reg (r:reg_64) = IOpIm (IOp64One (OReg r))
[@instr_attr] unfold let oneXmm (o:operand128) = IOpIm (IOpXmmOne o)
[@instr_attr] unfold let opFlagsCf = IOpIm IOpFlagsCf
[@instr_attr] unfold let opFlagsOf = IOpIm IOpFlagsOf
[@instr_attr]
let instr_val_t (o:instr_operand) : Type0 =
match o with
| IOpEx IOp64 | IOpIm (IOp64One _) -> nat64
| IOpEx IOpXmm | IOpIm (IOpXmmOne _) -> quad32
| IOpIm IOpFlagsCf -> bool
| IOpIm IOpFlagsOf -> bool
[@instr_attr]
let rec instr_ret_t (outs:list instr_out) : Type0 =
match outs with
| [] -> unit
| [(_, o)] -> instr_val_t o
| (_, o)::outs -> instr_val_t o & instr_ret_t outs
[@instr_attr]
let rec instr_args_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match args with
| [] -> option (instr_ret_t outs)
| i::args -> arrow (instr_val_t i) (instr_args_t outs args)
[@instr_attr]
let rec instr_inouts_t (outs inouts:list instr_out) (args:list instr_operand) : Type0 =
match inouts with
| [] -> instr_args_t outs args
| (Out, _)::inouts -> instr_inouts_t outs inouts args
| (InOut, i)::inouts -> arrow (instr_val_t i) (instr_inouts_t outs inouts args)
(*
An instr evaluator is a function of type:
in_outs1 ... -> in_outsi -> args1 -> ...> argsj -> (outs1 & (... & outsk) ...)
where in_outs = [(b, o) in outs | b = InOut]
*)
[@instr_attr]
let instr_eval_t (outs:list instr_out) (args:list instr_operand) : Type0 =
instr_inouts_t outs outs args
[@instr_attr]
let instr_operand_t (arg:instr_operand_explicit) : Type0 =
match arg with
| IOp64 -> operand64
| IOpXmm -> operand128
[@instr_attr]
let rec instr_operands_t_args (args:list instr_operand) : Type0 =
match args with
| [] -> unit
| (IOpEx i)::args -> instr_operand_t i & instr_operands_t_args args
| (IOpIm _)::args -> instr_operands_t_args args
[@instr_attr]
let rec instr_operands_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match outs with
| [] -> instr_operands_t_args args
| (_, IOpEx i)::outs -> instr_operand_t i & instr_operands_t outs args
| (_, IOpIm _)::outs -> instr_operands_t outs args
(*
The printed syntax may be different from the underlying semantics,
so we have a separate data type to represent operand syntax.
The print operands are listed in Intel/MASM order (destination operand listed first).
*)
type instr_print_operand =
| P8 : operand64 -> instr_print_operand
| P16 : operand64 -> instr_print_operand
| P32 : operand64 -> instr_print_operand
| P64 : operand64 -> instr_print_operand
| PXmm : operand128 -> instr_print_operand
| PImm : int -> instr_print_operand
| PShift : operand64 -> instr_print_operand
type instr_print_kind =
| POpcode
| PSuffix // add suffix character to opcode for GCC/ATT syntax
| PrintPSha256rnds2
type instr_print =
| Print : string -> instr_print_kind -> list instr_print_operand -> instr_print
type flag_havoc = | HavocFlags | PreserveFlags
(*
This type is abstract so that untrusted code can't invent nonexistent instruction semantics
out of thin air. (Only trusted instruction definitions can create new values of this type.)
The arguments (outs, args, havoc_flags), together with a function instr_eval,
determine the semantics.
*)
val instr_t (outs:list instr_out) (args:list instr_operand) (havoc_flags:flag_havoc) : Type0
noeq type instr_t_record =
| InstrTypeRecord :
#outs:list instr_out ->
#args:list instr_operand ->
#havoc_flags:flag_havoc ->
i:instr_t outs args havoc_flags ->
instr_t_record
val instr_eval
(#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc)
(i:instr_t outs args havoc_flags)
// : normal (instr_eval_t outs args)
: norm [zeta; iota; delta_attr [`%instr_attr]] (instr_eval_t outs args)
val instr_printer
(#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc)
(i:instr_t outs args havoc_flags) (oprs:normal (instr_operands_t outs args))
: instr_print
let instr_dep
(outs:list instr_out) (args:list instr_operand) (havoc_flags:flag_havoc)
(f:normal (instr_eval_t outs args)) | false | false | Vale.X64.Instruction_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val instr_dep
(outs: list instr_out)
(args: list instr_operand)
(havoc_flags: flag_havoc)
(f: normal (instr_eval_t outs args))
: Type0 | [] | Vale.X64.Instruction_s.instr_dep | {
"file_name": "vale/specs/hardware/Vale.X64.Instruction_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
havoc_flags: Vale.X64.Instruction_s.flag_havoc ->
f: Vale.X64.Instruction_s.normal (Vale.X64.Instruction_s.instr_eval_t outs args)
-> Type0 | {
"end_col": 54,
"end_line": 160,
"start_col": 2,
"start_line": 160
} |
Prims.Tot | val as_vale_stack (st: BS.machine_stack) : SI.vale_stack | [
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_vale_stack (st:BS.machine_stack)
: SI.vale_stack
= IB.coerce st | val as_vale_stack (st: BS.machine_stack) : SI.vale_stack
let as_vale_stack (st: BS.machine_stack) : SI.vale_stack = | false | null | false | IB.coerce st | {
"checked_file": "Vale.X64.MemoryAdapters.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.MemoryAdapters.fsti"
} | [
"total"
] | [
"Vale.X64.Machine_Semantics_s.machine_stack",
"Vale.Interop.Base.coerce",
"Vale.X64.Stack_i.vale_stack"
] | [] | module Vale.X64.MemoryAdapters
open FStar.Mul
open Vale.Interop.Base
open Vale.Arch.HeapTypes_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Arch.MachineHeap_s
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module IB = Vale.Interop.Base
module VS = Vale.X64.State
module V = Vale.X64.Decls
module Map16 = Vale.Lib.Map16
val as_vale_buffer (#src #t:base_typ) (i:IB.buf_t src t) : GTot (ME.buffer t)
val as_vale_immbuffer (#src #t:base_typ) (i:IB.ibuf_t src t) : GTot (ME.buffer t)
val stack_eq : squash (BS.machine_stack == SI.vale_stack)
val as_mem (h:ME.vale_heap) : GTot IB.interop_heap
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
val lemma_heap_impl : squash (heap_impl == vale_full_heap)
val create_initial_vale_heap (ih:IB.interop_heap) : GTot vale_heap
val create_initial_vale_full_heap (ih:IB.interop_heap) (mt:memTaint_t) : Ghost vale_full_heap
(requires True)
(ensures fun h ->
h == coerce (heap_create_impl ih mt) /\
ME.mem_inv h /\
ME.is_initial_heap h.vf_layout h.vf_heap /\
ME.get_heaplet_id h.vf_heap == None /\
h.vf_heap == create_initial_vale_heap ih
)
unfold
let as_vale_stack (st:BS.machine_stack) | false | true | Vale.X64.MemoryAdapters.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_vale_stack (st: BS.machine_stack) : SI.vale_stack | [] | Vale.X64.MemoryAdapters.as_vale_stack | {
"file_name": "vale/code/arch/x64/interop/Vale.X64.MemoryAdapters.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | st: Vale.X64.Machine_Semantics_s.machine_stack -> Vale.X64.Stack_i.vale_stack | {
"end_col": 16,
"end_line": 44,
"start_col": 4,
"start_line": 44
} |
Prims.Tot | val coerce (#b #a: Type) (x: a{a == b}) : b | [
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "Vale.X64.Stack_i",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let coerce (#b #a:Type) (x:a{a == b}) : b = x | val coerce (#b #a: Type) (x: a{a == b}) : b
let coerce (#b #a: Type) (x: a{a == b}) : b = | false | null | false | x | {
"checked_file": "Vale.X64.MemoryAdapters.fsti.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.MemoryAdapters.fsti"
} | [
"total"
] | [
"Prims.eq2"
] | [] | module Vale.X64.MemoryAdapters
open FStar.Mul
open Vale.Interop.Base
open Vale.Arch.HeapTypes_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Arch.MachineHeap_s
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module SI = Vale.X64.Stack_i
module IB = Vale.Interop.Base
module VS = Vale.X64.State
module V = Vale.X64.Decls
module Map16 = Vale.Lib.Map16
val as_vale_buffer (#src #t:base_typ) (i:IB.buf_t src t) : GTot (ME.buffer t)
val as_vale_immbuffer (#src #t:base_typ) (i:IB.ibuf_t src t) : GTot (ME.buffer t)
val stack_eq : squash (BS.machine_stack == SI.vale_stack)
val as_mem (h:ME.vale_heap) : GTot IB.interop_heap | false | false | Vale.X64.MemoryAdapters.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val coerce (#b #a: Type) (x: a{a == b}) : b | [] | Vale.X64.MemoryAdapters.coerce | {
"file_name": "vale/code/arch/x64/interop/Vale.X64.MemoryAdapters.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: a{a == b} -> b | {
"end_col": 52,
"end_line": 25,
"start_col": 51,
"start_line": 25
} |
Prims.GTot | val length_all: #t: _ -> #input_stream_inst t -> x: t -> GTot nat | [
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "EverParse3d.ErrorCode",
"short_module": "LPE"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "EverParse3d.InputStream",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.InputStream",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let length_all #t (#_: input_stream_inst t) (x: t) : GTot nat = U64.v (len_all x) | val length_all: #t: _ -> #input_stream_inst t -> x: t -> GTot nat
let length_all #t (#_: input_stream_inst t) (x: t) : GTot nat = | false | null | false | U64.v (len_all x) | {
"checked_file": "EverParse3d.InputStream.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"EverParse3d.ErrorCode.fst.checked"
],
"interface_file": false,
"source_file": "EverParse3d.InputStream.Base.fst"
} | [
"sometrivial"
] | [
"EverParse3d.InputStream.Base.input_stream_inst",
"FStar.UInt64.v",
"EverParse3d.InputStream.Base.len_all",
"Prims.nat"
] | [] | module EverParse3d.InputStream.Base
module U8 = FStar.UInt8
module U64 = FStar.UInt64
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module B = LowStar.Buffer
module LPE = EverParse3d.ErrorCode
module LP = LowParse.Low.Base
noextract
inline_for_extraction
class input_stream_inst (t: Type) : Type = {
live: t -> HS.mem -> Tot prop;
footprint: (x: t) -> Ghost B.loc
(requires True)
(ensures (fun y -> B.address_liveness_insensitive_locs `B.loc_includes` y));
perm_footprint: (x: t) -> Ghost B.loc
(requires True)
(ensures (fun y -> footprint x `B.loc_includes` y));
live_not_unused_in:
(x: t) ->
(h: HS.mem) ->
Lemma
(requires (live x h))
(ensures (B.loc_not_unused_in h `B.loc_includes` footprint x));
len_all: (x: t) -> GTot LPE.pos_t;
get_all: (x: t) -> Ghost (Seq.seq U8.t)
(requires True)
(ensures (fun y -> Seq.length y == U64.v (len_all x)));
get_remaining: (x: t) -> (h: HS.mem) -> Ghost (Seq.seq U8.t)
(requires (live x h))
(ensures (fun y -> Seq.length y <= U64.v (len_all x)));
get_read: (x: t) -> (h: HS.mem) -> Ghost (Seq.seq U8.t)
(requires (live x h))
(ensures (fun y -> get_all x `Seq.equal` (y `Seq.append` get_remaining x h)));
preserved:
(x: t) ->
(l: B.loc) ->
(h: HS.mem) ->
(h' : HS.mem) ->
Lemma
(requires (live x h /\ B.modifies l h h' /\ B.loc_disjoint (footprint x) l))
(ensures (
live x h' /\
get_remaining x h' == get_remaining x h /\
get_read x h' == get_read x h
));
tlen: t -> Type0;
extra_t: Type0;
has:
(# [FStar.Tactics.Typeclasses.tcresolve () ] extra_t ) ->
(x: t) ->
(len: tlen x) ->
(pos: LPE.pos_t) ->
(n: U64.t) ->
HST.Stack bool
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h)
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
(res == true <==> Seq.length (get_remaining x h) >= U64.v n)
));
read:
(# [FStar.Tactics.Typeclasses.tcresolve ()] extra_t ) ->
(t': Type0) ->
(k: LP.parser_kind) ->
(p: LP.parser k t') ->
(r: LP.leaf_reader p) ->
(x: t) ->
(pos: LPE.pos_t) ->
(n: U64.t) ->
HST.Stack t'
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h) /\
k.LP.parser_kind_subkind == Some LP.ParserStrong /\
k.LP.parser_kind_high == Some k.LP.parser_kind_low /\
k.LP.parser_kind_low == U64.v n /\
U64.v n > 0 /\
U64.v n < 4294967296 /\
Some? (LP.parse p (get_remaining x h))
))
(ensures (fun h dst' h' ->
let s = get_remaining x h in
B.modifies (perm_footprint x) h h' /\
Seq.length s >= U64.v n /\
LP.parse p (Seq.slice s 0 (U64.v n)) == Some (dst', U64.v n) /\
LP.parse p s == Some (dst', U64.v n) /\
live x h' /\
get_remaining x h' `Seq.equal` Seq.slice s (U64.v n) (Seq.length s)
));
skip:
(# [FStar.Tactics.Typeclasses.tcresolve ()] extra_t ) ->
(x: t) ->
(pos: LPE.pos_t) ->
(n: U64.t) ->
HST.Stack unit
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h) /\
Seq.length (get_remaining x h) >= U64.v n
))
(ensures (fun h _ h' ->
let s = get_remaining x h in
B.modifies (perm_footprint x) h h' /\
live x h' /\
get_remaining x h' `Seq.equal` Seq.slice s (U64.v n) (Seq.length s)
));
skip_if_success:
(# [FStar.Tactics.Typeclasses.tcresolve ()] extra_t ) ->
(x: t) ->
(pos: LPE.pos_t) ->
(res: U64.t) ->
HST.Stack unit
(requires (fun h ->
live x h /\
(LPE.is_success res ==> (
U64.v pos == Seq.length (get_read x h)) /\
U64.v res >= U64.v pos /\
U64.v pos + Seq.length (get_remaining x h) >= U64.v res
)))
(ensures (fun h _ h' ->
let s = get_remaining x h in
B.modifies (perm_footprint x) h h' /\
live x h' /\
get_remaining x h' == (if LPE.is_success res then Seq.slice s (U64.v res - U64.v pos) (Seq.length s) else get_remaining x h)
));
empty:
(# [FStar.Tactics.Typeclasses.tcresolve ()] extra_t ) ->
(x: t) ->
(len: tlen x) ->
(pos: LPE.pos_t) ->
HST.Stack LPE.pos_t
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h)
))
(ensures (fun h res h' ->
B.modifies (perm_footprint x) h h' /\
live x h' /\
U64.v res == Seq.length (get_read x h') /\
get_remaining x h' `Seq.equal` Seq.empty
));
is_prefix_of:
(x: t) ->
(y: t) ->
Tot prop;
get_suffix:
(x: t) ->
(y: t) ->
Ghost (Seq.seq U8.t)
(requires (x `is_prefix_of` y))
(ensures (fun _ -> True));
is_prefix_of_prop:
(x: t) ->
(y: t) ->
(h: HS.mem) ->
Lemma
(requires (
live x h /\
x `is_prefix_of` y
))
(ensures (
live y h /\
get_read y h `Seq.equal` get_read x h /\
get_remaining y h `Seq.equal` (get_remaining x h `Seq.append` get_suffix x y)
));
truncate:
(x: t) ->
(pos: LPE.pos_t) ->
(n: U64.t) ->
HST.Stack t
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h) /\
U64.v n <= Seq.length (get_remaining x h)
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res `is_prefix_of` x /\
footprint res == footprint x /\
perm_footprint res == perm_footprint x /\
live res h' /\
Seq.length (get_remaining res h') == U64.v n
));
truncate_len:
(x: t) ->
(pos: LPE.pos_t) ->
(n: U64.t) ->
(res: t) ->
HST.Stack (tlen res)
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h) /\
U64.v n <= Seq.length (get_remaining x h) /\
res `is_prefix_of` x /\
footprint res == footprint x /\
perm_footprint res == perm_footprint x /\
live res h /\
Seq.length (get_remaining res h) == U64.v n
))
(ensures (fun h res_len h' ->
B.modifies B.loc_none h h'
));
} | false | false | EverParse3d.InputStream.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val length_all: #t: _ -> #input_stream_inst t -> x: t -> GTot nat | [] | EverParse3d.InputStream.Base.length_all | {
"file_name": "src/3d/prelude/EverParse3d.InputStream.Base.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: t -> Prims.GTot Prims.nat | {
"end_col": 81,
"end_line": 232,
"start_col": 64,
"start_line": 232
} |
FStar.Pervasives.Lemma | val preserved'
(#t: Type)
(#[FStar.Tactics.Typeclasses.tcresolve ()] inst: input_stream_inst t)
(x: t)
(l: B.loc)
(h h': HS.mem)
: Lemma (requires (live x h /\ B.modifies l h h' /\ B.loc_disjoint (footprint x) l))
(ensures
(live x h' /\ get_remaining x h' == get_remaining x h /\ get_read x h' == get_read x h))
[
SMTPatOr
[
[SMTPat (live x h); SMTPat (B.modifies l h h')];
[SMTPat (live x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h'); SMTPat (B.modifies l h h')]
]
] | [
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "EverParse3d.ErrorCode",
"short_module": "LPE"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "EverParse3d.InputStream",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.InputStream",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let preserved'
(#t: Type)
(# [FStar.Tactics.Typeclasses.tcresolve ()] inst : input_stream_inst t)
(x: t)
(l: B.loc)
(h: HS.mem)
(h' : HS.mem)
: Lemma
(requires (live x h /\ B.modifies l h h' /\ B.loc_disjoint (footprint x) l))
(ensures (
live x h' /\
get_remaining x h' == get_remaining x h /\
get_read x h' == get_read x h
))
[SMTPatOr [
[SMTPat (live x h); SMTPat (B.modifies l h h')];
[SMTPat (live x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h'); SMTPat (B.modifies l h h')];
]]
= preserved x l h h' | val preserved'
(#t: Type)
(#[FStar.Tactics.Typeclasses.tcresolve ()] inst: input_stream_inst t)
(x: t)
(l: B.loc)
(h h': HS.mem)
: Lemma (requires (live x h /\ B.modifies l h h' /\ B.loc_disjoint (footprint x) l))
(ensures
(live x h' /\ get_remaining x h' == get_remaining x h /\ get_read x h' == get_read x h))
[
SMTPatOr
[
[SMTPat (live x h); SMTPat (B.modifies l h h')];
[SMTPat (live x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h'); SMTPat (B.modifies l h h')]
]
]
let preserved'
(#t: Type)
(#[FStar.Tactics.Typeclasses.tcresolve ()] inst: input_stream_inst t)
(x: t)
(l: B.loc)
(h h': HS.mem)
: Lemma (requires (live x h /\ B.modifies l h h' /\ B.loc_disjoint (footprint x) l))
(ensures
(live x h' /\ get_remaining x h' == get_remaining x h /\ get_read x h' == get_read x h))
[
SMTPatOr
[
[SMTPat (live x h); SMTPat (B.modifies l h h')];
[SMTPat (live x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h'); SMTPat (B.modifies l h h')]
]
] = | false | null | true | preserved x l h h' | {
"checked_file": "EverParse3d.InputStream.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"EverParse3d.ErrorCode.fst.checked"
],
"interface_file": false,
"source_file": "EverParse3d.InputStream.Base.fst"
} | [
"lemma"
] | [
"EverParse3d.InputStream.Base.input_stream_inst",
"LowStar.Monotonic.Buffer.loc",
"FStar.Monotonic.HyperStack.mem",
"EverParse3d.InputStream.Base.preserved",
"Prims.unit",
"Prims.l_and",
"EverParse3d.InputStream.Base.live",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_disjoint",
"EverParse3d.InputStream.Base.footprint",
"Prims.squash",
"Prims.eq2",
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"EverParse3d.InputStream.Base.get_remaining",
"EverParse3d.InputStream.Base.get_read",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat_or",
"Prims.list",
"FStar.Pervasives.smt_pat",
"Prims.prop",
"Prims.Nil"
] | [] | module EverParse3d.InputStream.Base
module U8 = FStar.UInt8
module U64 = FStar.UInt64
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module B = LowStar.Buffer
module LPE = EverParse3d.ErrorCode
module LP = LowParse.Low.Base
noextract
inline_for_extraction
class input_stream_inst (t: Type) : Type = {
live: t -> HS.mem -> Tot prop;
footprint: (x: t) -> Ghost B.loc
(requires True)
(ensures (fun y -> B.address_liveness_insensitive_locs `B.loc_includes` y));
perm_footprint: (x: t) -> Ghost B.loc
(requires True)
(ensures (fun y -> footprint x `B.loc_includes` y));
live_not_unused_in:
(x: t) ->
(h: HS.mem) ->
Lemma
(requires (live x h))
(ensures (B.loc_not_unused_in h `B.loc_includes` footprint x));
len_all: (x: t) -> GTot LPE.pos_t;
get_all: (x: t) -> Ghost (Seq.seq U8.t)
(requires True)
(ensures (fun y -> Seq.length y == U64.v (len_all x)));
get_remaining: (x: t) -> (h: HS.mem) -> Ghost (Seq.seq U8.t)
(requires (live x h))
(ensures (fun y -> Seq.length y <= U64.v (len_all x)));
get_read: (x: t) -> (h: HS.mem) -> Ghost (Seq.seq U8.t)
(requires (live x h))
(ensures (fun y -> get_all x `Seq.equal` (y `Seq.append` get_remaining x h)));
preserved:
(x: t) ->
(l: B.loc) ->
(h: HS.mem) ->
(h' : HS.mem) ->
Lemma
(requires (live x h /\ B.modifies l h h' /\ B.loc_disjoint (footprint x) l))
(ensures (
live x h' /\
get_remaining x h' == get_remaining x h /\
get_read x h' == get_read x h
));
tlen: t -> Type0;
extra_t: Type0;
has:
(# [FStar.Tactics.Typeclasses.tcresolve () ] extra_t ) ->
(x: t) ->
(len: tlen x) ->
(pos: LPE.pos_t) ->
(n: U64.t) ->
HST.Stack bool
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h)
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
(res == true <==> Seq.length (get_remaining x h) >= U64.v n)
));
read:
(# [FStar.Tactics.Typeclasses.tcresolve ()] extra_t ) ->
(t': Type0) ->
(k: LP.parser_kind) ->
(p: LP.parser k t') ->
(r: LP.leaf_reader p) ->
(x: t) ->
(pos: LPE.pos_t) ->
(n: U64.t) ->
HST.Stack t'
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h) /\
k.LP.parser_kind_subkind == Some LP.ParserStrong /\
k.LP.parser_kind_high == Some k.LP.parser_kind_low /\
k.LP.parser_kind_low == U64.v n /\
U64.v n > 0 /\
U64.v n < 4294967296 /\
Some? (LP.parse p (get_remaining x h))
))
(ensures (fun h dst' h' ->
let s = get_remaining x h in
B.modifies (perm_footprint x) h h' /\
Seq.length s >= U64.v n /\
LP.parse p (Seq.slice s 0 (U64.v n)) == Some (dst', U64.v n) /\
LP.parse p s == Some (dst', U64.v n) /\
live x h' /\
get_remaining x h' `Seq.equal` Seq.slice s (U64.v n) (Seq.length s)
));
skip:
(# [FStar.Tactics.Typeclasses.tcresolve ()] extra_t ) ->
(x: t) ->
(pos: LPE.pos_t) ->
(n: U64.t) ->
HST.Stack unit
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h) /\
Seq.length (get_remaining x h) >= U64.v n
))
(ensures (fun h _ h' ->
let s = get_remaining x h in
B.modifies (perm_footprint x) h h' /\
live x h' /\
get_remaining x h' `Seq.equal` Seq.slice s (U64.v n) (Seq.length s)
));
skip_if_success:
(# [FStar.Tactics.Typeclasses.tcresolve ()] extra_t ) ->
(x: t) ->
(pos: LPE.pos_t) ->
(res: U64.t) ->
HST.Stack unit
(requires (fun h ->
live x h /\
(LPE.is_success res ==> (
U64.v pos == Seq.length (get_read x h)) /\
U64.v res >= U64.v pos /\
U64.v pos + Seq.length (get_remaining x h) >= U64.v res
)))
(ensures (fun h _ h' ->
let s = get_remaining x h in
B.modifies (perm_footprint x) h h' /\
live x h' /\
get_remaining x h' == (if LPE.is_success res then Seq.slice s (U64.v res - U64.v pos) (Seq.length s) else get_remaining x h)
));
empty:
(# [FStar.Tactics.Typeclasses.tcresolve ()] extra_t ) ->
(x: t) ->
(len: tlen x) ->
(pos: LPE.pos_t) ->
HST.Stack LPE.pos_t
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h)
))
(ensures (fun h res h' ->
B.modifies (perm_footprint x) h h' /\
live x h' /\
U64.v res == Seq.length (get_read x h') /\
get_remaining x h' `Seq.equal` Seq.empty
));
is_prefix_of:
(x: t) ->
(y: t) ->
Tot prop;
get_suffix:
(x: t) ->
(y: t) ->
Ghost (Seq.seq U8.t)
(requires (x `is_prefix_of` y))
(ensures (fun _ -> True));
is_prefix_of_prop:
(x: t) ->
(y: t) ->
(h: HS.mem) ->
Lemma
(requires (
live x h /\
x `is_prefix_of` y
))
(ensures (
live y h /\
get_read y h `Seq.equal` get_read x h /\
get_remaining y h `Seq.equal` (get_remaining x h `Seq.append` get_suffix x y)
));
truncate:
(x: t) ->
(pos: LPE.pos_t) ->
(n: U64.t) ->
HST.Stack t
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h) /\
U64.v n <= Seq.length (get_remaining x h)
))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
res `is_prefix_of` x /\
footprint res == footprint x /\
perm_footprint res == perm_footprint x /\
live res h' /\
Seq.length (get_remaining res h') == U64.v n
));
truncate_len:
(x: t) ->
(pos: LPE.pos_t) ->
(n: U64.t) ->
(res: t) ->
HST.Stack (tlen res)
(requires (fun h ->
live x h /\
U64.v pos == Seq.length (get_read x h) /\
U64.v n <= Seq.length (get_remaining x h) /\
res `is_prefix_of` x /\
footprint res == footprint x /\
perm_footprint res == perm_footprint x /\
live res h /\
Seq.length (get_remaining res h) == U64.v n
))
(ensures (fun h res_len h' ->
B.modifies B.loc_none h h'
));
}
let length_all #t (#_: input_stream_inst t) (x: t) : GTot nat = U64.v (len_all x)
let preserved'
(#t: Type)
(# [FStar.Tactics.Typeclasses.tcresolve ()] inst : input_stream_inst t)
(x: t)
(l: B.loc)
(h: HS.mem)
(h' : HS.mem)
: Lemma
(requires (live x h /\ B.modifies l h h' /\ B.loc_disjoint (footprint x) l))
(ensures (
live x h' /\
get_remaining x h' == get_remaining x h /\
get_read x h' == get_read x h
))
[SMTPatOr [
[SMTPat (live x h); SMTPat (B.modifies l h h')];
[SMTPat (live x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h'); SMTPat (B.modifies l h h')]; | false | false | EverParse3d.InputStream.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val preserved'
(#t: Type)
(#[FStar.Tactics.Typeclasses.tcresolve ()] inst: input_stream_inst t)
(x: t)
(l: B.loc)
(h h': HS.mem)
: Lemma (requires (live x h /\ B.modifies l h h' /\ B.loc_disjoint (footprint x) l))
(ensures
(live x h' /\ get_remaining x h' == get_remaining x h /\ get_read x h' == get_read x h))
[
SMTPatOr
[
[SMTPat (live x h); SMTPat (B.modifies l h h')];
[SMTPat (live x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h); SMTPat (B.modifies l h h')];
[SMTPat (get_remaining x h'); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h); SMTPat (B.modifies l h h')];
[SMTPat (get_read x h'); SMTPat (B.modifies l h h')]
]
] | [] | EverParse3d.InputStream.Base.preserved' | {
"file_name": "src/3d/prelude/EverParse3d.InputStream.Base.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
x: t ->
l: LowStar.Monotonic.Buffer.loc ->
h: FStar.Monotonic.HyperStack.mem ->
h': FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
EverParse3d.InputStream.Base.live x h /\ LowStar.Monotonic.Buffer.modifies l h h' /\
LowStar.Monotonic.Buffer.loc_disjoint (EverParse3d.InputStream.Base.footprint x) l)
(ensures
EverParse3d.InputStream.Base.live x h' /\
EverParse3d.InputStream.Base.get_remaining x h' ==
EverParse3d.InputStream.Base.get_remaining x h /\
EverParse3d.InputStream.Base.get_read x h' == EverParse3d.InputStream.Base.get_read x h)
[
SMTPatOr [
[
SMTPat (EverParse3d.InputStream.Base.live x h);
SMTPat (LowStar.Monotonic.Buffer.modifies l h h')
];
[
SMTPat (EverParse3d.InputStream.Base.live x h');
SMTPat (LowStar.Monotonic.Buffer.modifies l h h')
];
[
SMTPat (EverParse3d.InputStream.Base.get_remaining x h);
SMTPat (LowStar.Monotonic.Buffer.modifies l h h')
];
[
SMTPat (EverParse3d.InputStream.Base.get_remaining x h');
SMTPat (LowStar.Monotonic.Buffer.modifies l h h')
];
[
SMTPat (EverParse3d.InputStream.Base.get_read x h);
SMTPat (LowStar.Monotonic.Buffer.modifies l h h')
];
[
SMTPat (EverParse3d.InputStream.Base.get_read x h');
SMTPat (LowStar.Monotonic.Buffer.modifies l h h')
]
]
] | {
"end_col": 20,
"end_line": 256,
"start_col": 2,
"start_line": 256
} |
FStar.Pervasives.Lemma | val lemma_dv_equal
(#src: Type)
(#rel #rrel: MB.srel src)
(#dst: Type)
(view: DV.view src dst)
(b: MB.mbuffer src rel rrel)
(h0 h1: HS.mem)
: Lemma (requires MB.as_seq h0 b == MB.as_seq h1 b)
(ensures
(let dv = DV.mk_buffer_view b view in
DV.as_seq h0 dv == DV.as_seq h1 dv)) | [
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Modifies",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"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 lemma_dv_equal
(#src:Type)
(#rel #rrel:MB.srel src)
(#dst:Type)
(view:DV.view src dst)
(b:MB.mbuffer src rel rrel)
(h0 h1:HS.mem) : Lemma
(requires MB.as_seq h0 b == MB.as_seq h1 b)
(ensures (let dv = DV.mk_buffer_view b view in
DV.as_seq h0 dv == DV.as_seq h1 dv)) =
let dv = DV.mk_buffer_view b view in
let s0 = DV.as_seq h0 dv in
let s1 = DV.as_seq h1 dv in
let aux (i:nat{i < DV.length dv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
DV.as_seq_sel h0 dv i;
DV.as_seq_sel h1 dv i;
DV.get_sel h0 dv i;
DV.get_sel h1 dv i
in Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1 | val lemma_dv_equal
(#src: Type)
(#rel #rrel: MB.srel src)
(#dst: Type)
(view: DV.view src dst)
(b: MB.mbuffer src rel rrel)
(h0 h1: HS.mem)
: Lemma (requires MB.as_seq h0 b == MB.as_seq h1 b)
(ensures
(let dv = DV.mk_buffer_view b view in
DV.as_seq h0 dv == DV.as_seq h1 dv))
let lemma_dv_equal
(#src: Type)
(#rel #rrel: MB.srel src)
(#dst: Type)
(view: DV.view src dst)
(b: MB.mbuffer src rel rrel)
(h0 h1: HS.mem)
: Lemma (requires MB.as_seq h0 b == MB.as_seq h1 b)
(ensures
(let dv = DV.mk_buffer_view b view in
DV.as_seq h0 dv == DV.as_seq h1 dv)) = | false | null | true | let dv = DV.mk_buffer_view b view in
let s0 = DV.as_seq h0 dv in
let s1 = DV.as_seq h1 dv in
let aux (i: nat{i < DV.length dv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
DV.as_seq_sel h0 dv i;
DV.as_seq_sel h1 dv i;
DV.get_sel h0 dv i;
DV.get_sel h1 dv i
in
Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1 | {
"checked_file": "Vale.Lib.BufferViewHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.BufferView.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Lib.BufferViewHelpers.fst"
} | [
"lemma"
] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.BufferView.Down.view",
"LowStar.Monotonic.Buffer.mbuffer",
"FStar.Monotonic.HyperStack.mem",
"FStar.Seq.Base.lemma_eq_intro",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"LowStar.BufferView.Down.length",
"Prims.eq2",
"FStar.Seq.Base.index",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowStar.BufferView.Down.get_sel",
"LowStar.BufferView.Down.as_seq_sel",
"FStar.Seq.Properties.lseq",
"LowStar.BufferView.Down.as_seq",
"LowStar.BufferView.Down.buffer",
"LowStar.BufferView.Down.mk_buffer_view",
"FStar.Seq.Base.seq",
"LowStar.Monotonic.Buffer.as_seq"
] | [] | module Vale.Lib.BufferViewHelpers
open FStar.Mul
module MB = LowStar.Monotonic.Buffer
module BV = LowStar.BufferView
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
open LowStar.Modifies
open LowStar.ModifiesPat
let lemma_dv_equal
(#src:Type)
(#rel #rrel:MB.srel src)
(#dst:Type)
(view:DV.view src dst)
(b:MB.mbuffer src rel rrel)
(h0 h1:HS.mem) : Lemma
(requires MB.as_seq h0 b == MB.as_seq h1 b) | false | false | Vale.Lib.BufferViewHelpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_dv_equal
(#src: Type)
(#rel #rrel: MB.srel src)
(#dst: Type)
(view: DV.view src dst)
(b: MB.mbuffer src rel rrel)
(h0 h1: HS.mem)
: Lemma (requires MB.as_seq h0 b == MB.as_seq h1 b)
(ensures
(let dv = DV.mk_buffer_view b view in
DV.as_seq h0 dv == DV.as_seq h1 dv)) | [] | Vale.Lib.BufferViewHelpers.lemma_dv_equal | {
"file_name": "vale/code/lib/util/Vale.Lib.BufferViewHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
view: LowStar.BufferView.Down.view src dst ->
b: LowStar.Monotonic.Buffer.mbuffer src rel rrel ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires LowStar.Monotonic.Buffer.as_seq h0 b == LowStar.Monotonic.Buffer.as_seq h1 b)
(ensures
(let dv = LowStar.BufferView.Down.mk_buffer_view b view in
LowStar.BufferView.Down.as_seq h0 dv == LowStar.BufferView.Down.as_seq h1 dv)) | {
"end_col": 28,
"end_line": 34,
"start_col": 42,
"start_line": 24
} |
FStar.Pervasives.Lemma | val lemma_uv_equal (#src #dst: Type) (view: UV.view src dst) (b: DV.buffer src) (h0 h1: HS.mem)
: Lemma (requires (DV.length b % UV.View?.n view == 0 /\ DV.as_seq h0 b == DV.as_seq h1 b))
(ensures
(let bv = UV.mk_buffer b view in
UV.as_seq h0 bv == UV.as_seq h1 bv))
[SMTPat (UV.as_seq h0 (UV.mk_buffer b view)); SMTPat (UV.as_seq h1 (UV.mk_buffer b view))] | [
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Modifies",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"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 lemma_uv_equal
(#src:Type) (#dst:Type)
(view:UV.view src dst) (b:DV.buffer src) (h0 h1:HS.mem)
:Lemma (requires (DV.length b % UV.View?.n view == 0 /\ DV.as_seq h0 b == DV.as_seq h1 b))
(ensures (let bv = UV.mk_buffer b view in UV.as_seq h0 bv == UV.as_seq h1 bv))
[SMTPat (UV.as_seq h0 (UV.mk_buffer b view)); SMTPat (UV.as_seq h1 (UV.mk_buffer b view))]
= let uv = UV.mk_buffer b view in
let s0 = UV.as_seq h0 uv in
let s1 = UV.as_seq h1 uv in
let aux (i:nat{i < UV.length uv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
UV.as_seq_sel h0 uv i;
UV.as_seq_sel h1 uv i;
UV.get_sel h0 uv i;
UV.get_sel h1 uv i
in Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1 | val lemma_uv_equal (#src #dst: Type) (view: UV.view src dst) (b: DV.buffer src) (h0 h1: HS.mem)
: Lemma (requires (DV.length b % UV.View?.n view == 0 /\ DV.as_seq h0 b == DV.as_seq h1 b))
(ensures
(let bv = UV.mk_buffer b view in
UV.as_seq h0 bv == UV.as_seq h1 bv))
[SMTPat (UV.as_seq h0 (UV.mk_buffer b view)); SMTPat (UV.as_seq h1 (UV.mk_buffer b view))]
let lemma_uv_equal (#src #dst: Type) (view: UV.view src dst) (b: DV.buffer src) (h0 h1: HS.mem)
: Lemma (requires (DV.length b % UV.View?.n view == 0 /\ DV.as_seq h0 b == DV.as_seq h1 b))
(ensures
(let bv = UV.mk_buffer b view in
UV.as_seq h0 bv == UV.as_seq h1 bv))
[SMTPat (UV.as_seq h0 (UV.mk_buffer b view)); SMTPat (UV.as_seq h1 (UV.mk_buffer b view))] = | false | null | true | let uv = UV.mk_buffer b view in
let s0 = UV.as_seq h0 uv in
let s1 = UV.as_seq h1 uv in
let aux (i: nat{i < UV.length uv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
UV.as_seq_sel h0 uv i;
UV.as_seq_sel h1 uv i;
UV.get_sel h0 uv i;
UV.get_sel h1 uv i
in
Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1 | {
"checked_file": "Vale.Lib.BufferViewHelpers.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.BufferView.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Lib.BufferViewHelpers.fst"
} | [
"lemma"
] | [
"LowStar.BufferView.Up.view",
"LowStar.BufferView.Down.buffer",
"FStar.Monotonic.HyperStack.mem",
"FStar.Seq.Base.lemma_eq_intro",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"LowStar.BufferView.Up.length",
"Prims.eq2",
"FStar.Seq.Base.index",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowStar.BufferView.Up.get_sel",
"LowStar.BufferView.Up.as_seq_sel",
"FStar.Seq.Properties.lseq",
"LowStar.BufferView.Up.as_seq",
"LowStar.BufferView.Up.buffer",
"LowStar.BufferView.Up.mk_buffer",
"Prims.l_and",
"Prims.int",
"Prims.op_Modulus",
"LowStar.BufferView.Down.length",
"LowStar.BufferView.Up.__proj__View__item__n",
"LowStar.BufferView.Down.as_seq",
"Prims.Cons",
"FStar.Pervasives.smt_pat"
] | [] | module Vale.Lib.BufferViewHelpers
open FStar.Mul
module MB = LowStar.Monotonic.Buffer
module BV = LowStar.BufferView
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
open LowStar.Modifies
open LowStar.ModifiesPat
let lemma_dv_equal
(#src:Type)
(#rel #rrel:MB.srel src)
(#dst:Type)
(view:DV.view src dst)
(b:MB.mbuffer src rel rrel)
(h0 h1:HS.mem) : Lemma
(requires MB.as_seq h0 b == MB.as_seq h1 b)
(ensures (let dv = DV.mk_buffer_view b view in
DV.as_seq h0 dv == DV.as_seq h1 dv)) =
let dv = DV.mk_buffer_view b view in
let s0 = DV.as_seq h0 dv in
let s1 = DV.as_seq h1 dv in
let aux (i:nat{i < DV.length dv}) : Lemma (Seq.index s0 i == Seq.index s1 i) =
DV.as_seq_sel h0 dv i;
DV.as_seq_sel h1 dv i;
DV.get_sel h0 dv i;
DV.get_sel h1 dv i
in Classical.forall_intro aux;
Seq.lemma_eq_intro s0 s1
let lemma_uv_equal
(#src:Type) (#dst:Type)
(view:UV.view src dst) (b:DV.buffer src) (h0 h1:HS.mem)
:Lemma (requires (DV.length b % UV.View?.n view == 0 /\ DV.as_seq h0 b == DV.as_seq h1 b))
(ensures (let bv = UV.mk_buffer b view in UV.as_seq h0 bv == UV.as_seq h1 bv)) | false | false | Vale.Lib.BufferViewHelpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_uv_equal (#src #dst: Type) (view: UV.view src dst) (b: DV.buffer src) (h0 h1: HS.mem)
: Lemma (requires (DV.length b % UV.View?.n view == 0 /\ DV.as_seq h0 b == DV.as_seq h1 b))
(ensures
(let bv = UV.mk_buffer b view in
UV.as_seq h0 bv == UV.as_seq h1 bv))
[SMTPat (UV.as_seq h0 (UV.mk_buffer b view)); SMTPat (UV.as_seq h1 (UV.mk_buffer b view))] | [] | Vale.Lib.BufferViewHelpers.lemma_uv_equal | {
"file_name": "vale/code/lib/util/Vale.Lib.BufferViewHelpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
view: LowStar.BufferView.Up.view src dst ->
b: LowStar.BufferView.Down.buffer src ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
LowStar.BufferView.Down.length b % View?.n view == 0 /\
LowStar.BufferView.Down.as_seq h0 b == LowStar.BufferView.Down.as_seq h1 b)
(ensures
(let bv = LowStar.BufferView.Up.mk_buffer b view in
LowStar.BufferView.Up.as_seq h0 bv == LowStar.BufferView.Up.as_seq h1 bv))
[
SMTPat (LowStar.BufferView.Up.as_seq h0 (LowStar.BufferView.Up.mk_buffer b view));
SMTPat (LowStar.BufferView.Up.as_seq h1 (LowStar.BufferView.Up.mk_buffer b view))
] | {
"end_col": 28,
"end_line": 51,
"start_col": 3,
"start_line": 42
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lbytes len = lbuffer uint8 len | let lbytes len = | false | null | false | lbuffer uint8 len | {
"checked_file": "Hacl.K256.ECDSA.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.ECDSA.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8"
] | [] | module Hacl.K256.ECDSA
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module S = Spec.K256
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.K256.ECDSA.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lbytes : len: Lib.IntTypes.size_t -> Type0 | [] | Hacl.K256.ECDSA.lbytes | {
"file_name": "code/k256/Hacl.K256.ECDSA.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_t -> Type0 | {
"end_col": 34,
"end_line": 16,
"start_col": 17,
"start_line": 16
} |
|
Prims.Tot | val equality_equiv (a: Type) : equiv a | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let equality_equiv (a:Type) : equiv a =
EQ (fun x y -> x == y) (fun x -> ()) (fun x y -> ()) (fun x y z -> ()) | val equality_equiv (a: Type) : equiv a
let equality_equiv (a: Type) : equiv a = | false | null | false | EQ (fun x y -> x == y) (fun x -> ()) (fun x y -> ()) (fun x y z -> ()) | {
"checked_file": "FStar.Algebra.CommMonoid.Equiv.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Algebra.CommMonoid.Equiv.fst"
} | [
"total"
] | [
"FStar.Algebra.CommMonoid.Equiv.EQ",
"Prims.eq2",
"Prims.unit",
"FStar.Algebra.CommMonoid.Equiv.equiv"
] | [] | (*
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.Algebra.CommMonoid.Equiv
open FStar.Mul
unopteq
type equiv (a:Type) =
| EQ :
eq:(a -> a -> Type0) ->
reflexivity:(x:a -> Lemma (x `eq` x)) ->
symmetry:(x:a -> y:a -> Lemma (requires (x `eq` y)) (ensures (y `eq` x))) ->
transitivity:(x:a -> y:a -> z:a -> Lemma (requires (x `eq` y /\ y `eq` z)) (ensures (x `eq` z))) ->
equiv a
let elim_eq_laws #a (eq:equiv a)
: Lemma (
(forall x.{:pattern (x `eq.eq` x)} x `eq.eq` x) /\
(forall x y.{:pattern (x `eq.eq` y)} x `eq.eq` y ==> y `eq.eq` x) /\
(forall x y z.{:pattern eq.eq x y; eq.eq y z} (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z)
)
= introduce forall x. x `eq.eq` x
with (eq.reflexivity x);
introduce forall x y. x `eq.eq` y ==> y `eq.eq` x
with (introduce _ ==> _
with _. eq.symmetry x y);
introduce forall x y z. (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z
with (introduce _ ==> _
with _. eq.transitivity x y z) | false | false | FStar.Algebra.CommMonoid.Equiv.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 equality_equiv (a: Type) : equiv a | [] | FStar.Algebra.CommMonoid.Equiv.equality_equiv | {
"file_name": "ulib/FStar.Algebra.CommMonoid.Equiv.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> FStar.Algebra.CommMonoid.Equiv.equiv a | {
"end_col": 72,
"end_line": 47,
"start_col": 2,
"start_line": 47
} |
Prims.Tot | val int_multiply_cm:cm int (equality_equiv int) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_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_multiply_cm : cm int (equality_equiv int) =
CM 1 ( * ) (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ()) (fun _ _ _ _ -> ()) | val int_multiply_cm:cm int (equality_equiv int)
let int_multiply_cm:cm int (equality_equiv int) = | false | null | false | CM 1 ( * ) (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ()) (fun _ _ _ _ -> ()) | {
"checked_file": "FStar.Algebra.CommMonoid.Equiv.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Algebra.CommMonoid.Equiv.fst"
} | [
"total"
] | [
"FStar.Algebra.CommMonoid.Equiv.CM",
"Prims.int",
"FStar.Algebra.CommMonoid.Equiv.equality_equiv",
"FStar.Mul.op_Star",
"Prims.unit"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Algebra.CommMonoid.Equiv
open FStar.Mul
unopteq
type equiv (a:Type) =
| EQ :
eq:(a -> a -> Type0) ->
reflexivity:(x:a -> Lemma (x `eq` x)) ->
symmetry:(x:a -> y:a -> Lemma (requires (x `eq` y)) (ensures (y `eq` x))) ->
transitivity:(x:a -> y:a -> z:a -> Lemma (requires (x `eq` y /\ y `eq` z)) (ensures (x `eq` z))) ->
equiv a
let elim_eq_laws #a (eq:equiv a)
: Lemma (
(forall x.{:pattern (x `eq.eq` x)} x `eq.eq` x) /\
(forall x y.{:pattern (x `eq.eq` y)} x `eq.eq` y ==> y `eq.eq` x) /\
(forall x y z.{:pattern eq.eq x y; eq.eq y z} (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z)
)
= introduce forall x. x `eq.eq` x
with (eq.reflexivity x);
introduce forall x y. x `eq.eq` y ==> y `eq.eq` x
with (introduce _ ==> _
with _. eq.symmetry x y);
introduce forall x y z. (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z
with (introduce _ ==> _
with _. eq.transitivity x y z)
let equality_equiv (a:Type) : equiv a =
EQ (fun x y -> x == y) (fun x -> ()) (fun x y -> ()) (fun x y z -> ())
unopteq
type cm (a:Type) (eq:equiv a) =
| CM :
unit:a ->
mult:(a -> a -> a) ->
identity : (x:a -> Lemma ((unit `mult` x) `EQ?.eq eq` x)) ->
associativity : (x:a -> y:a -> z:a ->
Lemma ((x `mult` y `mult` z) `EQ?.eq eq` (x `mult` (y `mult` z)))) ->
commutativity:(x:a -> y:a -> Lemma ((x `mult` y) `EQ?.eq eq` (y `mult` x))) ->
congruence:(x:a -> y:a -> z:a -> w:a -> Lemma (requires (x `EQ?.eq eq` z /\ y `EQ?.eq eq` w)) (ensures ((mult x y) `EQ?.eq eq` (mult z w)))) ->
cm a eq
// temporarily fixing the universe of this lemma to u#1 because
// otherwise tactics for LowStar.Resource canonicalization fails
// by picking up an incorrect universe u#0 for resource type
let right_identity (#a:Type u#aa) (eq:equiv a) (m:cm a eq) (x:a)
: Lemma (x `CM?.mult m` (CM?.unit m) `EQ?.eq eq` x) =
CM?.commutativity m x (CM?.unit m);
CM?.identity m x;
EQ?.transitivity eq (x `CM?.mult m` (CM?.unit m)) ((CM?.unit m) `CM?.mult m` x) x
let int_plus_cm : cm int (equality_equiv int) =
CM 0 (+) (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ()) (fun _ _ _ _ -> ()) | false | true | FStar.Algebra.CommMonoid.Equiv.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 int_multiply_cm:cm int (equality_equiv int) | [] | FStar.Algebra.CommMonoid.Equiv.int_multiply_cm | {
"file_name": "ulib/FStar.Algebra.CommMonoid.Equiv.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Algebra.CommMonoid.Equiv.cm Prims.int
(FStar.Algebra.CommMonoid.Equiv.equality_equiv Prims.int) | {
"end_col": 80,
"end_line": 76,
"start_col": 2,
"start_line": 76
} |
Prims.Tot | val int_plus_cm:cm int (equality_equiv int) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_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_plus_cm : cm int (equality_equiv int) =
CM 0 (+) (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ()) (fun _ _ _ _ -> ()) | val int_plus_cm:cm int (equality_equiv int)
let int_plus_cm:cm int (equality_equiv int) = | false | null | false | CM 0 ( + ) (fun _ -> ()) (fun _ _ _ -> ()) (fun _ _ -> ()) (fun _ _ _ _ -> ()) | {
"checked_file": "FStar.Algebra.CommMonoid.Equiv.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Algebra.CommMonoid.Equiv.fst"
} | [
"total"
] | [
"FStar.Algebra.CommMonoid.Equiv.CM",
"Prims.int",
"FStar.Algebra.CommMonoid.Equiv.equality_equiv",
"Prims.op_Addition",
"Prims.unit"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Algebra.CommMonoid.Equiv
open FStar.Mul
unopteq
type equiv (a:Type) =
| EQ :
eq:(a -> a -> Type0) ->
reflexivity:(x:a -> Lemma (x `eq` x)) ->
symmetry:(x:a -> y:a -> Lemma (requires (x `eq` y)) (ensures (y `eq` x))) ->
transitivity:(x:a -> y:a -> z:a -> Lemma (requires (x `eq` y /\ y `eq` z)) (ensures (x `eq` z))) ->
equiv a
let elim_eq_laws #a (eq:equiv a)
: Lemma (
(forall x.{:pattern (x `eq.eq` x)} x `eq.eq` x) /\
(forall x y.{:pattern (x `eq.eq` y)} x `eq.eq` y ==> y `eq.eq` x) /\
(forall x y z.{:pattern eq.eq x y; eq.eq y z} (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z)
)
= introduce forall x. x `eq.eq` x
with (eq.reflexivity x);
introduce forall x y. x `eq.eq` y ==> y `eq.eq` x
with (introduce _ ==> _
with _. eq.symmetry x y);
introduce forall x y z. (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z
with (introduce _ ==> _
with _. eq.transitivity x y z)
let equality_equiv (a:Type) : equiv a =
EQ (fun x y -> x == y) (fun x -> ()) (fun x y -> ()) (fun x y z -> ())
unopteq
type cm (a:Type) (eq:equiv a) =
| CM :
unit:a ->
mult:(a -> a -> a) ->
identity : (x:a -> Lemma ((unit `mult` x) `EQ?.eq eq` x)) ->
associativity : (x:a -> y:a -> z:a ->
Lemma ((x `mult` y `mult` z) `EQ?.eq eq` (x `mult` (y `mult` z)))) ->
commutativity:(x:a -> y:a -> Lemma ((x `mult` y) `EQ?.eq eq` (y `mult` x))) ->
congruence:(x:a -> y:a -> z:a -> w:a -> Lemma (requires (x `EQ?.eq eq` z /\ y `EQ?.eq eq` w)) (ensures ((mult x y) `EQ?.eq eq` (mult z w)))) ->
cm a eq
// temporarily fixing the universe of this lemma to u#1 because
// otherwise tactics for LowStar.Resource canonicalization fails
// by picking up an incorrect universe u#0 for resource type
let right_identity (#a:Type u#aa) (eq:equiv a) (m:cm a eq) (x:a)
: Lemma (x `CM?.mult m` (CM?.unit m) `EQ?.eq eq` x) =
CM?.commutativity m x (CM?.unit m);
CM?.identity m x;
EQ?.transitivity eq (x `CM?.mult m` (CM?.unit m)) ((CM?.unit m) `CM?.mult m` x) x | false | true | FStar.Algebra.CommMonoid.Equiv.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 int_plus_cm:cm int (equality_equiv int) | [] | FStar.Algebra.CommMonoid.Equiv.int_plus_cm | {
"file_name": "ulib/FStar.Algebra.CommMonoid.Equiv.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Algebra.CommMonoid.Equiv.cm Prims.int
(FStar.Algebra.CommMonoid.Equiv.equality_equiv Prims.int) | {
"end_col": 78,
"end_line": 73,
"start_col": 2,
"start_line": 73
} |
FStar.Pervasives.Lemma | val right_identity (#a: Type u#aa) (eq: equiv a) (m: cm a eq) (x: a)
: Lemma (EQ?.eq eq (CM?.mult m x (CM?.unit m)) x) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let right_identity (#a:Type u#aa) (eq:equiv a) (m:cm a eq) (x:a)
: Lemma (x `CM?.mult m` (CM?.unit m) `EQ?.eq eq` x) =
CM?.commutativity m x (CM?.unit m);
CM?.identity m x;
EQ?.transitivity eq (x `CM?.mult m` (CM?.unit m)) ((CM?.unit m) `CM?.mult m` x) x | val right_identity (#a: Type u#aa) (eq: equiv a) (m: cm a eq) (x: a)
: Lemma (EQ?.eq eq (CM?.mult m x (CM?.unit m)) x)
let right_identity (#a: Type u#aa) (eq: equiv a) (m: cm a eq) (x: a)
: Lemma (EQ?.eq eq (CM?.mult m x (CM?.unit m)) x) = | false | null | true | CM?.commutativity m x (CM?.unit m);
CM?.identity m x;
EQ?.transitivity eq (CM?.mult m x (CM?.unit m)) (CM?.mult m (CM?.unit m) x) x | {
"checked_file": "FStar.Algebra.CommMonoid.Equiv.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Algebra.CommMonoid.Equiv.fst"
} | [
"lemma"
] | [
"FStar.Algebra.CommMonoid.Equiv.equiv",
"FStar.Algebra.CommMonoid.Equiv.cm",
"FStar.Algebra.CommMonoid.Equiv.__proj__EQ__item__transitivity",
"FStar.Algebra.CommMonoid.Equiv.__proj__CM__item__mult",
"FStar.Algebra.CommMonoid.Equiv.__proj__CM__item__unit",
"Prims.unit",
"FStar.Algebra.CommMonoid.Equiv.__proj__CM__item__identity",
"FStar.Algebra.CommMonoid.Equiv.__proj__CM__item__commutativity",
"Prims.l_True",
"Prims.squash",
"FStar.Algebra.CommMonoid.Equiv.__proj__EQ__item__eq",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Algebra.CommMonoid.Equiv
open FStar.Mul
unopteq
type equiv (a:Type) =
| EQ :
eq:(a -> a -> Type0) ->
reflexivity:(x:a -> Lemma (x `eq` x)) ->
symmetry:(x:a -> y:a -> Lemma (requires (x `eq` y)) (ensures (y `eq` x))) ->
transitivity:(x:a -> y:a -> z:a -> Lemma (requires (x `eq` y /\ y `eq` z)) (ensures (x `eq` z))) ->
equiv a
let elim_eq_laws #a (eq:equiv a)
: Lemma (
(forall x.{:pattern (x `eq.eq` x)} x `eq.eq` x) /\
(forall x y.{:pattern (x `eq.eq` y)} x `eq.eq` y ==> y `eq.eq` x) /\
(forall x y z.{:pattern eq.eq x y; eq.eq y z} (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z)
)
= introduce forall x. x `eq.eq` x
with (eq.reflexivity x);
introduce forall x y. x `eq.eq` y ==> y `eq.eq` x
with (introduce _ ==> _
with _. eq.symmetry x y);
introduce forall x y z. (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z
with (introduce _ ==> _
with _. eq.transitivity x y z)
let equality_equiv (a:Type) : equiv a =
EQ (fun x y -> x == y) (fun x -> ()) (fun x y -> ()) (fun x y z -> ())
unopteq
type cm (a:Type) (eq:equiv a) =
| CM :
unit:a ->
mult:(a -> a -> a) ->
identity : (x:a -> Lemma ((unit `mult` x) `EQ?.eq eq` x)) ->
associativity : (x:a -> y:a -> z:a ->
Lemma ((x `mult` y `mult` z) `EQ?.eq eq` (x `mult` (y `mult` z)))) ->
commutativity:(x:a -> y:a -> Lemma ((x `mult` y) `EQ?.eq eq` (y `mult` x))) ->
congruence:(x:a -> y:a -> z:a -> w:a -> Lemma (requires (x `EQ?.eq eq` z /\ y `EQ?.eq eq` w)) (ensures ((mult x y) `EQ?.eq eq` (mult z w)))) ->
cm a eq
// temporarily fixing the universe of this lemma to u#1 because
// otherwise tactics for LowStar.Resource canonicalization fails
// by picking up an incorrect universe u#0 for resource type
let right_identity (#a:Type u#aa) (eq:equiv a) (m:cm a eq) (x:a) | false | false | FStar.Algebra.CommMonoid.Equiv.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 right_identity (#a: Type u#aa) (eq: equiv a) (m: cm a eq) (x: a)
: Lemma (EQ?.eq eq (CM?.mult m x (CM?.unit m)) x) | [] | FStar.Algebra.CommMonoid.Equiv.right_identity | {
"file_name": "ulib/FStar.Algebra.CommMonoid.Equiv.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | eq: FStar.Algebra.CommMonoid.Equiv.equiv a -> m: FStar.Algebra.CommMonoid.Equiv.cm a eq -> x: a
-> FStar.Pervasives.Lemma (ensures EQ?.eq eq (CM?.mult m x (CM?.unit m)) x) | {
"end_col": 83,
"end_line": 70,
"start_col": 2,
"start_line": 68
} |
FStar.Pervasives.Lemma | val elim_eq_laws (#a: _) (eq: equiv a)
: Lemma
((forall x. {:pattern (x `eq.eq` x)} x `eq.eq` x) /\
(forall x y. {:pattern (x `eq.eq` y)} x `eq.eq` y ==> y `eq.eq` x) /\
(forall x y z. {:pattern eq.eq x y; eq.eq y z} (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z)) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let elim_eq_laws #a (eq:equiv a)
: Lemma (
(forall x.{:pattern (x `eq.eq` x)} x `eq.eq` x) /\
(forall x y.{:pattern (x `eq.eq` y)} x `eq.eq` y ==> y `eq.eq` x) /\
(forall x y z.{:pattern eq.eq x y; eq.eq y z} (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z)
)
= introduce forall x. x `eq.eq` x
with (eq.reflexivity x);
introduce forall x y. x `eq.eq` y ==> y `eq.eq` x
with (introduce _ ==> _
with _. eq.symmetry x y);
introduce forall x y z. (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z
with (introduce _ ==> _
with _. eq.transitivity x y z) | val elim_eq_laws (#a: _) (eq: equiv a)
: Lemma
((forall x. {:pattern (x `eq.eq` x)} x `eq.eq` x) /\
(forall x y. {:pattern (x `eq.eq` y)} x `eq.eq` y ==> y `eq.eq` x) /\
(forall x y z. {:pattern eq.eq x y; eq.eq y z} (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z))
let elim_eq_laws #a (eq: equiv a)
: Lemma
((forall x. {:pattern (x `eq.eq` x)} x `eq.eq` x) /\
(forall x y. {:pattern (x `eq.eq` y)} x `eq.eq` y ==> y `eq.eq` x) /\
(forall x y z. {:pattern eq.eq x y; eq.eq y z} (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z)) = | false | null | true | introduce forall x . x `eq.eq` x
with (eq.reflexivity x);
introduce forall x y . x `eq.eq` y ==> y `eq.eq` x
with (introduce _ ==> _
with _. eq.symmetry x y);
introduce forall x y z . (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z
with (introduce _ ==> _
with _. eq.transitivity x y z) | {
"checked_file": "FStar.Algebra.CommMonoid.Equiv.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Classical.Sugar.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Algebra.CommMonoid.Equiv.fst"
} | [
"lemma"
] | [
"FStar.Algebra.CommMonoid.Equiv.equiv",
"FStar.Classical.Sugar.forall_intro",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.l_and",
"FStar.Algebra.CommMonoid.Equiv.__proj__EQ__item__eq",
"FStar.Classical.Sugar.implies_intro",
"Prims.squash",
"FStar.Algebra.CommMonoid.Equiv.__proj__EQ__item__transitivity",
"Prims.unit",
"FStar.Algebra.CommMonoid.Equiv.__proj__EQ__item__symmetry",
"FStar.Algebra.CommMonoid.Equiv.__proj__EQ__item__reflexivity",
"Prims.l_True",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Algebra.CommMonoid.Equiv
open FStar.Mul
unopteq
type equiv (a:Type) =
| EQ :
eq:(a -> a -> Type0) ->
reflexivity:(x:a -> Lemma (x `eq` x)) ->
symmetry:(x:a -> y:a -> Lemma (requires (x `eq` y)) (ensures (y `eq` x))) ->
transitivity:(x:a -> y:a -> z:a -> Lemma (requires (x `eq` y /\ y `eq` z)) (ensures (x `eq` z))) ->
equiv a
let elim_eq_laws #a (eq:equiv a)
: Lemma (
(forall x.{:pattern (x `eq.eq` x)} x `eq.eq` x) /\
(forall x y.{:pattern (x `eq.eq` y)} x `eq.eq` y ==> y `eq.eq` x) /\
(forall x y z.{:pattern eq.eq x y; eq.eq y z} (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z) | false | false | FStar.Algebra.CommMonoid.Equiv.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 elim_eq_laws (#a: _) (eq: equiv a)
: Lemma
((forall x. {:pattern (x `eq.eq` x)} x `eq.eq` x) /\
(forall x y. {:pattern (x `eq.eq` y)} x `eq.eq` y ==> y `eq.eq` x) /\
(forall x y z. {:pattern eq.eq x y; eq.eq y z} (x `eq.eq` y /\ y `eq.eq` z) ==> x `eq.eq` z)) | [] | FStar.Algebra.CommMonoid.Equiv.elim_eq_laws | {
"file_name": "ulib/FStar.Algebra.CommMonoid.Equiv.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | eq: FStar.Algebra.CommMonoid.Equiv.equiv a
-> FStar.Pervasives.Lemma
(ensures
(forall (x: a). {:pattern EQ?.eq eq x x} EQ?.eq eq x x) /\
(forall (x: a) (y: a). {:pattern EQ?.eq eq x y} EQ?.eq eq x y ==> EQ?.eq eq y x) /\
(forall (x: a) (y: a) (z: a). {:pattern EQ?.eq eq x y; EQ?.eq eq y z}
EQ?.eq eq x y /\ EQ?.eq eq y z ==> EQ?.eq eq x z)) | {
"end_col": 40,
"end_line": 44,
"start_col": 4,
"start_line": 35
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 (f:felem5) =
let (o0, o1, o2, o3, o4) = f in
if v o1 >= pow2 51 then
felem_fits5 f (1, 2, 1, 1, 1) /\ v o1 % pow2 51 < 8192
else felem_fits5 f (1, 1, 1, 1, 1) | let mul_inv_t (f: felem5) = | false | null | false | let o0, o1, o2, o3, o4 = f in
if v o1 >= pow2 51
then felem_fits5 f (1, 2, 1, 1, 1) /\ v o1 % pow2 51 < 8192
else felem_fits5 f (1, 1, 1, 1, 1) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Lib.IntTypes.uint64",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.pow2",
"Prims.l_and",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Modulus",
"Prims.bool",
"Prims.logical"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul)
inline_for_extraction noextract
val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1))
let carry51_wide #m l cin =
let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul)) | false | true | Hacl.Spec.Curve25519.Field51.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 mul_inv_t : f: Hacl.Spec.Curve25519.Field51.Definition.felem5 -> Prims.logical | [] | Hacl.Spec.Curve25519.Field51.mul_inv_t | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.Curve25519.Field51.Definition.felem5 -> Prims.logical | {
"end_col": 36,
"end_line": 241,
"start_col": 26,
"start_line": 237
} |
|
Prims.Pure | val fsqr25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\
mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f1) /\
feval out2 == fmul (feval f2) (feval f2)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 fsqr25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let (o10, o11, o12, o13, o14) = fsqr_felem5 (f10, f11, f12, f13, f14) in
let (o20, o21, o22, o23, o24) = fsqr_felem5 (f20, f21, f22, f23, f24) in
let (o10, o11, o12, o13, o14) = carry_wide5 (o10, o11, o12, o13, o14) in
let (o20, o21, o22, o23, o24) = carry_wide5 (o20, o21, o22, o23, o24) in
((o10, o11, o12, o13, o14), (o20, o21, o22, o23, o24)) | val fsqr25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\
mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f1) /\
feval out2 == fmul (feval f2) (feval f2))
let fsqr25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) = | false | null | false | let o10, o11, o12, o13, o14 = fsqr_felem5 (f10, f11, f12, f13, f14) in
let o20, o21, o22, o23, o24 = fsqr_felem5 (f20, f21, f22, f23, f24) in
let o10, o11, o12, o13, o14 = carry_wide5 (o10, o11, o12, o13, o14) in
let o20, o21, o22, o23, o24 = carry_wide5 (o20, o21, o22, o23, o24) in
((o10, o11, o12, o13, o14), (o20, o21, o22, o23, o24)) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.uint64",
"Lib.IntTypes.uint128",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Curve25519.Field51.carry_wide5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide5",
"Hacl.Spec.Curve25519.Field51.fsqr_felem5"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul)
inline_for_extraction noextract
val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1))
let carry51_wide #m l cin =
let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul))
let mul_inv_t (f:felem5) =
let (o0, o1, o2, o3, o4) = f in
if v o1 >= pow2 51 then
felem_fits5 f (1, 2, 1, 1, 1) /\ v o1 % pow2 51 < 8192
else felem_fits5 f (1, 1, 1, 1, 1)
#push-options "--ifuel 1"
val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1))
let lemma_mul_inv f cin =
assert_norm (pow51 = pow2 51)
#pop-options
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val carry_wide5:
inp:felem_wide5{felem_wide_fits5 inp (6579, 4797, 3340, 1881, 423)}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == feval_wide inp)
let carry_wide5 (i0, i1, i2, i3, i4) =
assert_norm (6579 < pow2 13);
assert_norm (pow2 13 < max51);
let tmp0, c0 = carry51_wide #6579 i0 (u64 0) in
let tmp1, c1 = carry51_wide #4797 i1 c0 in
let tmp2, c2 = carry51_wide #3340 i2 c1 in
let tmp3, c3 = carry51_wide #1881 i3 c2 in
let tmp4, c4 = carry51_wide #423 i4 c3 in
lemma_carry5_simplify c0 c1 c2 c3 c4 tmp0 tmp1 tmp2 tmp3 tmp4;
let tmp0', c5 = carry51 tmp0 (c4 *! u64 19) in
[@inline_let]
let tmp1' = tmp1 +! c5 in
lemma_mul_inv (tmp0', tmp1, tmp2, tmp3, tmp4) c5;
(tmp0', tmp1', tmp2, tmp3, tmp4)
#pop-options
inline_for_extraction noextract
val fmul5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\
feval out == fmul (feval f1) (feval f2)}
let fmul5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let (tmp0, tmp1, tmp2, tmp3, tmp4) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp0, tmp1, tmp2, tmp3, tmp4) in
carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)
inline_for_extraction noextract
val fmul25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> f3:felem5{felem_fits5 f3 (9, 10, 9, 9, 9)}
-> f4:felem5{felem_fits5 f4 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\ mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f2) /\
feval out2 == fmul (feval f3) (feval f4))
let fmul25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) =
let (tmp10, tmp11, tmp12, tmp13, tmp14) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp20, tmp21, tmp22, tmp23, tmp24) = precomp_r19 (f40, f41, f42, f43, f44) in
let (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp10, tmp11, tmp12, tmp13, tmp14) in
let (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) =
mul_felem5 (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) (tmp20, tmp21, tmp22, tmp23, tmp24) in
let (o10,o11,o12,o13,o14) = carry_wide5 (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) in
let (o20,o21,o22,o23,o24) = carry_wide5 (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) in
((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24))
inline_for_extraction noextract
val fmul15:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:uint64{felem_fits1 f2 1}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == (feval f1 * v f2) % prime)
let fmul15 (f10, f11, f12, f13, f14) f2 =
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
smul_felem5 #1 #(9, 10, 9, 9, 9) f2 (f10, f11, f12, f13, f14) in
let out = (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
[@inline_let]
let res = carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
FStar.Math.Lemmas.lemma_mod_mul_distr_l (as_nat5 (f10, f11, f12, f13, f14)) (uint_v f2) prime;
assert (feval res == feval_wide (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4));
assert (feval res == (wide_as_nat5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)) % prime);
assert (feval res == (v f2 * as_nat5 (f10, f11, f12, f13, f14)) % prime);
FStar.Math.Lemmas.swap_mul (v f2) (as_nat5 (f10, f11, f12, f13, f14));
assert (feval res == (as_nat5 (f10, f11, f12, f13, f14) * v f2) % prime);
res
// inline_for_extraction noextract
// val fsqr_felem5:
// f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
// -> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423)}
// let fsqr_felem5 (f0, f1, f2, f3, f4) =
// let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 20, 18, 18, 18) f0 (f0, u64 2 *! f1, u64 2 *! f2, u64 2 *! f3, u64 2 *! f4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(342, 0, 10, 18, 18) #(81, 180, 162, 162, 162)
// f1 (u64 38 *! f4, u64 0, f1, u64 2 *! f2, u64 2 *! f3) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(342, 342, 0, 0, 9) #(3501, 180, 262, 342, 342)
// f2 (u64 38 *! f3, u64 38 *! f4, u64 0, u64 0, f2) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(0, 171, 342, 0, 0) #(6579, 3258, 262, 342, 423)
// f3 (u64 0, u64 19 *. f3, u64 38 *. f4, u64 0, u64 0) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(0, 0, 0, 171, 0) #(6579, 4797, 3340, 342, 423)
// f4 (u64 0, u64 0, u64 0, u64 19 *. f4, u64 0) (o0, o1, o2, o3, o4) in
// (o0, o1, o2, o3, o4)
inline_for_extraction noextract
val mul64_wide_add3:
#m0:scale64 -> #m1:scale64 -> #m2:scale64
-> #m3:scale64 -> #m4:scale64 -> #m5:scale64
-> a0:uint64{felem_fits1 a0 m0}
-> a1:uint64{felem_fits1 a1 m1}
-> b0:uint64{felem_fits1 b0 m2}
-> b1:uint64{felem_fits1 b1 m3}
-> c0:uint64{felem_fits1 c0 m4}
-> c1:uint64{felem_fits1 c1 m5} ->
Pure uint128
(requires m0 * m1 + m2 * m3 + m4 * m5 < 8192)
(ensures fun res ->
felem_wide_fits1 res (m0 * m1 + m2 * m3 + m4 * m5) /\
v res == v a0 * v a1 + v b0 * v b1 + v c0 * v c1)
let mul64_wide_add3 #m0 #m1 #m2 #m3 #m4 #m5 a0 a1 b0 b1 c0 c1 =
assert_norm (pow2 13 = 8192);
mul64_wide_add3_lemma #m0 #m1 #m2 #m3 #m4 #m5 a0 a1 b0 b1 c0 c1;
mul64_wide a0 a1 +! mul64_wide b0 b1 +! mul64_wide c0 c1
inline_for_extraction noextract
val fsqr_felem5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> Pure felem_wide5
(requires True)
(ensures fun out ->
felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f) (feval f))
let fsqr_felem5 (f0, f1, f2, f3, f4) =
assert_norm (pow2 13 = 8192);
let d0 = u64 2 *! f0 in
let d1 = u64 2 *! f1 in
let d2 = u64 38 *! f2 in
let d3 = u64 19 *! f3 in
let d419 = u64 19 *! f4 in
let d4 = u64 2 *! d419 in
let s0 = mul64_wide_add3 #9 #9 #342 #10 #342 #9 f0 f0 d4 f1 d2 f3 in
let s1 = mul64_wide_add3 #18 #10 #342 #9 #171 #9 d0 f1 d4 f2 d3 f3 in
let s2 = mul64_wide_add3 #18 #9 #10 #10 #342 #9 d0 f2 f1 f1 d4 f3 in
let s3 = mul64_wide_add3 #18 #9 #20 #9 #9 #171 d0 f3 d1 f2 f4 d419 in
let s4 = mul64_wide_add3 #18 #9 #20 #9 #9 #9 d0 f4 d1 f3 f2 f2 in
lemma_fmul_fsqr5 (f0, f1, f2, f3, f4);
(s0, s1, s2, s3, s4)
inline_for_extraction noextract
val fsqr5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\ feval out == fmul (feval f) (feval f)}
let fsqr5 (f0, f1, f2, f3, f4) =
let (o0, o1, o2, o3, o4) = fsqr_felem5 (f0, f1, f2, f3, f4) in
carry_wide5 (o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsqr25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\
mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f1) /\ | false | false | Hacl.Spec.Curve25519.Field51.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 fsqr25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\
mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f1) /\
feval out2 == fmul (feval f2) (feval f2)) | [] | Hacl.Spec.Curve25519.Field51.fsqr25 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f1:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f1 (9, 10, 9, 9, 9)} ->
f2:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f2 (9, 10, 9, 9, 9)}
-> Prims.Pure
(Hacl.Spec.Curve25519.Field51.Definition.felem5 * Hacl.Spec.Curve25519.Field51.Definition.felem5
) | {
"end_col": 56,
"end_line": 434,
"start_col": 64,
"start_line": 429
} |
Prims.Tot | val fmul5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\
feval out == fmul (feval f1) (feval f2)} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 fmul5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let (tmp0, tmp1, tmp2, tmp3, tmp4) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp0, tmp1, tmp2, tmp3, tmp4) in
carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) | val fmul5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\
feval out == fmul (feval f1) (feval f2)}
let fmul5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) = | false | null | false | let tmp0, tmp1, tmp2, tmp3, tmp4 = precomp_r19 (f20, f21, f22, f23, f24) in
let tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4 =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp0, tmp1, tmp2, tmp3, tmp4)
in
carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.uint64",
"Lib.IntTypes.uint128",
"Hacl.Spec.Curve25519.Field51.carry_wide5",
"Prims.l_and",
"Hacl.Spec.Curve25519.Field51.mul_inv_t",
"Prims.eq2",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval",
"Spec.Curve25519.fmul",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits5",
"Hacl.Spec.Curve25519.Field51.Definition.feval_wide",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.Curve25519.Field51.mul_felem5",
"Hacl.Spec.Curve25519.Field51.precomp_r19"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul)
inline_for_extraction noextract
val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1))
let carry51_wide #m l cin =
let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul))
let mul_inv_t (f:felem5) =
let (o0, o1, o2, o3, o4) = f in
if v o1 >= pow2 51 then
felem_fits5 f (1, 2, 1, 1, 1) /\ v o1 % pow2 51 < 8192
else felem_fits5 f (1, 1, 1, 1, 1)
#push-options "--ifuel 1"
val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1))
let lemma_mul_inv f cin =
assert_norm (pow51 = pow2 51)
#pop-options
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val carry_wide5:
inp:felem_wide5{felem_wide_fits5 inp (6579, 4797, 3340, 1881, 423)}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == feval_wide inp)
let carry_wide5 (i0, i1, i2, i3, i4) =
assert_norm (6579 < pow2 13);
assert_norm (pow2 13 < max51);
let tmp0, c0 = carry51_wide #6579 i0 (u64 0) in
let tmp1, c1 = carry51_wide #4797 i1 c0 in
let tmp2, c2 = carry51_wide #3340 i2 c1 in
let tmp3, c3 = carry51_wide #1881 i3 c2 in
let tmp4, c4 = carry51_wide #423 i4 c3 in
lemma_carry5_simplify c0 c1 c2 c3 c4 tmp0 tmp1 tmp2 tmp3 tmp4;
let tmp0', c5 = carry51 tmp0 (c4 *! u64 19) in
[@inline_let]
let tmp1' = tmp1 +! c5 in
lemma_mul_inv (tmp0', tmp1, tmp2, tmp3, tmp4) c5;
(tmp0', tmp1', tmp2, tmp3, tmp4)
#pop-options
inline_for_extraction noextract
val fmul5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\ | false | false | Hacl.Spec.Curve25519.Field51.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 fmul5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\
feval out == fmul (feval f1) (feval f2)} | [] | Hacl.Spec.Curve25519.Field51.fmul5 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f1:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f1 (9, 10, 9, 9, 9)} ->
f2:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{ Hacl.Spec.Curve25519.Field51.mul_inv_t out /\
Hacl.Spec.Curve25519.Field51.Definition.feval out ==
Spec.Curve25519.fmul (Hacl.Spec.Curve25519.Field51.Definition.feval f1)
(Hacl.Spec.Curve25519.Field51.Definition.feval f2) } | {
"end_col": 54,
"end_line": 295,
"start_col": 63,
"start_line": 291
} |
Prims.Tot | val fsqr5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\ feval out == fmul (feval f) (feval f)} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 fsqr5 (f0, f1, f2, f3, f4) =
let (o0, o1, o2, o3, o4) = fsqr_felem5 (f0, f1, f2, f3, f4) in
carry_wide5 (o0, o1, o2, o3, o4) | val fsqr5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\ feval out == fmul (feval f) (feval f)}
let fsqr5 (f0, f1, f2, f3, f4) = | false | null | false | let o0, o1, o2, o3, o4 = fsqr_felem5 (f0, f1, f2, f3, f4) in
carry_wide5 (o0, o1, o2, o3, o4) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Lib.IntTypes.uint128",
"Hacl.Spec.Curve25519.Field51.carry_wide5",
"Prims.l_and",
"Hacl.Spec.Curve25519.Field51.mul_inv_t",
"Prims.eq2",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval",
"Spec.Curve25519.fmul",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide5",
"Hacl.Spec.Curve25519.Field51.fsqr_felem5"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul)
inline_for_extraction noextract
val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1))
let carry51_wide #m l cin =
let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul))
let mul_inv_t (f:felem5) =
let (o0, o1, o2, o3, o4) = f in
if v o1 >= pow2 51 then
felem_fits5 f (1, 2, 1, 1, 1) /\ v o1 % pow2 51 < 8192
else felem_fits5 f (1, 1, 1, 1, 1)
#push-options "--ifuel 1"
val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1))
let lemma_mul_inv f cin =
assert_norm (pow51 = pow2 51)
#pop-options
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val carry_wide5:
inp:felem_wide5{felem_wide_fits5 inp (6579, 4797, 3340, 1881, 423)}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == feval_wide inp)
let carry_wide5 (i0, i1, i2, i3, i4) =
assert_norm (6579 < pow2 13);
assert_norm (pow2 13 < max51);
let tmp0, c0 = carry51_wide #6579 i0 (u64 0) in
let tmp1, c1 = carry51_wide #4797 i1 c0 in
let tmp2, c2 = carry51_wide #3340 i2 c1 in
let tmp3, c3 = carry51_wide #1881 i3 c2 in
let tmp4, c4 = carry51_wide #423 i4 c3 in
lemma_carry5_simplify c0 c1 c2 c3 c4 tmp0 tmp1 tmp2 tmp3 tmp4;
let tmp0', c5 = carry51 tmp0 (c4 *! u64 19) in
[@inline_let]
let tmp1' = tmp1 +! c5 in
lemma_mul_inv (tmp0', tmp1, tmp2, tmp3, tmp4) c5;
(tmp0', tmp1', tmp2, tmp3, tmp4)
#pop-options
inline_for_extraction noextract
val fmul5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\
feval out == fmul (feval f1) (feval f2)}
let fmul5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let (tmp0, tmp1, tmp2, tmp3, tmp4) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp0, tmp1, tmp2, tmp3, tmp4) in
carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)
inline_for_extraction noextract
val fmul25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> f3:felem5{felem_fits5 f3 (9, 10, 9, 9, 9)}
-> f4:felem5{felem_fits5 f4 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\ mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f2) /\
feval out2 == fmul (feval f3) (feval f4))
let fmul25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) =
let (tmp10, tmp11, tmp12, tmp13, tmp14) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp20, tmp21, tmp22, tmp23, tmp24) = precomp_r19 (f40, f41, f42, f43, f44) in
let (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp10, tmp11, tmp12, tmp13, tmp14) in
let (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) =
mul_felem5 (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) (tmp20, tmp21, tmp22, tmp23, tmp24) in
let (o10,o11,o12,o13,o14) = carry_wide5 (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) in
let (o20,o21,o22,o23,o24) = carry_wide5 (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) in
((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24))
inline_for_extraction noextract
val fmul15:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:uint64{felem_fits1 f2 1}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == (feval f1 * v f2) % prime)
let fmul15 (f10, f11, f12, f13, f14) f2 =
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
smul_felem5 #1 #(9, 10, 9, 9, 9) f2 (f10, f11, f12, f13, f14) in
let out = (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
[@inline_let]
let res = carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
FStar.Math.Lemmas.lemma_mod_mul_distr_l (as_nat5 (f10, f11, f12, f13, f14)) (uint_v f2) prime;
assert (feval res == feval_wide (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4));
assert (feval res == (wide_as_nat5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)) % prime);
assert (feval res == (v f2 * as_nat5 (f10, f11, f12, f13, f14)) % prime);
FStar.Math.Lemmas.swap_mul (v f2) (as_nat5 (f10, f11, f12, f13, f14));
assert (feval res == (as_nat5 (f10, f11, f12, f13, f14) * v f2) % prime);
res
// inline_for_extraction noextract
// val fsqr_felem5:
// f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
// -> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423)}
// let fsqr_felem5 (f0, f1, f2, f3, f4) =
// let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 20, 18, 18, 18) f0 (f0, u64 2 *! f1, u64 2 *! f2, u64 2 *! f3, u64 2 *! f4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(342, 0, 10, 18, 18) #(81, 180, 162, 162, 162)
// f1 (u64 38 *! f4, u64 0, f1, u64 2 *! f2, u64 2 *! f3) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(342, 342, 0, 0, 9) #(3501, 180, 262, 342, 342)
// f2 (u64 38 *! f3, u64 38 *! f4, u64 0, u64 0, f2) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(0, 171, 342, 0, 0) #(6579, 3258, 262, 342, 423)
// f3 (u64 0, u64 19 *. f3, u64 38 *. f4, u64 0, u64 0) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(0, 0, 0, 171, 0) #(6579, 4797, 3340, 342, 423)
// f4 (u64 0, u64 0, u64 0, u64 19 *. f4, u64 0) (o0, o1, o2, o3, o4) in
// (o0, o1, o2, o3, o4)
inline_for_extraction noextract
val mul64_wide_add3:
#m0:scale64 -> #m1:scale64 -> #m2:scale64
-> #m3:scale64 -> #m4:scale64 -> #m5:scale64
-> a0:uint64{felem_fits1 a0 m0}
-> a1:uint64{felem_fits1 a1 m1}
-> b0:uint64{felem_fits1 b0 m2}
-> b1:uint64{felem_fits1 b1 m3}
-> c0:uint64{felem_fits1 c0 m4}
-> c1:uint64{felem_fits1 c1 m5} ->
Pure uint128
(requires m0 * m1 + m2 * m3 + m4 * m5 < 8192)
(ensures fun res ->
felem_wide_fits1 res (m0 * m1 + m2 * m3 + m4 * m5) /\
v res == v a0 * v a1 + v b0 * v b1 + v c0 * v c1)
let mul64_wide_add3 #m0 #m1 #m2 #m3 #m4 #m5 a0 a1 b0 b1 c0 c1 =
assert_norm (pow2 13 = 8192);
mul64_wide_add3_lemma #m0 #m1 #m2 #m3 #m4 #m5 a0 a1 b0 b1 c0 c1;
mul64_wide a0 a1 +! mul64_wide b0 b1 +! mul64_wide c0 c1
inline_for_extraction noextract
val fsqr_felem5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> Pure felem_wide5
(requires True)
(ensures fun out ->
felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f) (feval f))
let fsqr_felem5 (f0, f1, f2, f3, f4) =
assert_norm (pow2 13 = 8192);
let d0 = u64 2 *! f0 in
let d1 = u64 2 *! f1 in
let d2 = u64 38 *! f2 in
let d3 = u64 19 *! f3 in
let d419 = u64 19 *! f4 in
let d4 = u64 2 *! d419 in
let s0 = mul64_wide_add3 #9 #9 #342 #10 #342 #9 f0 f0 d4 f1 d2 f3 in
let s1 = mul64_wide_add3 #18 #10 #342 #9 #171 #9 d0 f1 d4 f2 d3 f3 in
let s2 = mul64_wide_add3 #18 #9 #10 #10 #342 #9 d0 f2 f1 f1 d4 f3 in
let s3 = mul64_wide_add3 #18 #9 #20 #9 #9 #171 d0 f3 d1 f2 f4 d419 in
let s4 = mul64_wide_add3 #18 #9 #20 #9 #9 #9 d0 f4 d1 f3 f2 f2 in
lemma_fmul_fsqr5 (f0, f1, f2, f3, f4);
(s0, s1, s2, s3, s4)
inline_for_extraction noextract
val fsqr5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)} | false | false | Hacl.Spec.Curve25519.Field51.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 fsqr5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\ feval out == fmul (feval f) (feval f)} | [] | Hacl.Spec.Curve25519.Field51.fsqr5 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f (9, 10, 9, 9, 9)}
-> out:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{ Hacl.Spec.Curve25519.Field51.mul_inv_t out /\
Hacl.Spec.Curve25519.Field51.Definition.feval out ==
Spec.Curve25519.fmul (Hacl.Spec.Curve25519.Field51.Definition.feval f)
(Hacl.Spec.Curve25519.Field51.Definition.feval f) } | {
"end_col": 34,
"end_line": 416,
"start_col": 32,
"start_line": 414
} |
Prims.Tot | val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194) | val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) = | false | null | false | [@@ inline_let ]let r190 = f20 *! u64 19 in
[@@ inline_let ]let r191 = f21 *! u64 19 in
[@@ inline_let ]let r192 = f22 *! u64 19 in
[@@ inline_let ]let r193 = f23 *! u64 19 in
[@@ inline_let ]let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.u64"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)} | false | false | Hacl.Spec.Curve25519.Field51.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 precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)} | [] | Hacl.Spec.Curve25519.Field51.precomp_r19 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f2:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 r19 (171, 190, 171, 171, 171)} | {
"end_col": 32,
"end_line": 186,
"start_col": 2,
"start_line": 176
} |
Prims.Pure | val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul) | val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin = | false | null | false | let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [] | [
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.Curve25519.Field51.Definition.mask51",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Lemmas.lemma_carry51",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Plus_Bang",
"FStar.Pervasives.Native.tuple2"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\ | false | false | Hacl.Spec.Curve25519.Field51.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 carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13) | [] | Hacl.Spec.Curve25519.Field51.carry51 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l: Lib.IntTypes.uint64 -> cin: Lib.IntTypes.uint64
-> Prims.Pure (Lib.IntTypes.uint64 * Lib.IntTypes.uint64) | {
"end_col": 29,
"end_line": 220,
"start_col": 19,
"start_line": 217
} |
Prims.Tot | val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out | val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) = | false | null | false | let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l (as_nat5 (f10, f11, f12, f13, f14))
(as_nat5 (f20, f21, f22, f23, f24))
prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r ((as_nat5 (f10, f11, f12, f13, f14)) % prime)
(as_nat5 (f20, f21, f22, f23, f24))
prime;
out | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.uint64",
"Prims.unit",
"FStar.Math.Lemmas.lemma_mod_plus_distr_r",
"Prims.op_Modulus",
"Hacl.Spec.Curve25519.Field51.Definition.as_nat5",
"Spec.Curve25519.prime",
"FStar.Math.Lemmas.lemma_mod_plus_distr_l",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Bang",
"Prims.l_and",
"Prims.eq2",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval",
"Spec.Curve25519.fadd"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\ | false | false | Hacl.Spec.Curve25519.Field51.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 fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)} | [] | Hacl.Spec.Curve25519.Field51.fadd5 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f1:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f1 (1, 2, 1, 1, 1)} ->
f2:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{ Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 out (2, 4, 2, 2, 2) /\
Hacl.Spec.Curve25519.Field51.Definition.feval out ==
Spec.Curve25519.fadd (Hacl.Spec.Curve25519.Field51.Definition.feval f1)
(Hacl.Spec.Curve25519.Field51.Definition.feval f2) } | {
"end_col": 5,
"end_line": 30,
"start_col": 63,
"start_line": 19
} |
Prims.Tot | val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4) | val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) = | false | null | false | let o0, o1, o2, o3, o4 = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let o0, o1, o2, o3, o4 =
smul_add_felem5 #10
#(171, 9, 10, 9, 9)
#(81, 90, 81, 81, 81)
f11
(r194, r0, r1, r2, r3)
(o0, o1, o2, o3, o4)
in
let o0, o1, o2, o3, o4 =
smul_add_felem5 #9
#(171, 171, 9, 10, 9)
#(1791, 180, 181, 171, 171)
f12
(r193, r194, r0, r1, r2)
(o0, o1, o2, o3, o4)
in
let o0, o1, o2, o3, o4 =
smul_add_felem5 #9
#(171, 171, 171, 9, 10)
#(3330, 1719, 262, 261, 252)
f13
(r192, r193, r194, r0, r1)
(o0, o1, o2, o3, o4)
in
let o0, o1, o2, o3, o4 =
smul_add_felem5 #9
#(190, 171, 171, 171, 9)
#(4869, 3258, 1801, 342, 342)
f14
(r191, r192, r193, r194, r0)
(o0, o1, o2, o3, o4)
in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.l_and",
"Prims.eq2",
"Hacl.Spec.Curve25519.Field51.precomp_r19",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.uint64",
"Lib.IntTypes.uint128",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Lemmas.lemma_fmul5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits5",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval_wide",
"Spec.Curve25519.fmul",
"Hacl.Spec.Curve25519.Field51.Definition.feval",
"Prims.int",
"Hacl.Spec.Curve25519.Field51.Definition.wide_as_nat5",
"Prims.op_Addition",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U128",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Hacl.Spec.Curve25519.Field51.Definition.as_nat5",
"Hacl.Spec.Curve25519.Field51.Definition.op_Plus_Star",
"Hacl.Spec.Curve25519.Field51.Definition.op_Star_Hat",
"Hacl.Spec.Curve25519.Field51.smul_add_felem5",
"Hacl.Spec.Curve25519.Field51.smul_felem5"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\ | false | false | Hacl.Spec.Curve25519.Field51.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 mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)} | [] | Hacl.Spec.Curve25519.Field51.mul_felem5 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f1:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f1 (9, 10, 9, 9, 9)} ->
r:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 r (9, 10, 9, 9, 9)} ->
r19:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{ Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 r19 (171, 190, 171, 171, 171) /\
r19 == Hacl.Spec.Curve25519.Field51.precomp_r19 r }
-> out:
Hacl.Spec.Curve25519.Field51.Definition.felem_wide5
{ Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
Hacl.Spec.Curve25519.Field51.Definition.feval_wide out ==
Spec.Curve25519.fmul (Hacl.Spec.Curve25519.Field51.Definition.feval f1)
(Hacl.Spec.Curve25519.Field51.Definition.feval r) } | {
"end_col": 22,
"end_line": 206,
"start_col": 94,
"start_line": 195
} |
Prims.Pure | val fmul25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> f3:felem5{felem_fits5 f3 (9, 10, 9, 9, 9)}
-> f4:felem5{felem_fits5 f4 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\ mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f2) /\
feval out2 == fmul (feval f3) (feval f4)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 fmul25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) =
let (tmp10, tmp11, tmp12, tmp13, tmp14) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp20, tmp21, tmp22, tmp23, tmp24) = precomp_r19 (f40, f41, f42, f43, f44) in
let (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp10, tmp11, tmp12, tmp13, tmp14) in
let (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) =
mul_felem5 (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) (tmp20, tmp21, tmp22, tmp23, tmp24) in
let (o10,o11,o12,o13,o14) = carry_wide5 (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) in
let (o20,o21,o22,o23,o24) = carry_wide5 (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) in
((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24)) | val fmul25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> f3:felem5{felem_fits5 f3 (9, 10, 9, 9, 9)}
-> f4:felem5{felem_fits5 f4 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\ mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f2) /\
feval out2 == fmul (feval f3) (feval f4))
let fmul25
(f10, f11, f12, f13, f14)
(f20, f21, f22, f23, f24)
(f30, f31, f32, f33, f34)
(f40, f41, f42, f43, f44)
= | false | null | false | let tmp10, tmp11, tmp12, tmp13, tmp14 = precomp_r19 (f20, f21, f22, f23, f24) in
let tmp20, tmp21, tmp22, tmp23, tmp24 = precomp_r19 (f40, f41, f42, f43, f44) in
let tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14 =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp10, tmp11, tmp12, tmp13, tmp14)
in
let tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24 =
mul_felem5 (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) (tmp20, tmp21, tmp22, tmp23, tmp24)
in
let o10, o11, o12, o13, o14 = carry_wide5 (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) in
let o20, o21, o22, o23, o24 = carry_wide5 (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) in
((o10, o11, o12, o13, o14), (o20, o21, o22, o23, o24)) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple4",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.uint64",
"Lib.IntTypes.uint128",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Curve25519.Field51.carry_wide5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide5",
"Prims.l_and",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits5",
"Prims.eq2",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval_wide",
"Spec.Curve25519.fmul",
"Hacl.Spec.Curve25519.Field51.Definition.feval",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.Curve25519.Field51.mul_felem5",
"Hacl.Spec.Curve25519.Field51.precomp_r19"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul)
inline_for_extraction noextract
val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1))
let carry51_wide #m l cin =
let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul))
let mul_inv_t (f:felem5) =
let (o0, o1, o2, o3, o4) = f in
if v o1 >= pow2 51 then
felem_fits5 f (1, 2, 1, 1, 1) /\ v o1 % pow2 51 < 8192
else felem_fits5 f (1, 1, 1, 1, 1)
#push-options "--ifuel 1"
val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1))
let lemma_mul_inv f cin =
assert_norm (pow51 = pow2 51)
#pop-options
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val carry_wide5:
inp:felem_wide5{felem_wide_fits5 inp (6579, 4797, 3340, 1881, 423)}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == feval_wide inp)
let carry_wide5 (i0, i1, i2, i3, i4) =
assert_norm (6579 < pow2 13);
assert_norm (pow2 13 < max51);
let tmp0, c0 = carry51_wide #6579 i0 (u64 0) in
let tmp1, c1 = carry51_wide #4797 i1 c0 in
let tmp2, c2 = carry51_wide #3340 i2 c1 in
let tmp3, c3 = carry51_wide #1881 i3 c2 in
let tmp4, c4 = carry51_wide #423 i4 c3 in
lemma_carry5_simplify c0 c1 c2 c3 c4 tmp0 tmp1 tmp2 tmp3 tmp4;
let tmp0', c5 = carry51 tmp0 (c4 *! u64 19) in
[@inline_let]
let tmp1' = tmp1 +! c5 in
lemma_mul_inv (tmp0', tmp1, tmp2, tmp3, tmp4) c5;
(tmp0', tmp1', tmp2, tmp3, tmp4)
#pop-options
inline_for_extraction noextract
val fmul5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\
feval out == fmul (feval f1) (feval f2)}
let fmul5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let (tmp0, tmp1, tmp2, tmp3, tmp4) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp0, tmp1, tmp2, tmp3, tmp4) in
carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)
inline_for_extraction noextract
val fmul25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> f3:felem5{felem_fits5 f3 (9, 10, 9, 9, 9)}
-> f4:felem5{felem_fits5 f4 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\ mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f2) /\ | false | false | Hacl.Spec.Curve25519.Field51.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 fmul25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> f3:felem5{felem_fits5 f3 (9, 10, 9, 9, 9)}
-> f4:felem5{felem_fits5 f4 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\ mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f2) /\
feval out2 == fmul (feval f3) (feval f4)) | [] | Hacl.Spec.Curve25519.Field51.fmul25 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f1:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f1 (9, 10, 9, 9, 9)} ->
f2:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f2 (9, 10, 9, 9, 9)} ->
f3:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f3 (9, 10, 9, 9, 9)} ->
f4:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f4 (9, 10, 9, 9, 9)}
-> Prims.Pure
(Hacl.Spec.Curve25519.Field51.Definition.felem5 * Hacl.Spec.Curve25519.Field51.Definition.felem5
) | {
"end_col": 48,
"end_line": 318,
"start_col": 116,
"start_line": 309
} |
Prims.Tot | val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4) | val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) = | false | null | false | let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Lemmas.lemma_add_zero",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.u64",
"Prims.l_and",
"Prims.eq2",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\ | false | false | Hacl.Spec.Curve25519.Field51.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 fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1} | [] | Hacl.Spec.Curve25519.Field51.fadd_zero | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f1:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{ Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 out (9, 10, 9, 9, 9) /\
Hacl.Spec.Curve25519.Field51.Definition.feval out ==
Hacl.Spec.Curve25519.Field51.Definition.feval f1 } | {
"end_col": 22,
"end_line": 44,
"start_col": 41,
"start_line": 37
} |
Prims.Tot | val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y | val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
let mul_wide64 #m1 #m2 x y = | false | null | false | let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51);
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51);
paren_mul_right (m1 * max51) m2 max51;
paren_mul_right m1 max51 m2;
swap_mul max51 m2;
paren_mul_right m1 m2 max51;
paren_mul_right (m1 * m2) max51 max51;
assert (v x * v y <= ((m1 * max51) * m2) * max51);
assert (v x * v y <= ((m1 * m2) * max51) * max51);
mul64_wide x y | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.scale64",
"Lib.IntTypes.uint64",
"Prims.b2t",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits1",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.mul64_wide",
"Prims.unit",
"Prims._assert",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.Curve25519.Field51.Definition.max51",
"FStar.Math.Lemmas.paren_mul_right",
"FStar.Math.Lemmas.swap_mul",
"FStar.Math.Lemmas.lemma_mult_le_right",
"FStar.Math.Lemmas.lemma_mult_le_left",
"Lib.IntTypes.uint128",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.uint_v",
"Lib.IntTypes.U128",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits1"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5" | false | false | Hacl.Spec.Curve25519.Field51.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)} | [] | Hacl.Spec.Curve25519.Field51.mul_wide64 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
x: Lib.IntTypes.uint64{Hacl.Spec.Curve25519.Field51.Definition.felem_fits1 x m1} ->
y:
Lib.IntTypes.uint64
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:
Lib.IntTypes.uint128
{ Lib.IntTypes.uint_v z == Lib.IntTypes.uint_v x * Lib.IntTypes.uint_v y /\
Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits1 z (m1 * m2) } | {
"end_col": 16,
"end_line": 100,
"start_col": 2,
"start_line": 90
} |
Prims.Tot | val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out | val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) = | false | null | false | let m20, m21, m22, m23, m24 = m2 in
[@@ inline_let ]let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@@ inline_let ]let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@@ inline_let ]let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@@ inline_let ]let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@@ inline_let ]let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@@ inline_let ]let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.scale64",
"Hacl.Spec.Curve25519.Field51.Definition.scale64_5",
"Lib.IntTypes.uint64",
"Prims.b2t",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits1",
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Prims.l_and",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"Hacl.Spec.Curve25519.Field51.Definition.op_Less_Equals_Star",
"Hacl.Spec.Curve25519.Field51.Definition.op_Star_Hat",
"Hacl.Spec.Curve25519.Field51.Definition.s128x5",
"Prims.nat",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Lemmas.lemma_smul_felem5",
"FStar.Pervasives.Native.Mktuple5",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U128",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint128",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.v",
"Prims.op_Multiply",
"Lib.IntTypes.U64",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits1",
"Hacl.Spec.Curve25519.Field51.mul_wide64",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits5",
"Hacl.Spec.Curve25519.Field51.Definition.wide_as_nat5",
"FStar.Mul.op_Star",
"Lib.IntTypes.uint_v",
"Hacl.Spec.Curve25519.Field51.Definition.as_nat5"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\ | false | false | Hacl.Spec.Curve25519.Field51.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 smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2} | [] | Hacl.Spec.Curve25519.Field51.smul_felem5 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
u1: Lib.IntTypes.uint64{Hacl.Spec.Curve25519.Field51.Definition.felem_fits1 u1 m1} ->
f2:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{ Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f2 m2 /\
m1 *^ m2 <=* Hacl.Spec.Curve25519.Field51.Definition.s128x5 67108864 }
-> out:
Hacl.Spec.Curve25519.Field51.Definition.felem_wide5
{ Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits5 out (m1 *^ m2) /\
Hacl.Spec.Curve25519.Field51.Definition.wide_as_nat5 out ==
Lib.IntTypes.uint_v u1 * Hacl.Spec.Curve25519.Field51.Definition.as_nat5 f2 } | {
"end_col": 5,
"end_line": 126,
"start_col": 54,
"start_line": 111
} |
Prims.Tot | val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out | val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) = | false | null | false | let t0, t1, t2, t3, t4 = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l (as_nat5 (t0, t1, t2, t3, t4))
(- as_nat5 (f20, f21, f22, f23, f24))
prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime)
(as_nat5 (f20, f21, f22, f23, f24))
prime;
out | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.uint64",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Lemmas.lemma_mod_sub_distr",
"Prims.op_Modulus",
"Hacl.Spec.Curve25519.Field51.Definition.as_nat5",
"Spec.Curve25519.prime",
"FStar.Math.Lemmas.lemma_mod_plus_distr_l",
"Prims.op_Minus",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Bang",
"Prims.l_and",
"Prims.eq2",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval",
"Spec.Curve25519.fsub",
"Hacl.Spec.Curve25519.Field51.fadd_zero"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\ | false | false | Hacl.Spec.Curve25519.Field51.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 fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)} | [] | Hacl.Spec.Curve25519.Field51.fsub5 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f1:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f1 (1, 2, 1, 1, 1)} ->
f2:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{ Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 out (9, 10, 9, 9, 9) /\
Hacl.Spec.Curve25519.Field51.Definition.feval out ==
Spec.Curve25519.fsub (Hacl.Spec.Curve25519.Field51.Definition.feval f1)
(Hacl.Spec.Curve25519.Field51.Definition.feval f2) } | {
"end_col": 5,
"end_line": 65,
"start_col": 63,
"start_line": 52
} |
Prims.Tot | val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y | val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z = | false | null | false | z +! mul_wide64 #m1 #m2 x y | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"total"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.scale64",
"Hacl.Spec.Curve25519.Field51.Definition.scale128",
"Lib.IntTypes.uint64",
"Prims.b2t",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits1",
"Lib.IntTypes.uint128",
"Prims.l_and",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits1",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U128",
"Lib.IntTypes.SEC",
"Hacl.Spec.Curve25519.Field51.mul_wide64",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.uint_v",
"Lib.IntTypes.U64"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)} | false | false | Hacl.Spec.Curve25519.Field51.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 mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)} | [] | Hacl.Spec.Curve25519.Field51.mul_add_wide128 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
x: Lib.IntTypes.uint64{Hacl.Spec.Curve25519.Field51.Definition.felem_fits1 x m1} ->
y: Lib.IntTypes.uint64{Hacl.Spec.Curve25519.Field51.Definition.felem_fits1 y m2} ->
z:
Lib.IntTypes.uint128
{Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:
Lib.IntTypes.uint128
{ Lib.IntTypes.uint_v r ==
Lib.IntTypes.uint_v z + Lib.IntTypes.uint_v x * Lib.IntTypes.uint_v y /\
Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits1 r (m3 + m1 * m2) } | {
"end_col": 29,
"end_line": 138,
"start_col": 2,
"start_line": 138
} |
Prims.Pure | val subtract_p5:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> Pure felem5
(requires True)
(ensures fun out ->
as_nat5 out == feval f /\
felem_fits5 out (1, 1, 1, 1, 1) /\
as_nat5 out < prime) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 subtract_p5 (f0, f1, f2, f3, f4) =
let m0 = gte_mask f0 (u64 0x7ffffffffffed) in
let m1 = eq_mask f1 (u64 0x7ffffffffffff) in
let m2 = eq_mask f2 (u64 0x7ffffffffffff) in
let m3 = eq_mask f3 (u64 0x7ffffffffffff) in
let m4 = eq_mask f4 (u64 0x7ffffffffffff) in
let mask = m0 &. m1 &. m2 &. m3 &. m4 in
let f0' = f0 -. (mask &. u64 0x7ffffffffffed) in
let f1' = f1 -. (mask &. u64 0x7ffffffffffff) in
let f2' = f2 -. (mask &. u64 0x7ffffffffffff) in
let f3' = f3 -. (mask &. u64 0x7ffffffffffff) in
let f4' = f4 -. (mask &. u64 0x7ffffffffffff) in
logand_lemma mask (u64 0x7ffffffffffed);
logand_lemma mask (u64 0x7ffffffffffff);
lemma_subtract_p (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4');
(f0', f1', f2', f3', f4') | val subtract_p5:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> Pure felem5
(requires True)
(ensures fun out ->
as_nat5 out == feval f /\
felem_fits5 out (1, 1, 1, 1, 1) /\
as_nat5 out < prime)
let subtract_p5 (f0, f1, f2, f3, f4) = | false | null | false | let m0 = gte_mask f0 (u64 0x7ffffffffffed) in
let m1 = eq_mask f1 (u64 0x7ffffffffffff) in
let m2 = eq_mask f2 (u64 0x7ffffffffffff) in
let m3 = eq_mask f3 (u64 0x7ffffffffffff) in
let m4 = eq_mask f4 (u64 0x7ffffffffffff) in
let mask = m0 &. m1 &. m2 &. m3 &. m4 in
let f0' = f0 -. (mask &. u64 0x7ffffffffffed) in
let f1' = f1 -. (mask &. u64 0x7ffffffffffff) in
let f2' = f2 -. (mask &. u64 0x7ffffffffffff) in
let f3' = f3 -. (mask &. u64 0x7ffffffffffff) in
let f4' = f4 -. (mask &. u64 0x7ffffffffffff) in
logand_lemma mask (u64 0x7ffffffffffed);
logand_lemma mask (u64 0x7ffffffffffff);
lemma_subtract_p (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4');
(f0', f1', f2', f3', f4') | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Lemmas.lemma_subtract_p",
"Lib.IntTypes.logand_lemma",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.u64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.eq_mask",
"Lib.IntTypes.gte_mask"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul)
inline_for_extraction noextract
val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1))
let carry51_wide #m l cin =
let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul))
let mul_inv_t (f:felem5) =
let (o0, o1, o2, o3, o4) = f in
if v o1 >= pow2 51 then
felem_fits5 f (1, 2, 1, 1, 1) /\ v o1 % pow2 51 < 8192
else felem_fits5 f (1, 1, 1, 1, 1)
#push-options "--ifuel 1"
val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1))
let lemma_mul_inv f cin =
assert_norm (pow51 = pow2 51)
#pop-options
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val carry_wide5:
inp:felem_wide5{felem_wide_fits5 inp (6579, 4797, 3340, 1881, 423)}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == feval_wide inp)
let carry_wide5 (i0, i1, i2, i3, i4) =
assert_norm (6579 < pow2 13);
assert_norm (pow2 13 < max51);
let tmp0, c0 = carry51_wide #6579 i0 (u64 0) in
let tmp1, c1 = carry51_wide #4797 i1 c0 in
let tmp2, c2 = carry51_wide #3340 i2 c1 in
let tmp3, c3 = carry51_wide #1881 i3 c2 in
let tmp4, c4 = carry51_wide #423 i4 c3 in
lemma_carry5_simplify c0 c1 c2 c3 c4 tmp0 tmp1 tmp2 tmp3 tmp4;
let tmp0', c5 = carry51 tmp0 (c4 *! u64 19) in
[@inline_let]
let tmp1' = tmp1 +! c5 in
lemma_mul_inv (tmp0', tmp1, tmp2, tmp3, tmp4) c5;
(tmp0', tmp1', tmp2, tmp3, tmp4)
#pop-options
inline_for_extraction noextract
val fmul5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\
feval out == fmul (feval f1) (feval f2)}
let fmul5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let (tmp0, tmp1, tmp2, tmp3, tmp4) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp0, tmp1, tmp2, tmp3, tmp4) in
carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)
inline_for_extraction noextract
val fmul25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> f3:felem5{felem_fits5 f3 (9, 10, 9, 9, 9)}
-> f4:felem5{felem_fits5 f4 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\ mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f2) /\
feval out2 == fmul (feval f3) (feval f4))
let fmul25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) =
let (tmp10, tmp11, tmp12, tmp13, tmp14) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp20, tmp21, tmp22, tmp23, tmp24) = precomp_r19 (f40, f41, f42, f43, f44) in
let (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp10, tmp11, tmp12, tmp13, tmp14) in
let (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) =
mul_felem5 (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) (tmp20, tmp21, tmp22, tmp23, tmp24) in
let (o10,o11,o12,o13,o14) = carry_wide5 (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) in
let (o20,o21,o22,o23,o24) = carry_wide5 (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) in
((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24))
inline_for_extraction noextract
val fmul15:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:uint64{felem_fits1 f2 1}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == (feval f1 * v f2) % prime)
let fmul15 (f10, f11, f12, f13, f14) f2 =
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
smul_felem5 #1 #(9, 10, 9, 9, 9) f2 (f10, f11, f12, f13, f14) in
let out = (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
[@inline_let]
let res = carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
FStar.Math.Lemmas.lemma_mod_mul_distr_l (as_nat5 (f10, f11, f12, f13, f14)) (uint_v f2) prime;
assert (feval res == feval_wide (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4));
assert (feval res == (wide_as_nat5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)) % prime);
assert (feval res == (v f2 * as_nat5 (f10, f11, f12, f13, f14)) % prime);
FStar.Math.Lemmas.swap_mul (v f2) (as_nat5 (f10, f11, f12, f13, f14));
assert (feval res == (as_nat5 (f10, f11, f12, f13, f14) * v f2) % prime);
res
// inline_for_extraction noextract
// val fsqr_felem5:
// f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
// -> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423)}
// let fsqr_felem5 (f0, f1, f2, f3, f4) =
// let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 20, 18, 18, 18) f0 (f0, u64 2 *! f1, u64 2 *! f2, u64 2 *! f3, u64 2 *! f4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(342, 0, 10, 18, 18) #(81, 180, 162, 162, 162)
// f1 (u64 38 *! f4, u64 0, f1, u64 2 *! f2, u64 2 *! f3) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(342, 342, 0, 0, 9) #(3501, 180, 262, 342, 342)
// f2 (u64 38 *! f3, u64 38 *! f4, u64 0, u64 0, f2) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(0, 171, 342, 0, 0) #(6579, 3258, 262, 342, 423)
// f3 (u64 0, u64 19 *. f3, u64 38 *. f4, u64 0, u64 0) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(0, 0, 0, 171, 0) #(6579, 4797, 3340, 342, 423)
// f4 (u64 0, u64 0, u64 0, u64 19 *. f4, u64 0) (o0, o1, o2, o3, o4) in
// (o0, o1, o2, o3, o4)
inline_for_extraction noextract
val mul64_wide_add3:
#m0:scale64 -> #m1:scale64 -> #m2:scale64
-> #m3:scale64 -> #m4:scale64 -> #m5:scale64
-> a0:uint64{felem_fits1 a0 m0}
-> a1:uint64{felem_fits1 a1 m1}
-> b0:uint64{felem_fits1 b0 m2}
-> b1:uint64{felem_fits1 b1 m3}
-> c0:uint64{felem_fits1 c0 m4}
-> c1:uint64{felem_fits1 c1 m5} ->
Pure uint128
(requires m0 * m1 + m2 * m3 + m4 * m5 < 8192)
(ensures fun res ->
felem_wide_fits1 res (m0 * m1 + m2 * m3 + m4 * m5) /\
v res == v a0 * v a1 + v b0 * v b1 + v c0 * v c1)
let mul64_wide_add3 #m0 #m1 #m2 #m3 #m4 #m5 a0 a1 b0 b1 c0 c1 =
assert_norm (pow2 13 = 8192);
mul64_wide_add3_lemma #m0 #m1 #m2 #m3 #m4 #m5 a0 a1 b0 b1 c0 c1;
mul64_wide a0 a1 +! mul64_wide b0 b1 +! mul64_wide c0 c1
inline_for_extraction noextract
val fsqr_felem5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> Pure felem_wide5
(requires True)
(ensures fun out ->
felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f) (feval f))
let fsqr_felem5 (f0, f1, f2, f3, f4) =
assert_norm (pow2 13 = 8192);
let d0 = u64 2 *! f0 in
let d1 = u64 2 *! f1 in
let d2 = u64 38 *! f2 in
let d3 = u64 19 *! f3 in
let d419 = u64 19 *! f4 in
let d4 = u64 2 *! d419 in
let s0 = mul64_wide_add3 #9 #9 #342 #10 #342 #9 f0 f0 d4 f1 d2 f3 in
let s1 = mul64_wide_add3 #18 #10 #342 #9 #171 #9 d0 f1 d4 f2 d3 f3 in
let s2 = mul64_wide_add3 #18 #9 #10 #10 #342 #9 d0 f2 f1 f1 d4 f3 in
let s3 = mul64_wide_add3 #18 #9 #20 #9 #9 #171 d0 f3 d1 f2 f4 d419 in
let s4 = mul64_wide_add3 #18 #9 #20 #9 #9 #9 d0 f4 d1 f3 f2 f2 in
lemma_fmul_fsqr5 (f0, f1, f2, f3, f4);
(s0, s1, s2, s3, s4)
inline_for_extraction noextract
val fsqr5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\ feval out == fmul (feval f) (feval f)}
let fsqr5 (f0, f1, f2, f3, f4) =
let (o0, o1, o2, o3, o4) = fsqr_felem5 (f0, f1, f2, f3, f4) in
carry_wide5 (o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsqr25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\
mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f1) /\
feval out2 == fmul (feval f2) (feval f2))
let fsqr25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let (o10, o11, o12, o13, o14) = fsqr_felem5 (f10, f11, f12, f13, f14) in
let (o20, o21, o22, o23, o24) = fsqr_felem5 (f20, f21, f22, f23, f24) in
let (o10, o11, o12, o13, o14) = carry_wide5 (o10, o11, o12, o13, o14) in
let (o20, o21, o22, o23, o24) = carry_wide5 (o20, o21, o22, o23, o24) in
((o10, o11, o12, o13, o14), (o20, o21, o22, o23, o24))
#set-options "--z3rlimit 100 --max_fuel 2"
inline_for_extraction noextract
val carry_felem5_full:
inp:felem5{mul_inv_t inp}
-> out:felem5{feval out == feval inp /\ felem_fits5 out (1, 1, 1, 1, 1)}
let carry_felem5_full (f0, f1, f2, f3, f4) =
assert_norm (pow51 = pow2 51);
let tmp0, c0 = carry51 f0 (u64 0) in
let tmp1, c1 = carry51 f1 c0 in
assert (if v f1 < pow2 51 then v tmp1 < pow2 51 else v tmp1 < 8192);
let tmp2, c2 = carry51 f2 c1 in
let tmp3, c3 = carry51 f3 c2 in
let tmp4, c4 = carry51 f4 c3 in
lemma_carry5_simplify c0 c1 c2 c3 c4 tmp0 tmp1 tmp2 tmp3 tmp4;
[@inline_let]
let tmp0', c5 = carry51 tmp0 (c4 *! u64 19) in
[@inline_let]
let tmp1' = tmp1 +! c5 in
(tmp0', tmp1', tmp2, tmp3, tmp4)
inline_for_extraction noextract
val subtract_p5:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> Pure felem5
(requires True)
(ensures fun out ->
as_nat5 out == feval f /\
felem_fits5 out (1, 1, 1, 1, 1) /\ | false | false | Hacl.Spec.Curve25519.Field51.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 2,
"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 subtract_p5:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> Pure felem5
(requires True)
(ensures fun out ->
as_nat5 out == feval f /\
felem_fits5 out (1, 1, 1, 1, 1) /\
as_nat5 out < prime) | [] | Hacl.Spec.Curve25519.Field51.subtract_p5 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f (1, 1, 1, 1, 1)}
-> Prims.Pure Hacl.Spec.Curve25519.Field51.Definition.felem5 | {
"end_col": 27,
"end_line": 481,
"start_col": 38,
"start_line": 466
} |
Prims.Pure | val fsqr_felem5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> Pure felem_wide5
(requires True)
(ensures fun out ->
felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f) (feval f)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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_felem5 (f0, f1, f2, f3, f4) =
assert_norm (pow2 13 = 8192);
let d0 = u64 2 *! f0 in
let d1 = u64 2 *! f1 in
let d2 = u64 38 *! f2 in
let d3 = u64 19 *! f3 in
let d419 = u64 19 *! f4 in
let d4 = u64 2 *! d419 in
let s0 = mul64_wide_add3 #9 #9 #342 #10 #342 #9 f0 f0 d4 f1 d2 f3 in
let s1 = mul64_wide_add3 #18 #10 #342 #9 #171 #9 d0 f1 d4 f2 d3 f3 in
let s2 = mul64_wide_add3 #18 #9 #10 #10 #342 #9 d0 f2 f1 f1 d4 f3 in
let s3 = mul64_wide_add3 #18 #9 #20 #9 #9 #171 d0 f3 d1 f2 f4 d419 in
let s4 = mul64_wide_add3 #18 #9 #20 #9 #9 #9 d0 f4 d1 f3 f2 f2 in
lemma_fmul_fsqr5 (f0, f1, f2, f3, f4);
(s0, s1, s2, s3, s4) | val fsqr_felem5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> Pure felem_wide5
(requires True)
(ensures fun out ->
felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f) (feval f))
let fsqr_felem5 (f0, f1, f2, f3, f4) = | false | null | false | assert_norm (pow2 13 = 8192);
let d0 = u64 2 *! f0 in
let d1 = u64 2 *! f1 in
let d2 = u64 38 *! f2 in
let d3 = u64 19 *! f3 in
let d419 = u64 19 *! f4 in
let d4 = u64 2 *! d419 in
let s0 = mul64_wide_add3 #9 #9 #342 #10 #342 #9 f0 f0 d4 f1 d2 f3 in
let s1 = mul64_wide_add3 #18 #10 #342 #9 #171 #9 d0 f1 d4 f2 d3 f3 in
let s2 = mul64_wide_add3 #18 #9 #10 #10 #342 #9 d0 f2 f1 f1 d4 f3 in
let s3 = mul64_wide_add3 #18 #9 #20 #9 #9 #171 d0 f3 d1 f2 f4 d419 in
let s4 = mul64_wide_add3 #18 #9 #20 #9 #9 #9 d0 f4 d1 f3 f2 f2 in
lemma_fmul_fsqr5 (f0, f1, f2, f3, f4);
(s0, s1, s2, s3, s4) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Lib.IntTypes.uint128",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Lemmas.lemma_fmul_fsqr5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U128",
"Lib.IntTypes.SEC",
"Hacl.Spec.Curve25519.Field51.mul64_wide_add3",
"Lib.IntTypes.U64",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.u64",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.pow2",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide5"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul)
inline_for_extraction noextract
val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1))
let carry51_wide #m l cin =
let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul))
let mul_inv_t (f:felem5) =
let (o0, o1, o2, o3, o4) = f in
if v o1 >= pow2 51 then
felem_fits5 f (1, 2, 1, 1, 1) /\ v o1 % pow2 51 < 8192
else felem_fits5 f (1, 1, 1, 1, 1)
#push-options "--ifuel 1"
val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1))
let lemma_mul_inv f cin =
assert_norm (pow51 = pow2 51)
#pop-options
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val carry_wide5:
inp:felem_wide5{felem_wide_fits5 inp (6579, 4797, 3340, 1881, 423)}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == feval_wide inp)
let carry_wide5 (i0, i1, i2, i3, i4) =
assert_norm (6579 < pow2 13);
assert_norm (pow2 13 < max51);
let tmp0, c0 = carry51_wide #6579 i0 (u64 0) in
let tmp1, c1 = carry51_wide #4797 i1 c0 in
let tmp2, c2 = carry51_wide #3340 i2 c1 in
let tmp3, c3 = carry51_wide #1881 i3 c2 in
let tmp4, c4 = carry51_wide #423 i4 c3 in
lemma_carry5_simplify c0 c1 c2 c3 c4 tmp0 tmp1 tmp2 tmp3 tmp4;
let tmp0', c5 = carry51 tmp0 (c4 *! u64 19) in
[@inline_let]
let tmp1' = tmp1 +! c5 in
lemma_mul_inv (tmp0', tmp1, tmp2, tmp3, tmp4) c5;
(tmp0', tmp1', tmp2, tmp3, tmp4)
#pop-options
inline_for_extraction noextract
val fmul5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\
feval out == fmul (feval f1) (feval f2)}
let fmul5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let (tmp0, tmp1, tmp2, tmp3, tmp4) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp0, tmp1, tmp2, tmp3, tmp4) in
carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)
inline_for_extraction noextract
val fmul25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> f3:felem5{felem_fits5 f3 (9, 10, 9, 9, 9)}
-> f4:felem5{felem_fits5 f4 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\ mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f2) /\
feval out2 == fmul (feval f3) (feval f4))
let fmul25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) =
let (tmp10, tmp11, tmp12, tmp13, tmp14) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp20, tmp21, tmp22, tmp23, tmp24) = precomp_r19 (f40, f41, f42, f43, f44) in
let (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp10, tmp11, tmp12, tmp13, tmp14) in
let (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) =
mul_felem5 (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) (tmp20, tmp21, tmp22, tmp23, tmp24) in
let (o10,o11,o12,o13,o14) = carry_wide5 (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) in
let (o20,o21,o22,o23,o24) = carry_wide5 (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) in
((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24))
inline_for_extraction noextract
val fmul15:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:uint64{felem_fits1 f2 1}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == (feval f1 * v f2) % prime)
let fmul15 (f10, f11, f12, f13, f14) f2 =
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
smul_felem5 #1 #(9, 10, 9, 9, 9) f2 (f10, f11, f12, f13, f14) in
let out = (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
[@inline_let]
let res = carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
FStar.Math.Lemmas.lemma_mod_mul_distr_l (as_nat5 (f10, f11, f12, f13, f14)) (uint_v f2) prime;
assert (feval res == feval_wide (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4));
assert (feval res == (wide_as_nat5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)) % prime);
assert (feval res == (v f2 * as_nat5 (f10, f11, f12, f13, f14)) % prime);
FStar.Math.Lemmas.swap_mul (v f2) (as_nat5 (f10, f11, f12, f13, f14));
assert (feval res == (as_nat5 (f10, f11, f12, f13, f14) * v f2) % prime);
res
// inline_for_extraction noextract
// val fsqr_felem5:
// f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
// -> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423)}
// let fsqr_felem5 (f0, f1, f2, f3, f4) =
// let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 20, 18, 18, 18) f0 (f0, u64 2 *! f1, u64 2 *! f2, u64 2 *! f3, u64 2 *! f4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(342, 0, 10, 18, 18) #(81, 180, 162, 162, 162)
// f1 (u64 38 *! f4, u64 0, f1, u64 2 *! f2, u64 2 *! f3) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(342, 342, 0, 0, 9) #(3501, 180, 262, 342, 342)
// f2 (u64 38 *! f3, u64 38 *! f4, u64 0, u64 0, f2) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(0, 171, 342, 0, 0) #(6579, 3258, 262, 342, 423)
// f3 (u64 0, u64 19 *. f3, u64 38 *. f4, u64 0, u64 0) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(0, 0, 0, 171, 0) #(6579, 4797, 3340, 342, 423)
// f4 (u64 0, u64 0, u64 0, u64 19 *. f4, u64 0) (o0, o1, o2, o3, o4) in
// (o0, o1, o2, o3, o4)
inline_for_extraction noextract
val mul64_wide_add3:
#m0:scale64 -> #m1:scale64 -> #m2:scale64
-> #m3:scale64 -> #m4:scale64 -> #m5:scale64
-> a0:uint64{felem_fits1 a0 m0}
-> a1:uint64{felem_fits1 a1 m1}
-> b0:uint64{felem_fits1 b0 m2}
-> b1:uint64{felem_fits1 b1 m3}
-> c0:uint64{felem_fits1 c0 m4}
-> c1:uint64{felem_fits1 c1 m5} ->
Pure uint128
(requires m0 * m1 + m2 * m3 + m4 * m5 < 8192)
(ensures fun res ->
felem_wide_fits1 res (m0 * m1 + m2 * m3 + m4 * m5) /\
v res == v a0 * v a1 + v b0 * v b1 + v c0 * v c1)
let mul64_wide_add3 #m0 #m1 #m2 #m3 #m4 #m5 a0 a1 b0 b1 c0 c1 =
assert_norm (pow2 13 = 8192);
mul64_wide_add3_lemma #m0 #m1 #m2 #m3 #m4 #m5 a0 a1 b0 b1 c0 c1;
mul64_wide a0 a1 +! mul64_wide b0 b1 +! mul64_wide c0 c1
inline_for_extraction noextract
val fsqr_felem5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> Pure felem_wide5
(requires True)
(ensures fun out ->
felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f) (feval f)) | false | false | Hacl.Spec.Curve25519.Field51.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 fsqr_felem5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> Pure felem_wide5
(requires True)
(ensures fun out ->
felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f) (feval f)) | [] | Hacl.Spec.Curve25519.Field51.fsqr_felem5 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f (9, 10, 9, 9, 9)}
-> Prims.Pure Hacl.Spec.Curve25519.Field51.Definition.felem_wide5 | {
"end_col": 22,
"end_line": 407,
"start_col": 2,
"start_line": 392
} |
Prims.Pure | val fmul15:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:uint64{felem_fits1 f2 1}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == (feval f1 * v f2) % prime) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 fmul15 (f10, f11, f12, f13, f14) f2 =
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
smul_felem5 #1 #(9, 10, 9, 9, 9) f2 (f10, f11, f12, f13, f14) in
let out = (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
[@inline_let]
let res = carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
FStar.Math.Lemmas.lemma_mod_mul_distr_l (as_nat5 (f10, f11, f12, f13, f14)) (uint_v f2) prime;
assert (feval res == feval_wide (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4));
assert (feval res == (wide_as_nat5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)) % prime);
assert (feval res == (v f2 * as_nat5 (f10, f11, f12, f13, f14)) % prime);
FStar.Math.Lemmas.swap_mul (v f2) (as_nat5 (f10, f11, f12, f13, f14));
assert (feval res == (as_nat5 (f10, f11, f12, f13, f14) * v f2) % prime);
res | val fmul15:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:uint64{felem_fits1 f2 1}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == (feval f1 * v f2) % prime)
let fmul15 (f10, f11, f12, f13, f14) f2 = | false | null | false | let tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4 =
smul_felem5 #1 #(9, 10, 9, 9, 9) f2 (f10, f11, f12, f13, f14)
in
let out = (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
[@@ inline_let ]let res = carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
FStar.Math.Lemmas.lemma_mod_mul_distr_l (as_nat5 (f10, f11, f12, f13, f14)) (uint_v f2) prime;
assert (feval res == feval_wide (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4));
assert (feval res == (wide_as_nat5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)) % prime);
assert (feval res == (v f2 * as_nat5 (f10, f11, f12, f13, f14)) % prime);
FStar.Math.Lemmas.swap_mul (v f2) (as_nat5 (f10, f11, f12, f13, f14));
assert (feval res == (as_nat5 (f10, f11, f12, f13, f14) * v f2) % prime);
res | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Prims.b2t",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits1",
"Lib.IntTypes.uint128",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.Curve25519.Field51.Definition.feval",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Hacl.Spec.Curve25519.Field51.Definition.as_nat5",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Spec.Curve25519.prime",
"FStar.Math.Lemmas.swap_mul",
"Hacl.Spec.Curve25519.Field51.Definition.wide_as_nat5",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval_wide",
"FStar.Math.Lemmas.lemma_mod_mul_distr_l",
"Lib.IntTypes.uint_v",
"Hacl.Spec.Curve25519.Field51.carry_wide5",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U128",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide5",
"Prims.l_and",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits5",
"Hacl.Spec.Curve25519.Field51.Definition.op_Star_Hat",
"Prims.op_Multiply",
"Hacl.Spec.Curve25519.Field51.smul_felem5"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul)
inline_for_extraction noextract
val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1))
let carry51_wide #m l cin =
let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul))
let mul_inv_t (f:felem5) =
let (o0, o1, o2, o3, o4) = f in
if v o1 >= pow2 51 then
felem_fits5 f (1, 2, 1, 1, 1) /\ v o1 % pow2 51 < 8192
else felem_fits5 f (1, 1, 1, 1, 1)
#push-options "--ifuel 1"
val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1))
let lemma_mul_inv f cin =
assert_norm (pow51 = pow2 51)
#pop-options
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val carry_wide5:
inp:felem_wide5{felem_wide_fits5 inp (6579, 4797, 3340, 1881, 423)}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == feval_wide inp)
let carry_wide5 (i0, i1, i2, i3, i4) =
assert_norm (6579 < pow2 13);
assert_norm (pow2 13 < max51);
let tmp0, c0 = carry51_wide #6579 i0 (u64 0) in
let tmp1, c1 = carry51_wide #4797 i1 c0 in
let tmp2, c2 = carry51_wide #3340 i2 c1 in
let tmp3, c3 = carry51_wide #1881 i3 c2 in
let tmp4, c4 = carry51_wide #423 i4 c3 in
lemma_carry5_simplify c0 c1 c2 c3 c4 tmp0 tmp1 tmp2 tmp3 tmp4;
let tmp0', c5 = carry51 tmp0 (c4 *! u64 19) in
[@inline_let]
let tmp1' = tmp1 +! c5 in
lemma_mul_inv (tmp0', tmp1, tmp2, tmp3, tmp4) c5;
(tmp0', tmp1', tmp2, tmp3, tmp4)
#pop-options
inline_for_extraction noextract
val fmul5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\
feval out == fmul (feval f1) (feval f2)}
let fmul5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let (tmp0, tmp1, tmp2, tmp3, tmp4) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp0, tmp1, tmp2, tmp3, tmp4) in
carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)
inline_for_extraction noextract
val fmul25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> f3:felem5{felem_fits5 f3 (9, 10, 9, 9, 9)}
-> f4:felem5{felem_fits5 f4 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\ mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f2) /\
feval out2 == fmul (feval f3) (feval f4))
let fmul25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) =
let (tmp10, tmp11, tmp12, tmp13, tmp14) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp20, tmp21, tmp22, tmp23, tmp24) = precomp_r19 (f40, f41, f42, f43, f44) in
let (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp10, tmp11, tmp12, tmp13, tmp14) in
let (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) =
mul_felem5 (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) (tmp20, tmp21, tmp22, tmp23, tmp24) in
let (o10,o11,o12,o13,o14) = carry_wide5 (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) in
let (o20,o21,o22,o23,o24) = carry_wide5 (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) in
((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24))
inline_for_extraction noextract
val fmul15:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:uint64{felem_fits1 f2 1}
-> Pure felem5
(requires True)
(ensures fun out -> | false | false | Hacl.Spec.Curve25519.Field51.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 fmul15:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:uint64{felem_fits1 f2 1}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == (feval f1 * v f2) % prime) | [] | Hacl.Spec.Curve25519.Field51.fmul15 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f1:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f1 (9, 10, 9, 9, 9)} ->
f2: Lib.IntTypes.uint64{Hacl.Spec.Curve25519.Field51.Definition.felem_fits1 f2 1}
-> Prims.Pure Hacl.Spec.Curve25519.Field51.Definition.felem5 | {
"end_col": 5,
"end_line": 342,
"start_col": 41,
"start_line": 328
} |
Prims.Pure | val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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 carry51_wide #m l cin =
let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul)) | val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1))
let carry51_wide #m l cin = | false | null | false | let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul)) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [] | [
"Hacl.Spec.Curve25519.Field51.Definition.scale64",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.uint128",
"Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits1",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.to_u64",
"Lib.IntTypes.U128",
"Hacl.Spec.Curve25519.Field51.Definition.mask51",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Lemmas.lemma_carry51_wide",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.to_u128",
"FStar.Pervasives.Native.tuple2"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul)
inline_for_extraction noextract
val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\ | false | false | Hacl.Spec.Curve25519.Field51.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 carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1)) | [] | Hacl.Spec.Curve25519.Field51.carry51_wide | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
l: Lib.IntTypes.uint128{Hacl.Spec.Curve25519.Field51.Definition.felem_wide_fits1 l m} ->
cin: Lib.IntTypes.uint64
-> Prims.Pure (Lib.IntTypes.uint64 * Lib.IntTypes.uint64) | {
"end_col": 47,
"end_line": 235,
"start_col": 27,
"start_line": 232
} |
Prims.Pure | val store_felem5:
f:felem5{mul_inv_t f}
-> Pure (uint64 & uint64 & uint64 & uint64)
(requires True)
(ensures fun (o0, o1, o2, o3) ->
feval f == v o0 + v o1 * pow2 64 +
v o2 * pow2 64 * pow2 64 + v o3 * pow2 64 * pow2 64 * pow2 64) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.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_felem5 (f0, f1, f2, f3, f4) =
let (f0, f1, f2, f3, f4) = carry_felem5_full (f0, f1, f2, f3, f4) in
let (f0, f1, f2, f3, f4) = subtract_p5 (f0, f1, f2, f3, f4) in
let o0 = f0 |. (f1 <<. 51ul) in
let o1 = (f1 >>. 13ul) |. (f2 <<. 38ul) in
let o2 = (f2 >>. 26ul) |. (f3 <<. 25ul) in
let o3 = (f3 >>. 39ul) |. (f4 <<. 12ul) in
lemma_store_felem (f0, f1, f2, f3, f4);
(o0, o1, o2, o3) | val store_felem5:
f:felem5{mul_inv_t f}
-> Pure (uint64 & uint64 & uint64 & uint64)
(requires True)
(ensures fun (o0, o1, o2, o3) ->
feval f == v o0 + v o1 * pow2 64 +
v o2 * pow2 64 * pow2 64 + v o3 * pow2 64 * pow2 64 * pow2 64)
let store_felem5 (f0, f1, f2, f3, f4) = | false | null | false | let f0, f1, f2, f3, f4 = carry_felem5_full (f0, f1, f2, f3, f4) in
let f0, f1, f2, f3, f4 = subtract_p5 (f0, f1, f2, f3, f4) in
let o0 = f0 |. (f1 <<. 51ul) in
let o1 = (f1 >>. 13ul) |. (f2 <<. 38ul) in
let o2 = (f2 >>. 26ul) |. (f3 <<. 25ul) in
let o3 = (f3 >>. 39ul) |. (f4 <<. 12ul) in
lemma_store_felem (f0, f1, f2, f3, f4);
(o0, o1, o2, o3) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.mul_inv_t",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple4",
"Prims.unit",
"Hacl.Spec.Curve25519.Field51.Lemmas.lemma_store_felem",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Less_Less_Dot",
"FStar.Pervasives.Native.tuple4",
"Hacl.Spec.Curve25519.Field51.subtract_p5",
"Prims.l_and",
"Prims.eq2",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"Prims.nat",
"Hacl.Spec.Curve25519.Field51.carry_felem5_full"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul)
inline_for_extraction noextract
val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1))
let carry51_wide #m l cin =
let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul))
let mul_inv_t (f:felem5) =
let (o0, o1, o2, o3, o4) = f in
if v o1 >= pow2 51 then
felem_fits5 f (1, 2, 1, 1, 1) /\ v o1 % pow2 51 < 8192
else felem_fits5 f (1, 1, 1, 1, 1)
#push-options "--ifuel 1"
val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1))
let lemma_mul_inv f cin =
assert_norm (pow51 = pow2 51)
#pop-options
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val carry_wide5:
inp:felem_wide5{felem_wide_fits5 inp (6579, 4797, 3340, 1881, 423)}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == feval_wide inp)
let carry_wide5 (i0, i1, i2, i3, i4) =
assert_norm (6579 < pow2 13);
assert_norm (pow2 13 < max51);
let tmp0, c0 = carry51_wide #6579 i0 (u64 0) in
let tmp1, c1 = carry51_wide #4797 i1 c0 in
let tmp2, c2 = carry51_wide #3340 i2 c1 in
let tmp3, c3 = carry51_wide #1881 i3 c2 in
let tmp4, c4 = carry51_wide #423 i4 c3 in
lemma_carry5_simplify c0 c1 c2 c3 c4 tmp0 tmp1 tmp2 tmp3 tmp4;
let tmp0', c5 = carry51 tmp0 (c4 *! u64 19) in
[@inline_let]
let tmp1' = tmp1 +! c5 in
lemma_mul_inv (tmp0', tmp1, tmp2, tmp3, tmp4) c5;
(tmp0', tmp1', tmp2, tmp3, tmp4)
#pop-options
inline_for_extraction noextract
val fmul5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\
feval out == fmul (feval f1) (feval f2)}
let fmul5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let (tmp0, tmp1, tmp2, tmp3, tmp4) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp0, tmp1, tmp2, tmp3, tmp4) in
carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)
inline_for_extraction noextract
val fmul25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> f3:felem5{felem_fits5 f3 (9, 10, 9, 9, 9)}
-> f4:felem5{felem_fits5 f4 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\ mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f2) /\
feval out2 == fmul (feval f3) (feval f4))
let fmul25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) =
let (tmp10, tmp11, tmp12, tmp13, tmp14) = precomp_r19 (f20, f21, f22, f23, f24) in
let (tmp20, tmp21, tmp22, tmp23, tmp24) = precomp_r19 (f40, f41, f42, f43, f44) in
let (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) =
mul_felem5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) (tmp10, tmp11, tmp12, tmp13, tmp14) in
let (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) =
mul_felem5 (f30, f31, f32, f33, f34) (f40, f41, f42, f43, f44) (tmp20, tmp21, tmp22, tmp23, tmp24) in
let (o10,o11,o12,o13,o14) = carry_wide5 (tmp_w10, tmp_w11, tmp_w12, tmp_w13, tmp_w14) in
let (o20,o21,o22,o23,o24) = carry_wide5 (tmp_w20, tmp_w21, tmp_w22, tmp_w23, tmp_w24) in
((o10,o11,o12,o13,o14), (o20,o21,o22,o23,o24))
inline_for_extraction noextract
val fmul15:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:uint64{felem_fits1 f2 1}
-> Pure felem5
(requires True)
(ensures fun out ->
mul_inv_t out /\ feval out == (feval f1 * v f2) % prime)
let fmul15 (f10, f11, f12, f13, f14) f2 =
let (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) =
smul_felem5 #1 #(9, 10, 9, 9, 9) f2 (f10, f11, f12, f13, f14) in
let out = (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
[@inline_let]
let res = carry_wide5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4) in
FStar.Math.Lemmas.lemma_mod_mul_distr_l (as_nat5 (f10, f11, f12, f13, f14)) (uint_v f2) prime;
assert (feval res == feval_wide (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4));
assert (feval res == (wide_as_nat5 (tmp_w0, tmp_w1, tmp_w2, tmp_w3, tmp_w4)) % prime);
assert (feval res == (v f2 * as_nat5 (f10, f11, f12, f13, f14)) % prime);
FStar.Math.Lemmas.swap_mul (v f2) (as_nat5 (f10, f11, f12, f13, f14));
assert (feval res == (as_nat5 (f10, f11, f12, f13, f14) * v f2) % prime);
res
// inline_for_extraction noextract
// val fsqr_felem5:
// f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
// -> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423)}
// let fsqr_felem5 (f0, f1, f2, f3, f4) =
// let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 20, 18, 18, 18) f0 (f0, u64 2 *! f1, u64 2 *! f2, u64 2 *! f3, u64 2 *! f4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(342, 0, 10, 18, 18) #(81, 180, 162, 162, 162)
// f1 (u64 38 *! f4, u64 0, f1, u64 2 *! f2, u64 2 *! f3) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(342, 342, 0, 0, 9) #(3501, 180, 262, 342, 342)
// f2 (u64 38 *! f3, u64 38 *! f4, u64 0, u64 0, f2) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(0, 171, 342, 0, 0) #(6579, 3258, 262, 342, 423)
// f3 (u64 0, u64 19 *. f3, u64 38 *. f4, u64 0, u64 0) (o0, o1, o2, o3, o4) in
// let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(0, 0, 0, 171, 0) #(6579, 4797, 3340, 342, 423)
// f4 (u64 0, u64 0, u64 0, u64 19 *. f4, u64 0) (o0, o1, o2, o3, o4) in
// (o0, o1, o2, o3, o4)
inline_for_extraction noextract
val mul64_wide_add3:
#m0:scale64 -> #m1:scale64 -> #m2:scale64
-> #m3:scale64 -> #m4:scale64 -> #m5:scale64
-> a0:uint64{felem_fits1 a0 m0}
-> a1:uint64{felem_fits1 a1 m1}
-> b0:uint64{felem_fits1 b0 m2}
-> b1:uint64{felem_fits1 b1 m3}
-> c0:uint64{felem_fits1 c0 m4}
-> c1:uint64{felem_fits1 c1 m5} ->
Pure uint128
(requires m0 * m1 + m2 * m3 + m4 * m5 < 8192)
(ensures fun res ->
felem_wide_fits1 res (m0 * m1 + m2 * m3 + m4 * m5) /\
v res == v a0 * v a1 + v b0 * v b1 + v c0 * v c1)
let mul64_wide_add3 #m0 #m1 #m2 #m3 #m4 #m5 a0 a1 b0 b1 c0 c1 =
assert_norm (pow2 13 = 8192);
mul64_wide_add3_lemma #m0 #m1 #m2 #m3 #m4 #m5 a0 a1 b0 b1 c0 c1;
mul64_wide a0 a1 +! mul64_wide b0 b1 +! mul64_wide c0 c1
inline_for_extraction noextract
val fsqr_felem5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> Pure felem_wide5
(requires True)
(ensures fun out ->
felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f) (feval f))
let fsqr_felem5 (f0, f1, f2, f3, f4) =
assert_norm (pow2 13 = 8192);
let d0 = u64 2 *! f0 in
let d1 = u64 2 *! f1 in
let d2 = u64 38 *! f2 in
let d3 = u64 19 *! f3 in
let d419 = u64 19 *! f4 in
let d4 = u64 2 *! d419 in
let s0 = mul64_wide_add3 #9 #9 #342 #10 #342 #9 f0 f0 d4 f1 d2 f3 in
let s1 = mul64_wide_add3 #18 #10 #342 #9 #171 #9 d0 f1 d4 f2 d3 f3 in
let s2 = mul64_wide_add3 #18 #9 #10 #10 #342 #9 d0 f2 f1 f1 d4 f3 in
let s3 = mul64_wide_add3 #18 #9 #20 #9 #9 #171 d0 f3 d1 f2 f4 d419 in
let s4 = mul64_wide_add3 #18 #9 #20 #9 #9 #9 d0 f4 d1 f3 f2 f2 in
lemma_fmul_fsqr5 (f0, f1, f2, f3, f4);
(s0, s1, s2, s3, s4)
inline_for_extraction noextract
val fsqr5:
f:felem5{felem_fits5 f (9, 10, 9, 9, 9)}
-> out:felem5{mul_inv_t out /\ feval out == fmul (feval f) (feval f)}
let fsqr5 (f0, f1, f2, f3, f4) =
let (o0, o1, o2, o3, o4) = fsqr_felem5 (f0, f1, f2, f3, f4) in
carry_wide5 (o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsqr25:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> Pure (felem5 & felem5)
(requires True)
(ensures fun (out1, out2) ->
mul_inv_t out1 /\
mul_inv_t out2 /\
feval out1 == fmul (feval f1) (feval f1) /\
feval out2 == fmul (feval f2) (feval f2))
let fsqr25 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let (o10, o11, o12, o13, o14) = fsqr_felem5 (f10, f11, f12, f13, f14) in
let (o20, o21, o22, o23, o24) = fsqr_felem5 (f20, f21, f22, f23, f24) in
let (o10, o11, o12, o13, o14) = carry_wide5 (o10, o11, o12, o13, o14) in
let (o20, o21, o22, o23, o24) = carry_wide5 (o20, o21, o22, o23, o24) in
((o10, o11, o12, o13, o14), (o20, o21, o22, o23, o24))
#set-options "--z3rlimit 100 --max_fuel 2"
inline_for_extraction noextract
val carry_felem5_full:
inp:felem5{mul_inv_t inp}
-> out:felem5{feval out == feval inp /\ felem_fits5 out (1, 1, 1, 1, 1)}
let carry_felem5_full (f0, f1, f2, f3, f4) =
assert_norm (pow51 = pow2 51);
let tmp0, c0 = carry51 f0 (u64 0) in
let tmp1, c1 = carry51 f1 c0 in
assert (if v f1 < pow2 51 then v tmp1 < pow2 51 else v tmp1 < 8192);
let tmp2, c2 = carry51 f2 c1 in
let tmp3, c3 = carry51 f3 c2 in
let tmp4, c4 = carry51 f4 c3 in
lemma_carry5_simplify c0 c1 c2 c3 c4 tmp0 tmp1 tmp2 tmp3 tmp4;
[@inline_let]
let tmp0', c5 = carry51 tmp0 (c4 *! u64 19) in
[@inline_let]
let tmp1' = tmp1 +! c5 in
(tmp0', tmp1', tmp2, tmp3, tmp4)
inline_for_extraction noextract
val subtract_p5:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> Pure felem5
(requires True)
(ensures fun out ->
as_nat5 out == feval f /\
felem_fits5 out (1, 1, 1, 1, 1) /\
as_nat5 out < prime)
let subtract_p5 (f0, f1, f2, f3, f4) =
let m0 = gte_mask f0 (u64 0x7ffffffffffed) in
let m1 = eq_mask f1 (u64 0x7ffffffffffff) in
let m2 = eq_mask f2 (u64 0x7ffffffffffff) in
let m3 = eq_mask f3 (u64 0x7ffffffffffff) in
let m4 = eq_mask f4 (u64 0x7ffffffffffff) in
let mask = m0 &. m1 &. m2 &. m3 &. m4 in
let f0' = f0 -. (mask &. u64 0x7ffffffffffed) in
let f1' = f1 -. (mask &. u64 0x7ffffffffffff) in
let f2' = f2 -. (mask &. u64 0x7ffffffffffff) in
let f3' = f3 -. (mask &. u64 0x7ffffffffffff) in
let f4' = f4 -. (mask &. u64 0x7ffffffffffff) in
logand_lemma mask (u64 0x7ffffffffffed);
logand_lemma mask (u64 0x7ffffffffffff);
lemma_subtract_p (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4');
(f0', f1', f2', f3', f4')
inline_for_extraction noextract
val store_felem5:
f:felem5{mul_inv_t f}
-> Pure (uint64 & uint64 & uint64 & uint64)
(requires True)
(ensures fun (o0, o1, o2, o3) ->
feval f == v o0 + v o1 * pow2 64 + | false | false | Hacl.Spec.Curve25519.Field51.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 2,
"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_felem5:
f:felem5{mul_inv_t f}
-> Pure (uint64 & uint64 & uint64 & uint64)
(requires True)
(ensures fun (o0, o1, o2, o3) ->
feval f == v o0 + v o1 * pow2 64 +
v o2 * pow2 64 * pow2 64 + v o3 * pow2 64 * pow2 64 * pow2 64) | [] | Hacl.Spec.Curve25519.Field51.store_felem5 | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.Curve25519.Field51.Definition.felem5{Hacl.Spec.Curve25519.Field51.mul_inv_t f}
-> Prims.Pure
(((Lib.IntTypes.uint64 * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) * Lib.IntTypes.uint64) | {
"end_col": 18,
"end_line": 500,
"start_col": 39,
"start_line": 491
} |
FStar.Pervasives.Lemma | val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_mul_inv f cin =
assert_norm (pow51 = pow2 51) | val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1))
let lemma_mul_inv f cin = | false | null | true | assert_norm (pow51 = pow2 51) | {
"checked_file": "Hacl.Spec.Curve25519.Field51.fst.checked",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Lemmas.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field51.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.pow2",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.pos",
"Hacl.Spec.Curve25519.Field51.Definition.pow51",
"Prims.unit"
] | [] | module Hacl.Spec.Curve25519.Field51
open Lib.Sequence
open Lib.IntTypes
open FStar.Mul
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field51.Definition
open Hacl.Spec.Curve25519.Field51.Lemmas
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
val fadd5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (2, 4, 2, 2, 2) /\
feval out == fadd (feval f1) (feval f2)}
let fadd5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
let o0 = f10 +! f20 in
let o1 = f11 +! f21 in
let o2 = f12 +! f22 in
let o3 = f13 +! f23 in
let o4 = f14 +! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
((as_nat5 (f10, f11, f12, f13, f14)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
inline_for_extraction noextract
val fadd_zero:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == feval f1}
let fadd_zero (f10, f11, f12, f13, f14) =
let o0 = f10 +! u64 0x3fffffffffff68 in
let o1 = f11 +! u64 0x3ffffffffffff8 in
let o2 = f12 +! u64 0x3ffffffffffff8 in
let o3 = f13 +! u64 0x3ffffffffffff8 in
let o4 = f14 +! u64 0x3ffffffffffff8 in
lemma_add_zero (f10, f11, f12, f13, f14);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val fsub5:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> out:felem5{felem_fits5 out (9, 10, 9, 9, 9) /\
feval out == fsub (feval f1) (feval f2)}
let fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24) =
//assert_norm (0x3fffffffffff68 == pow2 54 - 152);
//assert_norm (0x3ffffffffffff8 == pow2 54 - 8);
let (t0, t1, t2, t3, t4) = fadd_zero (f10, f11, f12, f13, f14) in
let o0 = t0 -! f20 in
let o1 = t1 -! f21 in
let o2 = t2 -! f22 in
let o3 = t3 -! f23 in
let o4 = t4 -! f24 in
let out = (o0, o1, o2, o3, o4) in
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (t0, t1, t2, t3, t4)) (- as_nat5 (f20, f21, f22, f23, f24)) prime;
lemma_mod_sub_distr ((as_nat5 (t0, t1, t2, t3, t4)) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime;
out
val lemma_fsub:
f1:felem5{felem_fits5 f1 (1, 2, 1, 1, 1)}
-> f2:felem5{felem_fits5 f2 (1, 2, 1, 1, 1)}
-> Lemma (let (f10, f11, f12, f13, f14) = f1 in
let (f20, f21, f22, f23, f24) = f2 in
let o0 = f10 +! u64 0x3fffffffffff68 -! f20 in
let o1 = f11 +! u64 0x3ffffffffffff8 -! f21 in
let o2 = f12 +! u64 0x3ffffffffffff8 -! f22 in
let o3 = f13 +! u64 0x3ffffffffffff8 -! f23 in
let o4 = f14 +! u64 0x3ffffffffffff8 -! f24 in
let out = (o0, o1, o2, o3, o4) in
out == fsub5 (f10, f11, f12, f13, f14) (f20, f21, f22, f23, f24))
let lemma_fsub f1 f2 = ()
inline_for_extraction noextract
val mul_wide64:
#m1:scale64
-> #m2:scale64
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2 /\ m1 * m2 <= 67108864}
-> z:uint128{uint_v z == uint_v x * uint_v y /\ felem_wide_fits1 z (m1 * m2)}
#push-options "--z3rlimit 5"
let mul_wide64 #m1 #m2 x y =
let open FStar.Math.Lemmas in
lemma_mult_le_left (v x) (v y) (m2 * max51); //v x * v y <= v x * (m2 * max51)
lemma_mult_le_right (m2 * max51) (v x) (m1 * max51); // v x * (m2 * max51) <= (m1 * max51) * (m2 * max51)
paren_mul_right (m1 * max51) m2 max51; //(m1 * max51) * (m2 * max51) = ((m1 * max51) * m2) * max51
paren_mul_right m1 max51 m2; //(m1 * max51) * m2 = m1 * (max51 * m2)
swap_mul max51 m2; //max51 * m2 = m2 * max51
paren_mul_right m1 m2 max51; //m1 * (m2 * max51) = (m1 * m2) * max51
paren_mul_right (m1 * m2) max51 max51; //((m1 * m2) * max51) * max51 = (m1 * m2) * (max51 * max51)
assert (v x * v y <= m1 * max51 * m2 * max51);
assert (v x * v y <= m1 * m2 * max51 * max51);
mul64_wide x y
#pop-options
inline_for_extraction noextract
val smul_felem5:
#m1:scale64
-> #m2:scale64_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2 /\ m1 *^ m2 <=* s128x5 67108864}
-> out:felem_wide5{felem_wide_fits5 out (m1 *^ m2) /\
wide_as_nat5 out == uint_v u1 * as_nat5 f2}
let smul_felem5 #m1 #m2 u1 (f20, f21, f22, f23, f24) =
let (m20, m21, m22, m23, m24) = m2 in
[@inline_let]
let o0 = mul_wide64 #m1 #m20 u1 f20 in
[@inline_let]
let o1 = mul_wide64 #m1 #m21 u1 f21 in
[@inline_let]
let o2 = mul_wide64 #m1 #m22 u1 f22 in
[@inline_let]
let o3 = mul_wide64 #m1 #m23 u1 f23 in
[@inline_let]
let o4 = mul_wide64 #m1 #m24 u1 f24 in
[@inline_let]
let out = (o0, o1, o2, o3, o4) in
lemma_smul_felem5 u1 (f20, f21, f22, f23, f24);
out
inline_for_extraction noextract
val mul_add_wide128:
#m1:scale64
-> #m2:scale64
-> #m3:scale128
-> x:uint64{felem_fits1 x m1}
-> y:uint64{felem_fits1 y m2}
-> z:uint128{felem_wide_fits1 z m3 /\ m3 + m1 * m2 <= 67108864}
-> r:uint128{uint_v r == uint_v z + uint_v x * uint_v y /\ felem_wide_fits1 r (m3 + m1 * m2)}
let mul_add_wide128 #m1 #m2 #m3 x y z =
z +! mul_wide64 #m1 #m2 x y
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val smul_add_felem5:
#m1:scale64
-> #m2:scale64_5
-> #m3:scale128_5
-> u1:uint64{felem_fits1 u1 m1}
-> f2:felem5{felem_fits5 f2 m2}
-> acc1:felem_wide5{felem_wide_fits5 acc1 m3 /\ m3 +* m1 *^ m2 <=* s128x5 67108864}
-> acc2:felem_wide5{
wide_as_nat5 acc2 == wide_as_nat5 acc1 + uint_v u1 * as_nat5 f2 /\
felem_wide_fits5 acc2 (m3 +* m1 *^ m2)}
let smul_add_felem5 #m1 #m2 #m3 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4) =
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
[@inline_let]
let o0' = mul_add_wide128 #m1 #m20 #m30 u1 f20 o0 in
[@inline_let]
let o1' = mul_add_wide128 #m1 #m21 #m31 u1 f21 o1 in
[@inline_let]
let o2' = mul_add_wide128 #m1 #m22 #m32 u1 f22 o2 in
[@inline_let]
let o3' = mul_add_wide128 #m1 #m23 #m33 u1 f23 o3 in
[@inline_let]
let o4' = mul_add_wide128 #m1 #m24 #m34 u1 f24 o4 in
[@inline_let]
let out = (o0', o1', o2', o3', o4') in
lemma_smul_add_felem5 u1 (f20, f21, f22, f23, f24) (o0, o1, o2, o3, o4);
out
#pop-options
inline_for_extraction noextract
val precomp_r19:
f2:felem5{felem_fits5 f2 (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171)}
let precomp_r19 (f20, f21, f22, f23, f24) =
[@inline_let]
let r190 = f20 *! u64 19 in
[@inline_let]
let r191 = f21 *! u64 19 in
[@inline_let]
let r192 = f22 *! u64 19 in
[@inline_let]
let r193 = f23 *! u64 19 in
[@inline_let]
let r194 = f24 *! u64 19 in
(r190, r191, r192, r193, r194)
inline_for_extraction noextract
val mul_felem5:
f1:felem5{felem_fits5 f1 (9, 10, 9, 9, 9)}
-> r:felem5{felem_fits5 r (9, 10, 9, 9, 9)}
-> r19:felem5{felem_fits5 r19 (171, 190, 171, 171, 171) /\ r19 == precomp_r19 r}
-> out:felem_wide5{felem_wide_fits5 out (6579, 4797, 3340, 1881, 423) /\
feval_wide out == fmul (feval f1) (feval r)}
let mul_felem5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r190, r191, r192, r193, r194) =
let (o0, o1, o2, o3, o4) = smul_felem5 #9 #(9, 10, 9, 9, 9) f10 (r0, r1, r2, r3, r4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #10 #(171, 9, 10, 9, 9) #(81, 90, 81, 81, 81)
f11 (r194, r0, r1, r2, r3) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 9, 10, 9) #(1791, 180, 181, 171, 171)
f12 (r193, r194, r0, r1, r2) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(171, 171, 171, 9, 10) #(3330, 1719, 262, 261, 252)
f13 (r192, r193, r194, r0, r1) (o0, o1, o2, o3, o4) in
let (o0, o1, o2, o3, o4) = smul_add_felem5 #9 #(190, 171, 171, 171, 9) #(4869, 3258, 1801, 342, 342)
f14 (r191, r192, r193, r194, r0) (o0, o1, o2, o3, o4) in
lemma_fmul5 (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4);
(o0, o1, o2, o3, o4)
inline_for_extraction noextract
val carry51:
l:uint64
-> cin:uint64
-> Pure (uint64 & uint64)
(requires felem_fits1 l 2 /\ felem_fits1 cin 8190)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ uint_v l1 < pow2 13)
let carry51 l cin =
let l' = l +! cin in
lemma_carry51 l cin;
(l' &. mask51, l' >>. 51ul)
inline_for_extraction noextract
val carry51_wide:
#m:scale64{m < 8192}
-> l:uint128{felem_wide_fits1 l m}
-> cin:uint64
-> Pure (uint64 & uint64)
(requires True)
(ensures fun (l0, l1) ->
v l + v cin == v l1 * pow2 51 + v l0 /\
felem_fits1 l0 1 /\ felem_fits1 l1 (m + 1))
let carry51_wide #m l cin =
let l' = l +! to_u128 cin in
lemma_carry51_wide #m l cin;
((to_u64 l') &. mask51, to_u64 (l' >>. 51ul))
let mul_inv_t (f:felem5) =
let (o0, o1, o2, o3, o4) = f in
if v o1 >= pow2 51 then
felem_fits5 f (1, 2, 1, 1, 1) /\ v o1 % pow2 51 < 8192
else felem_fits5 f (1, 1, 1, 1, 1)
#push-options "--ifuel 1"
val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1)) | false | false | Hacl.Spec.Curve25519.Field51.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_mul_inv:
f:felem5{felem_fits5 f (1, 1, 1, 1, 1)}
-> cin:uint64{v cin < pow2 51}
-> Lemma
(let (i0, i1, i2, i3, i4) = f in
assert_norm (pow51 = pow2 51);
let i1' = i1 +! cin in
let out = (i0, i1', i2, i3, i4) in
if (v i1 + v cin) / pow2 51 > 0 then
felem_fits5 out (1, 2, 1, 1, 1) /\
(v i1 + v cin) % pow2 51 < v cin
else felem_fits5 out (1, 1, 1, 1, 1)) | [] | Hacl.Spec.Curve25519.Field51.lemma_mul_inv | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f:
Hacl.Spec.Curve25519.Field51.Definition.felem5
{Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 f (1, 1, 1, 1, 1)} ->
cin: Lib.IntTypes.uint64{Lib.IntTypes.v cin < Prims.pow2 51}
-> FStar.Pervasives.Lemma
(ensures
(let _ = f in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ i0 i1 i2 i3 i4 = _ in
FStar.Pervasives.assert_norm (Hacl.Spec.Curve25519.Field51.Definition.pow51 =
Prims.pow2 51);
let i1' = i1 +! cin in
let out = i0, i1', i2, i3, i4 in
(match (Lib.IntTypes.v i1 + Lib.IntTypes.v cin) / Prims.pow2 51 > 0 with
| true ->
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 out (1, 2, 1, 1, 1) /\
(Lib.IntTypes.v i1 + Lib.IntTypes.v cin) % Prims.pow2 51 < Lib.IntTypes.v cin
| _ -> Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 out (1, 1, 1, 1, 1))
<:
Type0)
<:
Type0)) | {
"end_col": 31,
"end_line": 257,
"start_col": 2,
"start_line": 257
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.