effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let c1 = 0x3320646eul
let c1 =
false
null
false
0x3320646eul
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul
false
true
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val c1 : FStar.UInt32.t
[]
Hacl.Spec.Chacha20.Vec.c1
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.UInt32.t
{ "end_col": 21, "end_line": 102, "start_col": 9, "start_line": 102 }
Prims.Tot
val chacha20_encrypt_bytes: #w:lanes -> k: key -> n: nonce -> c: counter -> msg: bytes{length msg <= max_size_t} -> cipher: bytes{length cipher == length msg}
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_encrypt_bytes #w key nonce ctr0 msg = let st0 = chacha20_init #w key nonce ctr0 in chacha20_update #w st0 msg
val chacha20_encrypt_bytes: #w:lanes -> k: key -> n: nonce -> c: counter -> msg: bytes{length msg <= max_size_t} -> cipher: bytes{length cipher == length msg} let chacha20_encrypt_bytes #w key nonce ctr0 msg =
false
null
false
let st0 = chacha20_init #w key nonce ctr0 in chacha20_update #w st0 msg
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.key", "Hacl.Spec.Chacha20.Vec.nonce", "Hacl.Spec.Chacha20.Vec.counter", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.max_size_t", "Hacl.Spec.Chacha20.Vec.chacha20_update", "Hacl.Spec.Chacha20.Vec.state", "Hacl.Spec.Chacha20.Vec.chacha20_init", "Prims.eq2", "Prims.nat" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c let transpose1 (st:state 1) : state 1 = st let transpose4 (st:state 4) : state 4 = let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st.[0],st.[1],st.[2],st.[3]) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st.[8],st.[9],st.[10],st.[11]) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st.[12],st.[13],st.[14],st.[15]) in create16 v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15 let transpose8 (st:state 8) : state 8 = let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st.[0],st.[1],st.[2],st.[3],st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st.[8],st.[9],st.[10],st.[11],st.[12],st.[13],st.[14],st.[15]) in create16 v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15 let transpose (#w:lanes) (st:state w) : state w = match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st // let store_block0 (#w:lanes) (st:state w) : Tot block1 = // let bl = create 64 (u8 0) in // repeati (16 / w) // (fun i bl -> update_sub bl (i * w * 4) (w * 4) (vec_to_bytes_le st.[i])) bl // let chacha20_key_block0 (#w:lanes) (k:key) (n:nonce) : Tot block1 = // let st0 = chacha20_init #w k n 0 in // let k = chacha20_core 0 st0 in // store_block0 k let xor_block_f (#w:lanes) (k:state w) (i:nat{i < 16}) (b:lbytes (w * 4)) : lbytes (w * 4) = let x = vec_from_bytes_le U32 w b in let y = x ^| k.[i] in vec_to_bytes_le y let xor_block (#w:lanes) (k:state w) (b:blocks w) : blocks w = map_blocks_multi (w * 4) 16 16 b (xor_block_f #w k) val chacha20_encrypt_block: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> b: blocks w -> Tot (blocks w) let chacha20_encrypt_block #w st0 incr b = let k = chacha20_core incr st0 in let k = transpose k in xor_block k b val chacha20_encrypt_last: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> len: size_nat{len < w * size_block} -> b: lbytes len -> Tot (lbytes len) let chacha20_encrypt_last #w st0 incr len b = let plain = create (w * size_block) (u8 0) in let plain = update_sub plain 0 len b in let cipher = chacha20_encrypt_block st0 incr plain in sub cipher 0 len val chacha20_update: #w:lanes -> st0: state w -> msg: bytes{length msg <= max_size_t} -> cipher: bytes{length cipher == length msg} let chacha20_update #w st0 msg = let cipher = msg in map_blocks (w * size_block) cipher (chacha20_encrypt_block st0) (chacha20_encrypt_last st0) val chacha20_encrypt_bytes: #w:lanes -> k: key -> n: nonce -> c: counter -> msg: bytes{length msg <= max_size_t} -> cipher: bytes{length cipher == length msg}
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val chacha20_encrypt_bytes: #w:lanes -> k: key -> n: nonce -> c: counter -> msg: bytes{length msg <= max_size_t} -> cipher: bytes{length cipher == length msg}
[]
Hacl.Spec.Chacha20.Vec.chacha20_encrypt_bytes
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.Chacha20.Vec.key -> n: Hacl.Spec.Chacha20.Vec.nonce -> c: Hacl.Spec.Chacha20.Vec.counter -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length msg <= Lib.IntTypes.max_size_t} -> cipher: Lib.ByteSequence.bytes{Lib.Sequence.length cipher == Lib.Sequence.length msg}
{ "end_col": 28, "end_line": 209, "start_col": 50, "start_line": 207 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w
let vec_load_i (#t: v_inttype) (w: width) (x: uint_t t SEC) =
false
null
false
vec_load #t x w
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Lib.IntVector.v_inttype", "Lib.IntVector.width", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.IntVector.vec_load", "Lib.IntVector.vec_t", "Prims.eq2", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntVector.vec_v", "Lib.Sequence.create" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0))
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vec_load_i : w: Lib.IntVector.width -> x: Lib.IntTypes.uint_t t Lib.IntTypes.SEC -> v: Lib.IntVector.vec_t t w {Lib.IntVector.vec_v v == Lib.Sequence.create w x}
[]
Hacl.Spec.Chacha20.Vec.vec_load_i
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
w: Lib.IntVector.width -> x: Lib.IntTypes.uint_t t Lib.IntTypes.SEC -> v: Lib.IntVector.vec_t t w {Lib.IntVector.vec_v v == Lib.Sequence.create w x}
{ "end_col": 74, "end_line": 118, "start_col": 59, "start_line": 118 }
Prims.Tot
val chacha20_decrypt_bytes: #w:lanes -> k: key -> n: nonce -> c: counter -> cipher: bytes{length cipher <= max_size_t} -> msg: bytes{length cipher == length msg}
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_decrypt_bytes #w key nonce ctr0 cipher = let st0 = chacha20_init #w key nonce ctr0 in chacha20_update #w st0 cipher
val chacha20_decrypt_bytes: #w:lanes -> k: key -> n: nonce -> c: counter -> cipher: bytes{length cipher <= max_size_t} -> msg: bytes{length cipher == length msg} let chacha20_decrypt_bytes #w key nonce ctr0 cipher =
false
null
false
let st0 = chacha20_init #w key nonce ctr0 in chacha20_update #w st0 cipher
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.key", "Hacl.Spec.Chacha20.Vec.nonce", "Hacl.Spec.Chacha20.Vec.counter", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.max_size_t", "Hacl.Spec.Chacha20.Vec.chacha20_update", "Hacl.Spec.Chacha20.Vec.state", "Hacl.Spec.Chacha20.Vec.chacha20_init", "Prims.eq2", "Prims.nat" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c let transpose1 (st:state 1) : state 1 = st let transpose4 (st:state 4) : state 4 = let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st.[0],st.[1],st.[2],st.[3]) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st.[8],st.[9],st.[10],st.[11]) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st.[12],st.[13],st.[14],st.[15]) in create16 v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15 let transpose8 (st:state 8) : state 8 = let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st.[0],st.[1],st.[2],st.[3],st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st.[8],st.[9],st.[10],st.[11],st.[12],st.[13],st.[14],st.[15]) in create16 v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15 let transpose (#w:lanes) (st:state w) : state w = match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st // let store_block0 (#w:lanes) (st:state w) : Tot block1 = // let bl = create 64 (u8 0) in // repeati (16 / w) // (fun i bl -> update_sub bl (i * w * 4) (w * 4) (vec_to_bytes_le st.[i])) bl // let chacha20_key_block0 (#w:lanes) (k:key) (n:nonce) : Tot block1 = // let st0 = chacha20_init #w k n 0 in // let k = chacha20_core 0 st0 in // store_block0 k let xor_block_f (#w:lanes) (k:state w) (i:nat{i < 16}) (b:lbytes (w * 4)) : lbytes (w * 4) = let x = vec_from_bytes_le U32 w b in let y = x ^| k.[i] in vec_to_bytes_le y let xor_block (#w:lanes) (k:state w) (b:blocks w) : blocks w = map_blocks_multi (w * 4) 16 16 b (xor_block_f #w k) val chacha20_encrypt_block: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> b: blocks w -> Tot (blocks w) let chacha20_encrypt_block #w st0 incr b = let k = chacha20_core incr st0 in let k = transpose k in xor_block k b val chacha20_encrypt_last: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> len: size_nat{len < w * size_block} -> b: lbytes len -> Tot (lbytes len) let chacha20_encrypt_last #w st0 incr len b = let plain = create (w * size_block) (u8 0) in let plain = update_sub plain 0 len b in let cipher = chacha20_encrypt_block st0 incr plain in sub cipher 0 len val chacha20_update: #w:lanes -> st0: state w -> msg: bytes{length msg <= max_size_t} -> cipher: bytes{length cipher == length msg} let chacha20_update #w st0 msg = let cipher = msg in map_blocks (w * size_block) cipher (chacha20_encrypt_block st0) (chacha20_encrypt_last st0) val chacha20_encrypt_bytes: #w:lanes -> k: key -> n: nonce -> c: counter -> msg: bytes{length msg <= max_size_t} -> cipher: bytes{length cipher == length msg} let chacha20_encrypt_bytes #w key nonce ctr0 msg = let st0 = chacha20_init #w key nonce ctr0 in chacha20_update #w st0 msg val chacha20_decrypt_bytes: #w:lanes -> k: key -> n: nonce -> c: counter -> cipher: bytes{length cipher <= max_size_t} -> msg: bytes{length cipher == length msg}
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val chacha20_decrypt_bytes: #w:lanes -> k: key -> n: nonce -> c: counter -> cipher: bytes{length cipher <= max_size_t} -> msg: bytes{length cipher == length msg}
[]
Hacl.Spec.Chacha20.Vec.chacha20_decrypt_bytes
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.Chacha20.Vec.key -> n: Hacl.Spec.Chacha20.Vec.nonce -> c: Hacl.Spec.Chacha20.Vec.counter -> cipher: Lib.ByteSequence.bytes{Lib.Sequence.length cipher <= Lib.IntTypes.max_size_t} -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length cipher == Lib.Sequence.length msg}
{ "end_col": 31, "end_line": 221, "start_col": 53, "start_line": 219 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint32xN (w:lanes) = vec_t U32 w
let uint32xN (w: lanes) =
false
null
false
vec_t U32 w
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Lib.IntVector.vec_t", "Lib.IntTypes.U32" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8}
false
true
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint32xN : w: Hacl.Spec.Chacha20.Vec.lanes -> Type0
[]
Hacl.Spec.Chacha20.Vec.uint32xN
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
w: Hacl.Spec.Chacha20.Vec.lanes -> Type0
{ "end_col": 36, "end_line": 31, "start_col": 25, "start_line": 31 }
Prims.Tot
val chacha20_encrypt_block: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> b: blocks w -> Tot (blocks w)
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_encrypt_block #w st0 incr b = let k = chacha20_core incr st0 in let k = transpose k in xor_block k b
val chacha20_encrypt_block: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> b: blocks w -> Tot (blocks w) let chacha20_encrypt_block #w st0 incr b =
false
null
false
let k = chacha20_core incr st0 in let k = transpose k in xor_block k b
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.state", "Hacl.Spec.Chacha20.Vec.counter", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Hacl.Spec.Chacha20.Vec.blocks", "Hacl.Spec.Chacha20.Vec.xor_block", "Hacl.Spec.Chacha20.Vec.transpose", "Hacl.Spec.Chacha20.Vec.chacha20_core" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c let transpose1 (st:state 1) : state 1 = st let transpose4 (st:state 4) : state 4 = let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st.[0],st.[1],st.[2],st.[3]) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st.[8],st.[9],st.[10],st.[11]) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st.[12],st.[13],st.[14],st.[15]) in create16 v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15 let transpose8 (st:state 8) : state 8 = let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st.[0],st.[1],st.[2],st.[3],st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st.[8],st.[9],st.[10],st.[11],st.[12],st.[13],st.[14],st.[15]) in create16 v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15 let transpose (#w:lanes) (st:state w) : state w = match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st // let store_block0 (#w:lanes) (st:state w) : Tot block1 = // let bl = create 64 (u8 0) in // repeati (16 / w) // (fun i bl -> update_sub bl (i * w * 4) (w * 4) (vec_to_bytes_le st.[i])) bl // let chacha20_key_block0 (#w:lanes) (k:key) (n:nonce) : Tot block1 = // let st0 = chacha20_init #w k n 0 in // let k = chacha20_core 0 st0 in // store_block0 k let xor_block_f (#w:lanes) (k:state w) (i:nat{i < 16}) (b:lbytes (w * 4)) : lbytes (w * 4) = let x = vec_from_bytes_le U32 w b in let y = x ^| k.[i] in vec_to_bytes_le y let xor_block (#w:lanes) (k:state w) (b:blocks w) : blocks w = map_blocks_multi (w * 4) 16 16 b (xor_block_f #w k) val chacha20_encrypt_block: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> b: blocks w ->
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val chacha20_encrypt_block: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> b: blocks w -> Tot (blocks w)
[]
Hacl.Spec.Chacha20.Vec.chacha20_encrypt_block
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st0: Hacl.Spec.Chacha20.Vec.state w -> incr: Hacl.Spec.Chacha20.Vec.counter{incr * w <= Lib.IntTypes.max_size_t} -> b: Hacl.Spec.Chacha20.Vec.blocks w -> Hacl.Spec.Chacha20.Vec.blocks w
{ "end_col": 15, "end_line": 173, "start_col": 42, "start_line": 170 }
Prims.Tot
val add_counter (#w: lanes) (ctr: counter{w * ctr <= max_size_t}) (st: state w) : state w
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv
val add_counter (#w: lanes) (ctr: counter{w * ctr <= max_size_t}) (st: state w) : state w let add_counter (#w: lanes) (ctr: counter{w * ctr <= max_size_t}) (st: state w) : state w =
false
null
false
let cv = vec_load (u32 w *! u32 ctr) w in st.[ 12 ] <- st.[ 12 ] +| cv
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.counter", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Hacl.Spec.Chacha20.Vec.state", "Lib.Sequence.op_String_Assignment", "Hacl.Spec.Chacha20.Vec.uint32xN", "Lib.IntVector.op_Plus_Bar", "Lib.IntTypes.U32", "Lib.Sequence.op_String_Access", "Lib.IntVector.vec_t", "Prims.eq2", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Lib.IntVector.vec_v", "Lib.Sequence.create", "Lib.IntTypes.mul", "Lib.IntTypes.mk_int", "Lib.IntVector.vec_load", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.u32" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_counter (#w: lanes) (ctr: counter{w * ctr <= max_size_t}) (st: state w) : state w
[]
Hacl.Spec.Chacha20.Vec.add_counter
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ctr: Hacl.Spec.Chacha20.Vec.counter{w * ctr <= Lib.IntTypes.max_size_t} -> st: Hacl.Spec.Chacha20.Vec.state w -> Hacl.Spec.Chacha20.Vec.state w
{ "end_col": 26, "end_line": 91, "start_col": 88, "start_line": 89 }
Prims.Tot
val transpose (#w: lanes) (st: state w) : state w
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let transpose (#w:lanes) (st:state w) : state w = match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st
val transpose (#w: lanes) (st: state w) : state w let transpose (#w: lanes) (st: state w) : state w =
false
null
false
match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.state", "Hacl.Spec.Chacha20.Vec.transpose1", "Hacl.Spec.Chacha20.Vec.transpose4", "Hacl.Spec.Chacha20.Vec.transpose8" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c let transpose1 (st:state 1) : state 1 = st let transpose4 (st:state 4) : state 4 = let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st.[0],st.[1],st.[2],st.[3]) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st.[8],st.[9],st.[10],st.[11]) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st.[12],st.[13],st.[14],st.[15]) in create16 v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15 let transpose8 (st:state 8) : state 8 = let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st.[0],st.[1],st.[2],st.[3],st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st.[8],st.[9],st.[10],st.[11],st.[12],st.[13],st.[14],st.[15]) in create16 v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val transpose (#w: lanes) (st: state w) : state w
[]
Hacl.Spec.Chacha20.Vec.transpose
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st: Hacl.Spec.Chacha20.Vec.state w -> Hacl.Spec.Chacha20.Vec.state w
{ "end_col": 22, "end_line": 144, "start_col": 2, "start_line": 141 }
Prims.Tot
val column_round (#w: lanes) : shuffle w
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15
val column_round (#w: lanes) : shuffle w let column_round (#w: lanes) : shuffle w =
false
null
false
quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.op_At", "Hacl.Spec.Chacha20.Vec.state", "Hacl.Spec.Chacha20.Vec.quarter_round", "Hacl.Spec.Chacha20.Vec.shuffle" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7)
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val column_round (#w: lanes) : shuffle w
[]
Hacl.Spec.Chacha20.Vec.column_round
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Spec.Chacha20.Vec.shuffle w
{ "end_col": 25, "end_line": 68, "start_col": 2, "start_line": 65 }
Prims.Tot
val sum_state (#w: lanes) (st1 st2: state w) : state w
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2
val sum_state (#w: lanes) (st1 st2: state w) : state w let sum_state (#w: lanes) (st1 st2: state w) : state w =
false
null
false
map2 ( +| ) st1 st2
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.state", "Lib.Sequence.map2", "Hacl.Spec.Chacha20.Vec.uint32xN", "Lib.IntVector.op_Plus_Bar", "Lib.IntTypes.U32" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m)))))))))
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sum_state (#w: lanes) (st1 st2: state w) : state w
[]
Hacl.Spec.Chacha20.Vec.sum_state
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st1: Hacl.Spec.Chacha20.Vec.state w -> st2: Hacl.Spec.Chacha20.Vec.state w -> Hacl.Spec.Chacha20.Vec.state w
{ "end_col": 19, "end_line": 87, "start_col": 2, "start_line": 87 }
Prims.Tot
val diagonal_round (#w: lanes) : shuffle w
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14
val diagonal_round (#w: lanes) : shuffle w let diagonal_round (#w: lanes) : shuffle w =
false
null
false
quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.op_At", "Hacl.Spec.Chacha20.Vec.state", "Hacl.Spec.Chacha20.Vec.quarter_round", "Hacl.Spec.Chacha20.Vec.shuffle" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val diagonal_round (#w: lanes) : shuffle w
[]
Hacl.Spec.Chacha20.Vec.diagonal_round
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Spec.Chacha20.Vec.shuffle w
{ "end_col": 25, "end_line": 74, "start_col": 2, "start_line": 71 }
Prims.Tot
val xor_block (#w: lanes) (k: state w) (b: blocks w) : blocks w
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let xor_block (#w:lanes) (k:state w) (b:blocks w) : blocks w = map_blocks_multi (w * 4) 16 16 b (xor_block_f #w k)
val xor_block (#w: lanes) (k: state w) (b: blocks w) : blocks w let xor_block (#w: lanes) (k: state w) (b: blocks w) : blocks w =
false
null
false
map_blocks_multi (w * 4) 16 16 b (xor_block_f #w k)
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.state", "Hacl.Spec.Chacha20.Vec.blocks", "Lib.Sequence.map_blocks_multi", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.Chacha20.Vec.xor_block_f" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c let transpose1 (st:state 1) : state 1 = st let transpose4 (st:state 4) : state 4 = let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st.[0],st.[1],st.[2],st.[3]) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st.[8],st.[9],st.[10],st.[11]) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st.[12],st.[13],st.[14],st.[15]) in create16 v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15 let transpose8 (st:state 8) : state 8 = let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st.[0],st.[1],st.[2],st.[3],st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st.[8],st.[9],st.[10],st.[11],st.[12],st.[13],st.[14],st.[15]) in create16 v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15 let transpose (#w:lanes) (st:state w) : state w = match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st // let store_block0 (#w:lanes) (st:state w) : Tot block1 = // let bl = create 64 (u8 0) in // repeati (16 / w) // (fun i bl -> update_sub bl (i * w * 4) (w * 4) (vec_to_bytes_le st.[i])) bl // let chacha20_key_block0 (#w:lanes) (k:key) (n:nonce) : Tot block1 = // let st0 = chacha20_init #w k n 0 in // let k = chacha20_core 0 st0 in // store_block0 k let xor_block_f (#w:lanes) (k:state w) (i:nat{i < 16}) (b:lbytes (w * 4)) : lbytes (w * 4) = let x = vec_from_bytes_le U32 w b in let y = x ^| k.[i] in vec_to_bytes_le y
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val xor_block (#w: lanes) (k: state w) (b: blocks w) : blocks w
[]
Hacl.Spec.Chacha20.Vec.xor_block
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.Chacha20.Vec.state w -> b: Hacl.Spec.Chacha20.Vec.blocks w -> Hacl.Spec.Chacha20.Vec.blocks w
{ "end_col": 53, "end_line": 162, "start_col": 2, "start_line": 162 }
Prims.Tot
val chacha20_encrypt_last: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> len: size_nat{len < w * size_block} -> b: lbytes len -> Tot (lbytes len)
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_encrypt_last #w st0 incr len b = let plain = create (w * size_block) (u8 0) in let plain = update_sub plain 0 len b in let cipher = chacha20_encrypt_block st0 incr plain in sub cipher 0 len
val chacha20_encrypt_last: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> len: size_nat{len < w * size_block} -> b: lbytes len -> Tot (lbytes len) let chacha20_encrypt_last #w st0 incr len b =
false
null
false
let plain = create (w * size_block) (u8 0) in let plain = update_sub plain 0 len b in let cipher = chacha20_encrypt_block st0 incr plain in sub cipher 0 len
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.state", "Hacl.Spec.Chacha20.Vec.counter", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.size_nat", "Prims.op_LessThan", "Hacl.Spec.Chacha20.Vec.size_block", "Lib.ByteSequence.lbytes", "Lib.Sequence.sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Hacl.Spec.Chacha20.Vec.blocks", "Hacl.Spec.Chacha20.Vec.chacha20_encrypt_block", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Prims.op_Multiply", "Prims.l_and", "Prims.eq2", "Prims.l_Forall", "Prims.nat", "Prims.l_or", "Prims.op_Addition", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index", "Lib.Sequence.update_sub", "FStar.Seq.Base.seq", "FStar.Seq.Base.create", "Lib.IntTypes.mk_int", "Prims.l_imp", "Lib.Sequence.create", "Lib.IntTypes.u8" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c let transpose1 (st:state 1) : state 1 = st let transpose4 (st:state 4) : state 4 = let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st.[0],st.[1],st.[2],st.[3]) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st.[8],st.[9],st.[10],st.[11]) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st.[12],st.[13],st.[14],st.[15]) in create16 v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15 let transpose8 (st:state 8) : state 8 = let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st.[0],st.[1],st.[2],st.[3],st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st.[8],st.[9],st.[10],st.[11],st.[12],st.[13],st.[14],st.[15]) in create16 v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15 let transpose (#w:lanes) (st:state w) : state w = match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st // let store_block0 (#w:lanes) (st:state w) : Tot block1 = // let bl = create 64 (u8 0) in // repeati (16 / w) // (fun i bl -> update_sub bl (i * w * 4) (w * 4) (vec_to_bytes_le st.[i])) bl // let chacha20_key_block0 (#w:lanes) (k:key) (n:nonce) : Tot block1 = // let st0 = chacha20_init #w k n 0 in // let k = chacha20_core 0 st0 in // store_block0 k let xor_block_f (#w:lanes) (k:state w) (i:nat{i < 16}) (b:lbytes (w * 4)) : lbytes (w * 4) = let x = vec_from_bytes_le U32 w b in let y = x ^| k.[i] in vec_to_bytes_le y let xor_block (#w:lanes) (k:state w) (b:blocks w) : blocks w = map_blocks_multi (w * 4) 16 16 b (xor_block_f #w k) val chacha20_encrypt_block: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> b: blocks w -> Tot (blocks w) let chacha20_encrypt_block #w st0 incr b = let k = chacha20_core incr st0 in let k = transpose k in xor_block k b val chacha20_encrypt_last: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> len: size_nat{len < w * size_block} -> b: lbytes len ->
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val chacha20_encrypt_last: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> len: size_nat{len < w * size_block} -> b: lbytes len -> Tot (lbytes len)
[]
Hacl.Spec.Chacha20.Vec.chacha20_encrypt_last
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st0: Hacl.Spec.Chacha20.Vec.state w -> incr: Hacl.Spec.Chacha20.Vec.counter{incr * w <= Lib.IntTypes.max_size_t} -> len: Lib.IntTypes.size_nat{len < w * Hacl.Spec.Chacha20.Vec.size_block} -> b: Lib.ByteSequence.lbytes len -> Lib.ByteSequence.lbytes len
{ "end_col": 18, "end_line": 186, "start_col": 45, "start_line": 182 }
Prims.Tot
val chacha20_update: #w:lanes -> st0: state w -> msg: bytes{length msg <= max_size_t} -> cipher: bytes{length cipher == length msg}
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_update #w st0 msg = let cipher = msg in map_blocks (w * size_block) cipher (chacha20_encrypt_block st0) (chacha20_encrypt_last st0)
val chacha20_update: #w:lanes -> st0: state w -> msg: bytes{length msg <= max_size_t} -> cipher: bytes{length cipher == length msg} let chacha20_update #w st0 msg =
false
null
false
let cipher = msg in map_blocks (w * size_block) cipher (chacha20_encrypt_block st0) (chacha20_encrypt_last st0)
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.state", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.max_size_t", "Lib.Sequence.map_blocks", "FStar.Mul.op_Star", "Hacl.Spec.Chacha20.Vec.size_block", "Hacl.Spec.Chacha20.Vec.chacha20_encrypt_block", "Hacl.Spec.Chacha20.Vec.chacha20_encrypt_last", "Lib.Sequence.seq", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.eq2", "Prims.nat" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c let transpose1 (st:state 1) : state 1 = st let transpose4 (st:state 4) : state 4 = let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st.[0],st.[1],st.[2],st.[3]) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st.[8],st.[9],st.[10],st.[11]) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st.[12],st.[13],st.[14],st.[15]) in create16 v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15 let transpose8 (st:state 8) : state 8 = let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st.[0],st.[1],st.[2],st.[3],st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st.[8],st.[9],st.[10],st.[11],st.[12],st.[13],st.[14],st.[15]) in create16 v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15 let transpose (#w:lanes) (st:state w) : state w = match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st // let store_block0 (#w:lanes) (st:state w) : Tot block1 = // let bl = create 64 (u8 0) in // repeati (16 / w) // (fun i bl -> update_sub bl (i * w * 4) (w * 4) (vec_to_bytes_le st.[i])) bl // let chacha20_key_block0 (#w:lanes) (k:key) (n:nonce) : Tot block1 = // let st0 = chacha20_init #w k n 0 in // let k = chacha20_core 0 st0 in // store_block0 k let xor_block_f (#w:lanes) (k:state w) (i:nat{i < 16}) (b:lbytes (w * 4)) : lbytes (w * 4) = let x = vec_from_bytes_le U32 w b in let y = x ^| k.[i] in vec_to_bytes_le y let xor_block (#w:lanes) (k:state w) (b:blocks w) : blocks w = map_blocks_multi (w * 4) 16 16 b (xor_block_f #w k) val chacha20_encrypt_block: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> b: blocks w -> Tot (blocks w) let chacha20_encrypt_block #w st0 incr b = let k = chacha20_core incr st0 in let k = transpose k in xor_block k b val chacha20_encrypt_last: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> len: size_nat{len < w * size_block} -> b: lbytes len -> Tot (lbytes len) let chacha20_encrypt_last #w st0 incr len b = let plain = create (w * size_block) (u8 0) in let plain = update_sub plain 0 len b in let cipher = chacha20_encrypt_block st0 incr plain in sub cipher 0 len val chacha20_update: #w:lanes -> st0: state w -> msg: bytes{length msg <= max_size_t}
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val chacha20_update: #w:lanes -> st0: state w -> msg: bytes{length msg <= max_size_t} -> cipher: bytes{length cipher == length msg}
[]
Hacl.Spec.Chacha20.Vec.chacha20_update
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st0: Hacl.Spec.Chacha20.Vec.state w -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length msg <= Lib.IntTypes.max_size_t} -> cipher: Lib.ByteSequence.bytes{Lib.Sequence.length cipher == Lib.Sequence.length msg}
{ "end_col": 31, "end_line": 197, "start_col": 32, "start_line": 193 }
Prims.Tot
val chacha20_init (#w: lanes) (k: key) (n: nonce) (ctr0: counter) : state w
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c
val chacha20_init (#w: lanes) (k: key) (n: nonce) (ctr0: counter) : state w let chacha20_init (#w: lanes) (k: key) (n: nonce) (ctr0: counter) : state w =
false
null
false
let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[ 12 ] <- st.[ 12 ] +| c
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.key", "Hacl.Spec.Chacha20.Vec.nonce", "Hacl.Spec.Chacha20.Vec.counter", "Lib.Sequence.op_String_Assignment", "Hacl.Spec.Chacha20.Vec.uint32xN", "Lib.IntVector.op_Plus_Bar", "Lib.IntTypes.U32", "Lib.Sequence.op_String_Access", "Lib.IntVector.vec_t", "Prims.eq2", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Lib.IntVector.vec_v", "Lib.Sequence.createi", "Lib.IntTypes.mk_int", "Lib.IntVector.vec_counter", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.index", "Hacl.Spec.Chacha20.Vec.vec_load_i", "Lib.Sequence.map", "Lib.IntTypes.uint32", "Hacl.Spec.Chacha20.Vec.setup1", "Hacl.Spec.Chacha20.Vec.state" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val chacha20_init (#w: lanes) (k: key) (n: nonce) (ctr0: counter) : state w
[]
Hacl.Spec.Chacha20.Vec.chacha20_init
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.Chacha20.Vec.key -> n: Hacl.Spec.Chacha20.Vec.nonce -> ctr0: Hacl.Spec.Chacha20.Vec.counter -> Hacl.Spec.Chacha20.Vec.state w
{ "end_col": 25, "end_line": 124, "start_col": 73, "start_line": 120 }
Prims.Tot
val setup1 (k: key) (n: nonce) (ctr0: counter) : lseq uint32 16
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0))
val setup1 (k: key) (n: nonce) (ctr0: counter) : lseq uint32 16 let setup1 (k: key) (n: nonce) (ctr0: counter) : lseq uint32 16 =
false
null
false
Scalar.setup k n ctr0 (create 16 (u32 0))
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.key", "Hacl.Spec.Chacha20.Vec.nonce", "Hacl.Spec.Chacha20.Vec.counter", "Spec.Chacha20.setup", "Lib.Sequence.create", "Lib.IntTypes.uint32", "Lib.IntTypes.u32", "Lib.Sequence.lseq" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val setup1 (k: key) (n: nonce) (ctr0: counter) : lseq uint32 16
[]
Hacl.Spec.Chacha20.Vec.setup1
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.Chacha20.Vec.key -> n: Hacl.Spec.Chacha20.Vec.nonce -> ctr0: Hacl.Spec.Chacha20.Vec.counter -> Lib.Sequence.lseq Lib.IntTypes.uint32 16
{ "end_col": 43, "end_line": 115, "start_col": 2, "start_line": 115 }
Prims.Tot
val line (#w: lanes) (a b d: idx) (s: rotval U32) (m: state w) : state w
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m
val line (#w: lanes) (a b d: idx) (s: rotval U32) (m: state w) : state w let line (#w: lanes) (a b d: idx) (s: rotval U32) (m: state w) : state w =
false
null
false
let m = m.[ a ] <- m.[ a ] +| m.[ b ] in let m = m.[ d ] <- (m.[ d ] ^| m.[ a ]) <<<| s in m
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.idx", "Lib.IntTypes.rotval", "Lib.IntTypes.U32", "Hacl.Spec.Chacha20.Vec.state", "Lib.Sequence.lseq", "Hacl.Spec.Chacha20.Vec.uint32xN", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Lib.IntVector.op_Less_Less_Less_Bar", "Lib.IntVector.op_Hat_Bar", "Lib.Sequence.index", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.l_imp", "Prims.op_LessThan", "Prims.op_disEquality", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.op_String_Assignment", "Lib.Sequence.op_String_Access", "Lib.IntVector.op_Plus_Bar" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x)
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val line (#w: lanes) (a b d: idx) (s: rotval U32) (m: state w) : state w
[]
Hacl.Spec.Chacha20.Vec.line
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Chacha20.Vec.idx -> b: Hacl.Spec.Chacha20.Vec.idx -> d: Hacl.Spec.Chacha20.Vec.idx -> s: Lib.IntTypes.rotval Lib.IntTypes.U32 -> m: Hacl.Spec.Chacha20.Vec.state w -> Hacl.Spec.Chacha20.Vec.state w
{ "end_col": 3, "end_line": 56, "start_col": 82, "start_line": 53 }
Prims.Tot
val chacha20_constants:lseq size_t 4
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l
val chacha20_constants:lseq size_t 4 let chacha20_constants:lseq size_t 4 =
false
null
false
[@@ inline_let ]let l = [c0; c1; c2; c3] in assert_norm (List.Tot.length l == 4); createL l
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Lib.Sequence.createL", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "Prims.Cons", "Hacl.Spec.Chacha20.Vec.c0", "Hacl.Spec.Chacha20.Vec.c1", "Hacl.Spec.Chacha20.Vec.c2", "Hacl.Spec.Chacha20.Vec.c3", "Prims.Nil" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val chacha20_constants:lseq size_t 4
[]
Hacl.Spec.Chacha20.Vec.chacha20_constants
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB) 4
{ "end_col": 11, "end_line": 112, "start_col": 2, "start_line": 109 }
Prims.Tot
val transpose1 (st: state 1) : state 1
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let transpose1 (st:state 1) : state 1 = st
val transpose1 (st: state 1) : state 1 let transpose1 (st: state 1) : state 1 =
false
null
false
st
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.state" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val transpose1 (st: state 1) : state 1
[]
Hacl.Spec.Chacha20.Vec.transpose1
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st: Hacl.Spec.Chacha20.Vec.state 1 -> Hacl.Spec.Chacha20.Vec.state 1
{ "end_col": 42, "end_line": 126, "start_col": 40, "start_line": 126 }
Prims.Tot
val xor_block_f (#w: lanes) (k: state w) (i: nat{i < 16}) (b: lbytes (w * 4)) : lbytes (w * 4)
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let xor_block_f (#w:lanes) (k:state w) (i:nat{i < 16}) (b:lbytes (w * 4)) : lbytes (w * 4) = let x = vec_from_bytes_le U32 w b in let y = x ^| k.[i] in vec_to_bytes_le y
val xor_block_f (#w: lanes) (k: state w) (i: nat{i < 16}) (b: lbytes (w * 4)) : lbytes (w * 4) let xor_block_f (#w: lanes) (k: state w) (i: nat{i < 16}) (b: lbytes (w * 4)) : lbytes (w * 4) =
false
null
false
let x = vec_from_bytes_le U32 w b in let y = x ^| k.[ i ] in vec_to_bytes_le y
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.state", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.ByteSequence.lbytes", "FStar.Mul.op_Star", "Lib.IntVector.vec_to_bytes_le", "Lib.IntTypes.U32", "Lib.IntVector.vec_t", "Lib.IntVector.op_Hat_Bar", "Lib.Sequence.op_String_Access", "Hacl.Spec.Chacha20.Vec.uint32xN", "Lib.IntVector.vec_from_bytes_le" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c let transpose1 (st:state 1) : state 1 = st let transpose4 (st:state 4) : state 4 = let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st.[0],st.[1],st.[2],st.[3]) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st.[8],st.[9],st.[10],st.[11]) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st.[12],st.[13],st.[14],st.[15]) in create16 v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15 let transpose8 (st:state 8) : state 8 = let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st.[0],st.[1],st.[2],st.[3],st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st.[8],st.[9],st.[10],st.[11],st.[12],st.[13],st.[14],st.[15]) in create16 v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15 let transpose (#w:lanes) (st:state w) : state w = match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st // let store_block0 (#w:lanes) (st:state w) : Tot block1 = // let bl = create 64 (u8 0) in // repeati (16 / w) // (fun i bl -> update_sub bl (i * w * 4) (w * 4) (vec_to_bytes_le st.[i])) bl // let chacha20_key_block0 (#w:lanes) (k:key) (n:nonce) : Tot block1 = // let st0 = chacha20_init #w k n 0 in // let k = chacha20_core 0 st0 in // store_block0 k
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val xor_block_f (#w: lanes) (k: state w) (i: nat{i < 16}) (b: lbytes (w * 4)) : lbytes (w * 4)
[]
Hacl.Spec.Chacha20.Vec.xor_block_f
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.Chacha20.Vec.state w -> i: Prims.nat{i < 16} -> b: Lib.ByteSequence.lbytes (w * 4) -> Lib.ByteSequence.lbytes (w * 4)
{ "end_col": 19, "end_line": 159, "start_col": 92, "start_line": 156 }
Prims.Tot
val transpose_state (#w: lanes) (st: state w) : lseq (lseq uint32 16) w
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x)
val transpose_state (#w: lanes) (st: state w) : lseq (lseq uint32 16) w let transpose_state (#w: lanes) (st: state w) : lseq (lseq uint32 16) w =
false
null
false
createi w (fun i -> let x:lseq uint32 16 = create16 (vec_v st.[ 0 ]).[ i ] (vec_v st.[ 1 ]).[ i ] (vec_v st.[ 2 ]).[ i ] (vec_v st.[ 3 ]).[ i ] (vec_v st.[ 4 ]).[ i ] (vec_v st.[ 5 ]).[ i ] (vec_v st.[ 6 ]).[ i ] (vec_v st.[ 7 ]).[ i ] (vec_v st.[ 8 ]).[ i ] (vec_v st.[ 9 ]).[ i ] (vec_v st.[ 10 ]).[ i ] (vec_v st.[ 11 ]).[ i ] (vec_v st.[ 12 ]).[ i ] (vec_v st.[ 13 ]).[ i ] (vec_v st.[ 14 ]).[ i ] (vec_v st.[ 15 ]).[ i ] in x)
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.lanes", "Hacl.Spec.Chacha20.Vec.state", "Lib.Sequence.createi", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.create16", "Lib.Sequence.op_String_Access", "Lib.IntTypes.uint_t", "Lib.IntVector.vec_v", "Hacl.Spec.Chacha20.Vec.uint32xN", "Lib.IntTypes.uint32" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val transpose_state (#w: lanes) (st: state w) : lseq (lseq uint32 16) w
[]
Hacl.Spec.Chacha20.Vec.transpose_state
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st: Hacl.Spec.Chacha20.Vec.state w -> Lib.Sequence.lseq (Lib.Sequence.lseq Lib.IntTypes.uint32 16) w
{ "end_col": 6, "end_line": 50, "start_col": 2, "start_line": 44 }
Prims.Tot
val transpose4 (st: state 4) : state 4
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let transpose4 (st:state 4) : state 4 = let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st.[0],st.[1],st.[2],st.[3]) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st.[8],st.[9],st.[10],st.[11]) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st.[12],st.[13],st.[14],st.[15]) in create16 v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15
val transpose4 (st: state 4) : state 4 let transpose4 (st: state 4) : state 4 =
false
null
false
let v0, v1, v2, v3 = VecTranspose.transpose4x4 (st.[ 0 ], st.[ 1 ], st.[ 2 ], st.[ 3 ]) in let v4, v5, v6, v7 = VecTranspose.transpose4x4 (st.[ 4 ], st.[ 5 ], st.[ 6 ], st.[ 7 ]) in let v8, v9, v10, v11 = VecTranspose.transpose4x4 (st.[ 8 ], st.[ 9 ], st.[ 10 ], st.[ 11 ]) in let v12, v13, v14, v15 = VecTranspose.transpose4x4 (st.[ 12 ], st.[ 13 ], st.[ 14 ], st.[ 15 ]) in create16 v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.state", "Lib.IntVector.vec_t", "Lib.IntTypes.U32", "Lib.Sequence.create16", "Hacl.Spec.Chacha20.Vec.uint32xN", "Lib.IntVector.Transpose.vec_t4", "Lib.IntVector.Transpose.transpose4x4", "FStar.Pervasives.Native.Mktuple4", "Lib.Sequence.op_String_Access" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c let transpose1 (st:state 1) : state 1 = st
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val transpose4 (st: state 4) : state 4
[]
Hacl.Spec.Chacha20.Vec.transpose4
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st: Hacl.Spec.Chacha20.Vec.state 4 -> Hacl.Spec.Chacha20.Vec.state 4
{ "end_col": 64, "end_line": 133, "start_col": 39, "start_line": 128 }
Prims.Tot
val transpose8 (st: state 8) : state 8
[ { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Scalar" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let transpose8 (st:state 8) : state 8 = let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st.[0],st.[1],st.[2],st.[3],st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st.[8],st.[9],st.[10],st.[11],st.[12],st.[13],st.[14],st.[15]) in create16 v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15
val transpose8 (st: state 8) : state 8 let transpose8 (st: state 8) : state 8 =
false
null
false
let v0, v1, v2, v3, v4, v5, v6, v7 = VecTranspose.transpose8x8 (st.[ 0 ], st.[ 1 ], st.[ 2 ], st.[ 3 ], st.[ 4 ], st.[ 5 ], st.[ 6 ], st.[ 7 ]) in let v8, v9, v10, v11, v12, v13, v14, v15 = VecTranspose.transpose8x8 (st.[ 8 ], st.[ 9 ], st.[ 10 ], st.[ 11 ], st.[ 12 ], st.[ 13 ], st.[ 14 ], st.[ 15 ]) in create16 v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15
{ "checked_file": "Hacl.Spec.Chacha20.Vec.fst.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Chacha20.Vec.fst" }
[ "total" ]
[ "Hacl.Spec.Chacha20.Vec.state", "Lib.IntVector.vec_t", "Lib.IntTypes.U32", "Lib.Sequence.create16", "Hacl.Spec.Chacha20.Vec.uint32xN", "Lib.IntVector.Transpose.vec_t8", "Lib.IntVector.Transpose.transpose8x8", "FStar.Pervasives.Native.Mktuple8", "Lib.Sequence.op_String_Access" ]
[]
module Hacl.Spec.Chacha20.Vec open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Lib.IntVector module Scalar = Spec.Chacha20 module VecTranspose = Lib.IntVector.Transpose #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 type key = lbytes size_key type block1 = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers let lanes = n:width{n == 1 \/ n == 4 \/ n == 8} inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w type state (w:lanes) = lseq (uint32xN w) 16 type idx = n:size_nat{n < 16} type shuffle (w:lanes) = state w -> state w type blocks (w:lanes) = lbytes (w * 64) // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let transpose_state (#w:lanes) (st:state w) : lseq (lseq uint32 16) w = createi w (fun i -> let x : lseq uint32 16 = create16 (vec_v st.[0]).[i] (vec_v st.[1]).[i] (vec_v st.[2]).[i] (vec_v st.[3]).[i] (vec_v st.[4]).[i] (vec_v st.[5]).[i] (vec_v st.[6]).[i] (vec_v st.[7]).[i] (vec_v st.[8]).[i] (vec_v st.[9]).[i] (vec_v st.[10]).[i] (vec_v st.[11]).[i] (vec_v st.[12]).[i] (vec_v st.[13]).[i] (vec_v st.[14]).[i] (vec_v st.[15]).[i] in x) let line (#w:lanes) (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state w) : state w = let m = m.[a] <- m.[a] +| m.[b] in let m = m.[d] <- (m.[d] ^| m.[a]) <<<| s in m let quarter_round (#w:lanes) a b c d : shuffle w = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round (#w:lanes) : shuffle w = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round (#w:lanes) : shuffle w = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round (#w:lanes) : shuffle w = column_round @ diagonal_round (* 2 rounds *) let rounds (#w:lanes) (m:state w) : state w = double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round ( double_round (double_round m))))))))) let sum_state (#w:lanes) (st1:state w) (st2:state w) : state w = map2 (+|) st1 st2 let add_counter (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (st:state w) : state w = let cv = vec_load (u32 w *! u32 ctr) w in st.[12] <- st.[12] +| cv let chacha20_core (#w:lanes) (ctr:counter{w * ctr <= max_size_t}) (s0:state w) : state w = let k = add_counter ctr s0 in let k = rounds k in let k = sum_state k s0 in add_counter ctr k inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup1 (k:key) (n:nonce) (ctr0:counter) : lseq uint32 16 = Scalar.setup k n ctr0 (create 16 (u32 0)) inline_for_extraction let vec_load_i (#t:v_inttype) (w:width) (x:uint_t t SEC) = vec_load #t x w let chacha20_init (#w:lanes) (k:key) (n:nonce) (ctr0:counter) : state w = let st1 = setup1 k n ctr0 in let st = map (vec_load_i w) st1 in let c = vec_counter U32 w in st.[12] <- st.[12] +| c let transpose1 (st:state 1) : state 1 = st let transpose4 (st:state 4) : state 4 = let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st.[0],st.[1],st.[2],st.[3]) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st.[4],st.[5],st.[6],st.[7]) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st.[8],st.[9],st.[10],st.[11]) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st.[12],st.[13],st.[14],st.[15]) in create16 v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15
false
false
Hacl.Spec.Chacha20.Vec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val transpose8 (st: state 8) : state 8
[]
Hacl.Spec.Chacha20.Vec.transpose8
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st: Hacl.Spec.Chacha20.Vec.state 8 -> Hacl.Spec.Chacha20.Vec.state 8
{ "end_col": 64, "end_line": 138, "start_col": 39, "start_line": 135 }
FStar.Tactics.Effect.Tac
val squash_and_elim (t: term) : Tac unit
[ { "abbrev": false, "full_module": "FStar.Reflection.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "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 squash_and_elim (t : term) : Tac unit = let ae = `__squash_and_elim in apply_lemma (mk_e_app ae [t])
val squash_and_elim (t: term) : Tac unit let squash_and_elim (t: term) : Tac unit =
true
null
false
let ae = `__squash_and_elim in apply_lemma (mk_e_app ae [t])
{ "checked_file": "Vale.Lib.Tactics.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Derived.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Formula.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Tactics.fst" }
[]
[ "FStar.Reflection.Types.term", "FStar.Tactics.V1.Derived.apply_lemma", "FStar.Reflection.V1.Derived.mk_e_app", "Prims.Cons", "Prims.Nil", "Prims.unit" ]
[]
module Vale.Lib.Tactics open FStar.Mul open FStar.Tactics open FStar.Tactics.Derived open FStar.Reflection.Formula (***** Tactic to destruct conjuctions in context *) private val __squash_and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __squash_and_elim #p #q #phi p_and_q f = ()
false
false
Vale.Lib.Tactics.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 squash_and_elim (t: term) : Tac unit
[]
Vale.Lib.Tactics.squash_and_elim
{ "file_name": "vale/code/lib/util/Vale.Lib.Tactics.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 33, "end_line": 18, "start_col": 43, "start_line": 16 }
FStar.Tactics.Effect.Tac
val tf (t: term) : Tot (term -> Tac unit)
[ { "abbrev": false, "full_module": "FStar.Reflection.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "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 tf (t : term) : Tot (term -> Tac unit) = match unsquash_term t with | None -> and_elim | _ -> squash_and_elim
val tf (t: term) : Tot (term -> Tac unit) let tf (t: term) : Tot (term -> Tac unit) =
true
null
false
match unsquash_term t with | None -> and_elim | _ -> squash_and_elim
{ "checked_file": "Vale.Lib.Tactics.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Derived.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Formula.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Tactics.fst" }
[]
[ "FStar.Reflection.Types.term", "FStar.Reflection.V1.Derived.unsquash_term", "FStar.Tactics.V1.Logic.and_elim", "FStar.Pervasives.Native.option", "Vale.Lib.Tactics.squash_and_elim", "Prims.unit" ]
[]
module Vale.Lib.Tactics open FStar.Mul open FStar.Tactics open FStar.Tactics.Derived open FStar.Reflection.Formula (***** Tactic to destruct conjuctions in context *) private val __squash_and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __squash_and_elim #p #q #phi p_and_q f = () let squash_and_elim (t : term) : Tac unit = let ae = `__squash_and_elim in apply_lemma (mk_e_app ae [t])
false
false
Vale.Lib.Tactics.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 tf (t: term) : Tot (term -> Tac unit)
[]
Vale.Lib.Tactics.tf
{ "file_name": "vale/code/lib/util/Vale.Lib.Tactics.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: FStar.Reflection.Types.term -> _: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 24, "end_line": 23, "start_col": 2, "start_line": 21 }
FStar.Tactics.Effect.Tac
val destruct_conj: Prims.unit -> Tac unit
[ { "abbrev": false, "full_module": "FStar.Reflection.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "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 destruct_conj () : Tac unit = let e = cur_env () in iterate_env (binders_of_env e)
val destruct_conj: Prims.unit -> Tac unit let destruct_conj () : Tac unit =
true
null
false
let e = cur_env () in iterate_env (binders_of_env e)
{ "checked_file": "Vale.Lib.Tactics.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Derived.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Formula.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Tactics.fst" }
[]
[ "Prims.unit", "Vale.Lib.Tactics.iterate_env", "FStar.Reflection.V1.Builtins.binders_of_env", "FStar.Reflection.Types.env", "FStar.Tactics.V1.Derived.cur_env" ]
[]
module Vale.Lib.Tactics open FStar.Mul open FStar.Tactics open FStar.Tactics.Derived open FStar.Reflection.Formula (***** Tactic to destruct conjuctions in context *) private val __squash_and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __squash_and_elim #p #q #phi p_and_q f = () let squash_and_elim (t : term) : Tac unit = let ae = `__squash_and_elim in apply_lemma (mk_e_app ae [t]) let tf (t : term) : Tot (term -> Tac unit) = match unsquash_term t with | None -> and_elim | _ -> squash_and_elim let rec iterate_env (bs : binders) : Tac unit = match bs with | [] -> () | b :: bs -> let ty = type_of_binder b in let elim = tf ty in begin match term_as_formula_total ty with | And _ _ -> elim (pack (Tv_Var (bv_of_binder b))); clear b; let t1 = implies_intro () in let t2 = implies_intro () in iterate_env (t1 :: t2 :: bs) | _ -> iterate_env bs end
false
false
Vale.Lib.Tactics.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 destruct_conj: Prims.unit -> Tac unit
[]
Vale.Lib.Tactics.destruct_conj
{ "file_name": "vale/code/lib/util/Vale.Lib.Tactics.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 33, "end_line": 45, "start_col": 33, "start_line": 43 }
FStar.Tactics.Effect.Tac
val iterate_env (bs: binders) : Tac unit
[ { "abbrev": false, "full_module": "FStar.Reflection.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec iterate_env (bs : binders) : Tac unit = match bs with | [] -> () | b :: bs -> let ty = type_of_binder b in let elim = tf ty in begin match term_as_formula_total ty with | And _ _ -> elim (pack (Tv_Var (bv_of_binder b))); clear b; let t1 = implies_intro () in let t2 = implies_intro () in iterate_env (t1 :: t2 :: bs) | _ -> iterate_env bs end
val iterate_env (bs: binders) : Tac unit let rec iterate_env (bs: binders) : Tac unit =
true
null
false
match bs with | [] -> () | b :: bs -> let ty = type_of_binder b in let elim = tf ty in match term_as_formula_total ty with | And _ _ -> elim (pack (Tv_Var (bv_of_binder b))); clear b; let t1 = implies_intro () in let t2 = implies_intro () in iterate_env (t1 :: t2 :: bs) | _ -> iterate_env bs
{ "checked_file": "Vale.Lib.Tactics.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Derived.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.Formula.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Tactics.fst" }
[]
[ "FStar.Reflection.Types.binders", "Prims.unit", "FStar.Reflection.Types.binder", "Prims.list", "FStar.Reflection.Types.term", "Vale.Lib.Tactics.iterate_env", "Prims.Cons", "FStar.Tactics.V1.Logic.implies_intro", "FStar.Tactics.V1.Builtins.clear", "FStar.Tactics.V1.Builtins.pack", "FStar.Reflection.V1.Data.Tv_Var", "FStar.Reflection.V1.Derived.bv_of_binder", "FStar.Reflection.V1.Formula.formula", "FStar.Reflection.V1.Formula.term_as_formula_total", "Vale.Lib.Tactics.tf", "FStar.Reflection.Types.typ", "FStar.Reflection.V1.Derived.type_of_binder" ]
[]
module Vale.Lib.Tactics open FStar.Mul open FStar.Tactics open FStar.Tactics.Derived open FStar.Reflection.Formula (***** Tactic to destruct conjuctions in context *) private val __squash_and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __squash_and_elim #p #q #phi p_and_q f = () let squash_and_elim (t : term) : Tac unit = let ae = `__squash_and_elim in apply_lemma (mk_e_app ae [t]) let tf (t : term) : Tot (term -> Tac unit) = match unsquash_term t with | None -> and_elim | _ -> squash_and_elim
false
false
Vale.Lib.Tactics.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 iterate_env (bs: binders) : Tac unit
[ "recursion" ]
Vale.Lib.Tactics.iterate_env
{ "file_name": "vale/code/lib/util/Vale.Lib.Tactics.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bs: FStar.Reflection.Types.binders -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 11, "end_line": 40, "start_col": 4, "start_line": 26 }
Prims.Tot
val set_to_one (q: quad32) : quad32
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let set_to_one (q:quad32) : quad32 = Mkfour 1 q.lo1 q.hi2 q.hi3
val set_to_one (q: quad32) : quad32 let set_to_one (q: quad32) : quad32 =
false
null
false
Mkfour 1 q.lo1 q.hi2 q.hi3
{ "checked_file": "Vale.AES.GCM_BE.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE_s.fst.checked", "Vale.AES.GHash_BE.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCTR_BE.fsti.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.GCM_BE_s.fst.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.GCM_BE.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.quad32", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3" ]
[]
module Vale.AES.GCM_BE open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_BE_s open Vale.AES.AES_BE_s open Vale.AES.GCM_helpers_BE open Vale.AES.GCTR_BE_s open Vale.AES.GCTR_BE open Vale.AES.GHash_BE_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open FStar.Calc open Vale.AES.GHash_BE
false
true
Vale.AES.GCM_BE.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 set_to_one (q: quad32) : quad32
[]
Vale.AES.GCM_BE.set_to_one
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM_BE.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32
{ "end_col": 63, "end_line": 21, "start_col": 37, "start_line": 21 }
Prims.Pure
val gcm_decrypt_BE_tag (alg: algorithm) (key: seq nat8) (iv: supported_iv_BE) (cipher auth: seq nat8) : Pure (seq nat8) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32) (ensures fun t -> True)
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gcm_decrypt_BE_tag (alg:algorithm) (key:seq nat8) (iv:supported_iv_BE) (cipher:seq nat8) (auth:seq nat8) : Pure (seq nat8) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32 ) (ensures fun t -> True) = let key_BE = seq_nat8_to_seq_nat32_BE key in let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_BE iv in let lengths_BE = two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length cipher))) in let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits cipher) in let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in let s_BE = ghash_BE h_BE hash_input_BE in let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in t
val gcm_decrypt_BE_tag (alg: algorithm) (key: seq nat8) (iv: supported_iv_BE) (cipher auth: seq nat8) : Pure (seq nat8) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32) (ensures fun t -> True) let gcm_decrypt_BE_tag (alg: algorithm) (key: seq nat8) (iv: supported_iv_BE) (cipher auth: seq nat8) : Pure (seq nat8) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32) (ensures fun t -> True) =
false
null
false
let key_BE = seq_nat8_to_seq_nat32_BE key in let h_BE = aes_encrypt_word alg key_BE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_BE iv in let lengths_BE = two_two_to_four (Mktwo (nat_to_two 32 (8 * length auth)) (nat_to_two 32 (8 * length cipher))) in let zero_padded_c_BE = be_bytes_to_seq_quad32 (pad_to_128_bits cipher) in let zero_padded_a_BE = be_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_BE = append zero_padded_a_BE (append zero_padded_c_BE (create 1 lengths_BE)) in let s_BE = ghash_BE h_BE hash_input_BE in let t = gctr_encrypt j0_BE (be_quad32_to_bytes s_BE) alg key_BE in t
{ "checked_file": "Vale.AES.GCM_BE.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE_s.fst.checked", "Vale.AES.GHash_BE.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCTR_BE.fsti.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.GCM_BE_s.fst.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.GCM_BE.fsti" }
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Vale.AES.GCM_BE_s.supported_iv_BE", "Vale.AES.GCTR_BE_s.gctr_encrypt", "Vale.Arch.Types.be_quad32_to_bytes", "Vale.Def.Types_s.quad32", "Vale.AES.GHash_BE_s.ghash_BE", "FStar.Seq.Base.append", "FStar.Seq.Base.create", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "Vale.AES.GCTR_BE_s.pad_to_128_bits", "Vale.Def.Words_s.four", "Vale.Def.Words_s.natN", "Prims.pow2", "Vale.Def.Words.Four_s.two_two_to_four", "Vale.Def.Words_s.Mktwo", "Vale.Def.Words_s.two", "Vale.Def.Words.Two_s.nat_to_two", "FStar.Mul.op_Star", "FStar.Seq.Base.length", "Vale.AES.GCM_BE_s.compute_iv_BE", "Vale.AES.AES_BE_s.aes_encrypt_word", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.nat32", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_BE", "Prims.l_and", "Vale.AES.AES_common_s.is_aes_key", "Prims.b2t", "Prims.op_LessThan", "Vale.Def.Words_s.pow2_32", "Prims.l_True" ]
[]
module Vale.AES.GCM_BE open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.GCM_BE_s open Vale.AES.AES_BE_s open Vale.AES.GCM_helpers_BE open Vale.AES.GCTR_BE_s open Vale.AES.GCTR_BE open Vale.AES.GHash_BE_s open FStar.Mul open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open FStar.Calc open Vale.AES.GHash_BE let set_to_one (q:quad32) : quad32 = Mkfour 1 q.lo1 q.hi2 q.hi3 val lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_BE) (num_bytes:nat64) (h_BE j0:quad32) : Lemma (requires length iv_extra_b == 1 /\ length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\ num_bytes == 96/8 /\ (let iv_BE = index iv_extra_b 0 in j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\ (let raw_quads = append iv_b iv_extra_b in let iv_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE raw_quads)) 0 num_bytes in iv_bytes == iv)) (ensures j0 == compute_iv_BE h_BE iv) val lemma_compute_iv_hard (iv:supported_iv_BE) (quads:seq quad32) (length_quad h_BE j0:quad32) : Lemma (requires ~(length iv == 96/8) /\ quads == be_bytes_to_seq_quad32 (pad_to_128_bits iv) /\ j0 == ghash_incremental h_BE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\ length_quad == two_two_to_four (Mktwo (nat_to_two 32 0) (nat_to_two 32 (8 * length iv)))) (ensures j0 == compute_iv_BE h_BE iv) val lemma_length_simplifier (s bytes t:seq quad32) (num_bytes:nat) : Lemma (requires t == (if num_bytes > (length s) * 16 then append s bytes else s) /\ (num_bytes <= (length s) * 16 ==> num_bytes == (length s * 16)) /\ length s * 16 <= num_bytes /\ num_bytes < length s * 16 + 16 /\ length bytes == 1 ) (ensures slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE t)) 0 num_bytes == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (append s bytes))) 0 num_bytes) val gcm_blocks_helper_simplified (alg:algorithm) (key:seq nat32) (a128 a_bytes p128 p_bytes c128 c_bytes:seq quad32) (p_num_bytes a_num_bytes:nat) (iv:supported_iv_BE) (j0_BE h enc_hash length_quad:quad32) : Lemma (requires // Required by gcm_blocks length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\ a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_word alg key /\ j0_BE == compute_iv_BE h iv /\ h = aes_encrypt_word alg key (Mkfour 0 0 0 0) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\ length_quad == two_two_to_four (Mktwo (nat_to_two 32 (8 * a_num_bytes)) (nat_to_two 32 (8 * p_num_bytes))) /\ (let ctr_BE_1:quad32 = j0_BE in let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > length p128 * 16 then append p128 p_bytes else p128 in let cipher:seq quad32 = if p_num_bytes > length p128 * 16 then append c128 c_bytes else c128 in let cipher_bound:nat = length p128 + (if p_num_bytes > length p128 * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\ (let auth_raw_quads = if a_num_bytes > length a128 * 16 then append a128 a_bytes else a128 in let auth_input_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE auth_raw_quads)) 0 a_num_bytes in let auth_padded_bytes = pad_to_128_bits auth_input_bytes in let auth_quads = be_bytes_to_seq_quad32 auth_padded_bytes in let raw_quads = append auth_quads c128 in let total_bytes = length auth_quads * 16 + p_num_bytes in let raw_quads = if p_num_bytes > length p128 * 16 then let raw_quads = append raw_quads c_bytes in let input_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE raw_quads)) 0 total_bytes in let input_padded_bytes = pad_to_128_bits input_bytes in be_bytes_to_seq_quad32 input_padded_bytes else raw_quads in let final_quads = append raw_quads (create 1 length_quad) in enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_BE h final_quads) alg key 0 ))) (ensures (let auth_raw_quads = append a128 a_bytes in let auth_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE auth_raw_quads)) 0 a_num_bytes in let plain_raw_quads = append p128 p_bytes in let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain_raw_quads)) 0 p_num_bytes in let cipher_raw_quads = append c128 c_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_raw_quads)) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_encrypt_BE alg (seq_nat32_to_seq_nat8_BE key) iv plain_bytes auth_bytes) /\ be_quad32_to_bytes enc_hash == snd (gcm_encrypt_BE alg (seq_nat32_to_seq_nat8_BE key) iv plain_bytes auth_bytes)) ) val gcm_blocks_helper_dec_simplified (alg:algorithm) (key:seq nat32) (p128 p_bytes c128 c_bytes:seq quad32) (auth_bytes alleged_tag:seq nat8) (p_num_bytes:nat) (iv:supported_iv_BE) (j0_BE:quad32) : Lemma (requires // Required by gcm_blocks length p128 * 16 <= p_num_bytes /\ p_num_bytes < length p128 * 16 + 16 /\ length p128 == length c128 /\ length p_bytes == 1 /\ length c_bytes == 1 /\ (length auth_bytes) < pow2_32 /\ is_aes_key_word alg key /\ (let h_BE = aes_encrypt_word alg key (Mkfour 0 0 0 0) in j0_BE = compute_iv_BE h_BE iv) /\ // Ensured by gcm_blocks p_num_bytes < pow2_32 /\ (let ctr_BE_2:quad32 = inc32 j0_BE 1 in let plain:seq quad32 = if p_num_bytes > length p128 * 16 then append p128 p_bytes else p128 in let cipher:seq quad32 = if p_num_bytes > length p128 * 16 then append c128 c_bytes else c128 in let cipher_bound:nat = length p128 + (if p_num_bytes > length p128 * 16 then 1 else 0) in gctr_partial alg cipher_bound plain cipher key ctr_BE_2 )) (ensures (let plain_raw_quads = append p128 p_bytes in let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain_raw_quads)) 0 p_num_bytes in let cipher_raw_quads = append c128 c_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_raw_quads)) 0 p_num_bytes in length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\ cipher_bytes == fst (gcm_decrypt_BE alg (seq_nat32_to_seq_nat8_BE key) iv plain_bytes auth_bytes alleged_tag))) let gcm_decrypt_BE_tag (alg:algorithm) (key:seq nat8) (iv:supported_iv_BE) (cipher:seq nat8) (auth:seq nat8) : Pure (seq nat8) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32 )
false
false
Vale.AES.GCM_BE.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 gcm_decrypt_BE_tag (alg: algorithm) (key: seq nat8) (iv: supported_iv_BE) (cipher auth: seq nat8) : Pure (seq nat8) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32) (ensures fun t -> True)
[]
Vale.AES.GCM_BE.gcm_decrypt_BE_tag
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM_BE.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> iv: Vale.AES.GCM_BE_s.supported_iv_BE -> cipher: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Words_s.nat8)
{ "end_col": 3, "end_line": 200, "start_col": 3, "start_line": 187 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i]
let close_pattern' (p: pattern) (x: var) (i: index) =
false
null
false
subst_pat p [ND x i]
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "total" ]
[ "Pulse.Syntax.Base.pattern", "Pulse.Syntax.Base.var", "Pulse.Syntax.Base.index", "Pulse.Syntax.Naming.subst_pat", "Prims.Cons", "Pulse.Syntax.Naming.subst_elt", "Pulse.Syntax.Naming.ND", "Prims.Nil" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v]
false
true
Pulse.Typing.LN.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 close_pattern' : p: Pulse.Syntax.Base.pattern -> x: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> Pulse.Syntax.Base.pattern
[]
Pulse.Typing.LN.close_pattern'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: Pulse.Syntax.Base.pattern -> x: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> Pulse.Syntax.Base.pattern
{ "end_col": 22, "end_line": 146, "start_col": 2, "start_line": 146 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v]
let open_pattern' (p: pattern) (v: term) (i: index) =
false
null
false
subst_pat p [DT i v]
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "total" ]
[ "Pulse.Syntax.Base.pattern", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Syntax.Naming.subst_pat", "Prims.Cons", "Pulse.Syntax.Naming.subst_elt", "Pulse.Syntax.Naming.DT", "Prims.Nil" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i
false
true
Pulse.Typing.LN.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 open_pattern' : p: Pulse.Syntax.Base.pattern -> v: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> Pulse.Syntax.Base.pattern
[]
Pulse.Typing.LN.open_pattern'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: Pulse.Syntax.Base.pattern -> v: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> Pulse.Syntax.Base.pattern
{ "end_col": 22, "end_line": 144, "start_col": 2, "start_line": 144 }
Prims.Tot
val close_term_pairs' (t: list (term & term)) (v: var) (i: index) : Tot (list (term & term))
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let close_term_pairs' (t:list (term & term)) (v:var) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ ND v i ]
val close_term_pairs' (t: list (term & term)) (v: var) (i: index) : Tot (list (term & term)) let close_term_pairs' (t: list (term & term)) (v: var) (i: index) : Tot (list (term & term)) =
false
null
false
subst_term_pairs t [ND v i]
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "total" ]
[ "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.var", "Pulse.Syntax.Base.index", "Pulse.Syntax.Naming.subst_term_pairs", "Prims.Cons", "Pulse.Syntax.Naming.subst_elt", "Pulse.Syntax.Naming.ND", "Prims.Nil" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i let close_term_pairs' (t:list (term & term)) (v:var) (i:index)
false
true
Pulse.Typing.LN.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 close_term_pairs' (t: list (term & term)) (v: var) (i: index) : Tot (list (term & term))
[]
Pulse.Typing.LN.close_term_pairs'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.list (Pulse.Syntax.Base.term * Pulse.Syntax.Base.term) -> v: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> Prims.list (Pulse.Syntax.Base.term * Pulse.Syntax.Base.term)
{ "end_col": 33, "end_line": 785, "start_col": 4, "start_line": 785 }
Prims.Tot
val open_term_pairs' (t: list (term & term)) (v: term) (i: index) : Tot (list (term & term))
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ]
val open_term_pairs' (t: list (term & term)) (v: term) (i: index) : Tot (list (term & term)) let open_term_pairs' (t: list (term & term)) (v: term) (i: index) : Tot (list (term & term)) =
false
null
false
subst_term_pairs t [DT i v]
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "total" ]
[ "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Syntax.Naming.subst_term_pairs", "Prims.Cons", "Pulse.Syntax.Naming.subst_elt", "Pulse.Syntax.Naming.DT", "Prims.Nil" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index)
false
true
Pulse.Typing.LN.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 open_term_pairs' (t: list (term & term)) (v: term) (i: index) : Tot (list (term & term))
[]
Pulse.Typing.LN.open_term_pairs'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.list (Pulse.Syntax.Base.term * Pulse.Syntax.Base.term) -> v: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> Prims.list (Pulse.Syntax.Base.term * Pulse.Syntax.Base.term)
{ "end_col": 33, "end_line": 113, "start_col": 4, "start_line": 113 }
FStar.Pervasives.Lemma
val tot_typing_ln (#g:_) (#e:_) (#t:_) (d:tot_typing g e t) : Lemma (ln e /\ ln t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let tot_typing_ln (#g:_) (#e:_) (#t:_) (d:tot_typing g e t) : Lemma (ensures ln e /\ ln t) = tot_or_ghost_typing_ln d
val tot_typing_ln (#g:_) (#e:_) (#t:_) (d:tot_typing g e t) : Lemma (ln e /\ ln t) let tot_typing_ln (#g #e #t: _) (d: tot_typing g e t) : Lemma (ensures ln e /\ ln t) =
false
null
true
tot_or_ghost_typing_ln d
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Typing.LN.tot_or_ghost_typing_ln", "FStar.Stubs.TypeChecker.Core.E_Total", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.b2t", "Pulse.Syntax.Naming.ln", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i let close_term_pairs' (t:list (term & term)) (v:var) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ ND v i ] let rec close_term_ln_pairs (t:list (term & term)) (x:var) (i:index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) = match t with | [] -> () | (l, r)::tl -> close_term_ln' l x i; close_term_ln' r x i; close_term_ln_pairs tl x i let close_proof_hint_ln (ht:proof_hint_type) (v:var) (i:index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> close_term_ln' p v i | RENAME { pairs; goal } -> close_term_ln_pairs pairs v i; close_term_ln_opt' goal v i | REWRITE { t1; t2 } -> close_term_ln' t1 v i; close_term_ln' t2 v i let rec close_st_term_ln' (t:st_term) (x:var) (i:index) : Lemma (requires ln_st' t (i - 1)) (ensures ln_st' (close_st_term' t x i) i) (decreases t) = match t.term with | Tm_Return { term } -> close_term_ln' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> close_term_ln' p x i | Tm_IntroExists { p; witnesses } -> close_term_ln' p x i; close_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> close_term_ln' invariant x (i + 1); close_st_term_ln' condition x i; close_st_term_ln' body x i | Tm_If { b; then_; else_; post } -> close_term_ln' b x i; close_st_term_ln' then_ x i; close_st_term_ln' else_ x i; close_term_ln_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_st_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_STApp { head; arg } -> close_term_ln' head x i; close_term_ln' arg x i | Tm_Abs { b; ascription=c; body } -> close_term_ln' b.binder_ty x i; close_comp_ln' c x (i + 1); close_st_term_ln' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> close_term_ln' pre1 x i; close_st_term_ln' body1 x i; close_term_ln' post1 x (i + 1); close_term_ln' pre2 x i; close_st_term_ln' body2 x i; close_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> close_term_ln' t1 x i; close_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_term_ln' length x i; close_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> close_term_ln' typ x i; close_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in close_proof_hint_ln hint_type x (i + n); close_st_term_ln' t x (i + n) let close_comp_ln (c:comp) (v:var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0) = close_comp_ln' c v 0 #push-options "--ifuel 2 --z3rlimit_factor 4 --z3cliopt 'smt.qi.eager_threshold=100'" let lift_comp_ln #g #c1 #c2 (d:lift_comp g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = () let tot_or_ghost_typing_ln (#g:_) (#e:_) (#t:_) (#eff:_) (d:typing g e eff t) : Lemma (ensures ln e /\ ln t) = let E dt = d in well_typed_terms_are_ln _ _ _ dt; elab_ln_inverse e; elab_ln_inverse t let tot_typing_ln (#g:_) (#e:_) (#t:_) (d:tot_typing g e t) : Lemma
false
false
Pulse.Typing.LN.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=100" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val tot_typing_ln (#g:_) (#e:_) (#t:_) (d:tot_typing g e t) : Lemma (ln e /\ ln t)
[]
Pulse.Typing.LN.tot_typing_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
d: Pulse.Typing.tot_typing g e t -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln e /\ Pulse.Syntax.Naming.ln t)
{ "end_col": 28, "end_line": 926, "start_col": 4, "start_line": 926 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v]
let open_pattern_args' (ps: list (pattern & bool)) (v: term) (i: index) =
false
null
false
subst_pat_args ps [DT i v]
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "total" ]
[ "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.pattern", "Prims.bool", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Syntax.Naming.subst_pat_args", "Prims.Cons", "Pulse.Syntax.Naming.subst_elt", "Pulse.Syntax.Naming.DT", "Prims.Nil" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i]
false
true
Pulse.Typing.LN.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 open_pattern_args' : ps: Prims.list (Pulse.Syntax.Base.pattern * Prims.bool) -> v: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> Prims.list (Pulse.Syntax.Base.pattern * Prims.bool)
[]
Pulse.Typing.LN.open_pattern_args'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
ps: Prims.list (Pulse.Syntax.Base.pattern * Prims.bool) -> v: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> Prims.list (Pulse.Syntax.Base.pattern * Prims.bool)
{ "end_col": 28, "end_line": 148, "start_col": 2, "start_line": 148 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i]
let close_pattern_args' (ps: list (pattern & bool)) (x: var) (i: index) =
false
null
false
subst_pat_args ps [ND x i]
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "total" ]
[ "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.pattern", "Prims.bool", "Pulse.Syntax.Base.var", "Pulse.Syntax.Base.index", "Pulse.Syntax.Naming.subst_pat_args", "Prims.Cons", "Pulse.Syntax.Naming.subst_elt", "Pulse.Syntax.Naming.ND", "Prims.Nil" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v]
false
true
Pulse.Typing.LN.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 close_pattern_args' : ps: Prims.list (Pulse.Syntax.Base.pattern * Prims.bool) -> x: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> Prims.list (Pulse.Syntax.Base.pattern * Prims.bool)
[]
Pulse.Typing.LN.close_pattern_args'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
ps: Prims.list (Pulse.Syntax.Base.pattern * Prims.bool) -> x: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> Prims.list (Pulse.Syntax.Base.pattern * Prims.bool)
{ "end_col": 28, "end_line": 150, "start_col": 2, "start_line": 150 }
FStar.Pervasives.Lemma
val close_term_ln_list' (t: list term) (x: var) (i: index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i
val close_term_ln_list' (t: list term) (x: var) (i: index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) let rec close_term_ln_list' (t: list term) (x: var) (i: index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) =
false
null
true
match t with | [] -> () | hd :: tl -> close_term_ln' hd x i; close_term_ln_list' tl x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Prims.list", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.var", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.close_term_ln_list'", "Prims.unit", "Pulse.Typing.LN.close_term_ln'", "Prims.b2t", "Pulse.Syntax.Naming.ln_list'", "Prims.op_Subtraction", "Prims.squash", "Pulse.Syntax.Naming.close_term_list'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i)
false
false
Pulse.Typing.LN.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 close_term_ln_list' (t: list term) (x: var) (i: index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t)
[ "recursion" ]
Pulse.Typing.LN.close_term_ln_list'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.list Pulse.Syntax.Base.term -> x: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_list' t (i - 1)) (ensures Pulse.Syntax.Naming.ln_list' (Pulse.Syntax.Naming.close_term_list' t x i) i) (decreases t)
{ "end_col": 32, "end_line": 781, "start_col": 4, "start_line": 777 }
FStar.Pervasives.Lemma
val close_term_ln_opt' (t: option term) (x: var) (i: index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i
val close_term_ln_opt' (t: option term) (x: var) (i: index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) let close_term_ln_opt' (t: option term) (x: var) (i: index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) =
false
null
true
match t with | None -> () | Some t -> close_term_ln' t x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.var", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.close_term_ln'", "Prims.unit", "Prims.b2t", "Pulse.Syntax.Naming.ln_opt'", "Prims.op_Subtraction", "Prims.squash", "Pulse.Syntax.Naming.close_term_opt'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i)
false
false
Pulse.Typing.LN.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 close_term_ln_opt' (t: option term) (x: var) (i: index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t)
[]
Pulse.Typing.LN.close_term_ln_opt'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: FStar.Pervasives.Native.option Pulse.Syntax.Base.term -> x: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_opt' t (i - 1)) (ensures Pulse.Syntax.Naming.ln_opt' (Pulse.Syntax.Naming.close_term_opt' t x i) i) (decreases t)
{ "end_col": 36, "end_line": 770, "start_col": 4, "start_line": 768 }
FStar.Pervasives.Lemma
val well_typed_terms_are_ln (g: R.env) (e t: R.term) (#eff: _) (d: RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d
val well_typed_terms_are_ln (g: R.env) (e t: R.term) (#eff: _) (d: RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) let well_typed_terms_are_ln (g: R.env) (e t: R.term) (#eff: _) (d: RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) =
false
null
true
RT.well_typed_terms_are_ln g e (eff, t) d
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "FStar.Reflection.Types.env", "FStar.Reflection.Types.term", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "FStar.Reflection.Typing.typing", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.Types.typ", "FStar.Reflection.Typing.well_typed_terms_are_ln", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.b2t", "FStar.Reflection.Typing.ln", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) =
false
false
Pulse.Typing.LN.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 well_typed_terms_are_ln (g: R.env) (e t: R.term) (#eff: _) (d: RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t)
[]
Pulse.Typing.LN.well_typed_terms_are_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
g: FStar.Reflection.Types.env -> e: FStar.Reflection.Types.term -> t: FStar.Reflection.Types.term -> d: FStar.Reflection.Typing.typing g e (eff, t) -> FStar.Pervasives.Lemma (ensures FStar.Reflection.Typing.ln e /\ FStar.Reflection.Typing.ln t)
{ "end_col": 43, "end_line": 18, "start_col": 2, "start_line": 18 }
FStar.Pervasives.Lemma
val ln_weakening_pairs (t: list (term & term)) (i j: int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j
val ln_weakening_pairs (t: list (term & term)) (i j: int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) let rec ln_weakening_pairs (t: list (term & term)) (i j: int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) =
false
null
true
match t with | [] -> () | (l, r) :: tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.term", "Prims.int", "Pulse.Typing.LN.ln_weakening_pairs", "Prims.unit", "Pulse.Typing.LN.ln_weakening", "Prims.l_and", "Prims.b2t", "Pulse.Syntax.Naming.ln_terms'", "Prims.op_LessThanOrEqual", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j)
false
false
Pulse.Typing.LN.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 ln_weakening_pairs (t: list (term & term)) (i j: int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t)
[ "recursion" ]
Pulse.Typing.LN.ln_weakening_pairs
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.list (Pulse.Syntax.Base.term * Pulse.Syntax.Base.term) -> i: Prims.int -> j: Prims.int -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_terms' t i /\ i <= j) (ensures Pulse.Syntax.Naming.ln_terms' t j) (decreases t)
{ "end_col": 31, "end_line": 407, "start_col": 4, "start_line": 402 }
FStar.Pervasives.Lemma
val open_st_term_ln (e: st_term) (v: var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0
val open_st_term_ln (e: st_term) (v: var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) let open_st_term_ln (e: st_term) (v: var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) =
false
null
true
open_st_term_ln' e (term_of_no_name_var v) 0
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.var", "Pulse.Typing.LN.open_st_term_ln'", "Pulse.Syntax.Pure.term_of_no_name_var", "Prims.unit", "Prims.b2t", "Pulse.Syntax.Naming.ln_st", "Pulse.Syntax.Naming.open_st_term", "Prims.squash", "Pulse.Syntax.Naming.ln_st'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v))
false
false
Pulse.Typing.LN.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 open_st_term_ln (e: st_term) (v: var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0)
[]
Pulse.Typing.LN.open_st_term_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
e: Pulse.Syntax.Base.st_term -> v: Pulse.Syntax.Base.var -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_st (Pulse.Syntax.Naming.open_st_term e v)) (ensures Pulse.Syntax.Naming.ln_st' e 0)
{ "end_col": 48, "end_line": 319, "start_col": 4, "start_line": 319 }
FStar.Pervasives.Lemma
val tot_or_ghost_typing_ln (#g #e #t #eff: _) (d: typing g e eff t) : Lemma (ensures ln e /\ ln t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let tot_or_ghost_typing_ln (#g:_) (#e:_) (#t:_) (#eff:_) (d:typing g e eff t) : Lemma (ensures ln e /\ ln t) = let E dt = d in well_typed_terms_are_ln _ _ _ dt; elab_ln_inverse e; elab_ln_inverse t
val tot_or_ghost_typing_ln (#g #e #t #eff: _) (d: typing g e eff t) : Lemma (ensures ln e /\ ln t) let tot_or_ghost_typing_ln (#g #e #t #eff: _) (d: typing g e eff t) : Lemma (ensures ln e /\ ln t) =
false
null
true
let E dt = d in well_typed_terms_are_ln _ _ _ dt; elab_ln_inverse e; elab_ln_inverse t
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "Pulse.Typing.typing", "FStar.Reflection.Typing.typing", "Pulse.Typing.elab_env", "Pulse.Elaborate.Pure.elab_term", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.Types.typ", "Pulse.Typing.LN.elab_ln_inverse", "Prims.unit", "Pulse.Typing.LN.well_typed_terms_are_ln", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.b2t", "Pulse.Syntax.Naming.ln", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i let close_term_pairs' (t:list (term & term)) (v:var) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ ND v i ] let rec close_term_ln_pairs (t:list (term & term)) (x:var) (i:index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) = match t with | [] -> () | (l, r)::tl -> close_term_ln' l x i; close_term_ln' r x i; close_term_ln_pairs tl x i let close_proof_hint_ln (ht:proof_hint_type) (v:var) (i:index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> close_term_ln' p v i | RENAME { pairs; goal } -> close_term_ln_pairs pairs v i; close_term_ln_opt' goal v i | REWRITE { t1; t2 } -> close_term_ln' t1 v i; close_term_ln' t2 v i let rec close_st_term_ln' (t:st_term) (x:var) (i:index) : Lemma (requires ln_st' t (i - 1)) (ensures ln_st' (close_st_term' t x i) i) (decreases t) = match t.term with | Tm_Return { term } -> close_term_ln' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> close_term_ln' p x i | Tm_IntroExists { p; witnesses } -> close_term_ln' p x i; close_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> close_term_ln' invariant x (i + 1); close_st_term_ln' condition x i; close_st_term_ln' body x i | Tm_If { b; then_; else_; post } -> close_term_ln' b x i; close_st_term_ln' then_ x i; close_st_term_ln' else_ x i; close_term_ln_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_st_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_STApp { head; arg } -> close_term_ln' head x i; close_term_ln' arg x i | Tm_Abs { b; ascription=c; body } -> close_term_ln' b.binder_ty x i; close_comp_ln' c x (i + 1); close_st_term_ln' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> close_term_ln' pre1 x i; close_st_term_ln' body1 x i; close_term_ln' post1 x (i + 1); close_term_ln' pre2 x i; close_st_term_ln' body2 x i; close_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> close_term_ln' t1 x i; close_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_term_ln' length x i; close_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> close_term_ln' typ x i; close_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in close_proof_hint_ln hint_type x (i + n); close_st_term_ln' t x (i + n) let close_comp_ln (c:comp) (v:var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0) = close_comp_ln' c v 0 #push-options "--ifuel 2 --z3rlimit_factor 4 --z3cliopt 'smt.qi.eager_threshold=100'" let lift_comp_ln #g #c1 #c2 (d:lift_comp g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = () let tot_or_ghost_typing_ln (#g:_) (#e:_) (#t:_) (#eff:_) (d:typing g e eff t) : Lemma
false
false
Pulse.Typing.LN.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=100" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val tot_or_ghost_typing_ln (#g #e #t #eff: _) (d: typing g e eff t) : Lemma (ensures ln e /\ ln t)
[]
Pulse.Typing.LN.tot_or_ghost_typing_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
d: Pulse.Typing.typing g e eff t -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln e /\ Pulse.Syntax.Naming.ln t)
{ "end_col": 21, "end_line": 919, "start_col": 3, "start_line": 916 }
Prims.Tot
val __brs_of (t: st_term{Tm_Match? t.term}) : list branch
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs
val __brs_of (t: st_term{Tm_Match? t.term}) : list branch let __brs_of (t: st_term{Tm_Match? t.term}) : list branch =
false
null
false
let Tm_Match { brs = brs } = t.term in brs
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "total" ]
[ "Pulse.Syntax.Base.st_term", "Prims.b2t", "Pulse.Syntax.Base.uu___is_Tm_Match", "Pulse.Syntax.Base.__proj__Mkst_term__item__term", "Pulse.Syntax.Base.term", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.vprop", "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.pattern", "Pulse.Syntax.Base.branch", "Pulse.Syntax.Base.st_term'" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i
false
false
Pulse.Typing.LN.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 __brs_of (t: st_term{Tm_Match? t.term}) : list branch
[]
Pulse.Typing.LN.__brs_of
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Pulse.Syntax.Base.st_term{Tm_Match? (Mkst_term?.term t)} -> Prims.list Pulse.Syntax.Base.branch
{ "end_col": 5, "end_line": 98, "start_col": 58, "start_line": 96 }
FStar.Pervasives.Lemma
val open_term_ln_list' (t: list term) (x: term) (i: index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i
val open_term_ln_list' (t: list term) (x: term) (i: index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) let rec open_term_ln_list' (t: list term) (x: term) (i: index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) =
false
null
true
match t with | [] -> () | hd :: tl -> open_term_ln' hd x i; open_term_ln_list' tl x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Prims.list", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.open_term_ln_list'", "Prims.unit", "Pulse.Typing.LN.open_term_ln'", "Prims.b2t", "Pulse.Syntax.Naming.ln_list'", "Pulse.Syntax.Naming.open_term_list'", "Prims.op_Subtraction", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i)
false
false
Pulse.Typing.LN.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 open_term_ln_list' (t: list term) (x: term) (i: index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t)
[ "recursion" ]
Pulse.Typing.LN.open_term_ln_list'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.list Pulse.Syntax.Base.term -> x: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_list' (Pulse.Syntax.Naming.open_term_list' t x i) (i - 1)) (ensures Pulse.Syntax.Naming.ln_list' t i) (decreases t)
{ "end_col": 31, "end_line": 109, "start_col": 4, "start_line": 105 }
FStar.Pervasives.Lemma
val open_term_ln (e: term) (v: var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0
val open_term_ln (e: term) (v: var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) let open_term_ln (e: term) (v: var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) =
false
null
true
open_term_ln' e (term_of_no_name_var v) 0
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.var", "Pulse.Typing.LN.open_term_ln'", "Pulse.Syntax.Pure.term_of_no_name_var", "Prims.unit", "Prims.b2t", "Pulse.Syntax.Naming.ln", "Pulse.Syntax.Naming.open_term", "Prims.squash", "Pulse.Syntax.Naming.ln'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v))
false
false
Pulse.Typing.LN.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 open_term_ln (e: term) (v: var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0)
[]
Pulse.Typing.LN.open_term_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
e: Pulse.Syntax.Base.term -> v: Pulse.Syntax.Base.var -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln (Pulse.Syntax.Naming.open_term e v)) (ensures Pulse.Syntax.Naming.ln' e 0)
{ "end_col": 45, "end_line": 312, "start_col": 4, "start_line": 312 }
FStar.Pervasives.Lemma
val ln_weakening_list (t: list term) (i j: int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j
val ln_weakening_list (t: list term) (i j: int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) let rec ln_weakening_list (t: list term) (i j: int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) =
false
null
true
match t with | [] -> () | hd :: tl -> ln_weakening hd i j; ln_weakening_list tl i j
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Prims.list", "Pulse.Syntax.Base.term", "Prims.int", "Pulse.Typing.LN.ln_weakening_list", "Prims.unit", "Pulse.Typing.LN.ln_weakening", "Prims.l_and", "Prims.b2t", "Pulse.Syntax.Naming.ln_list'", "Prims.op_LessThanOrEqual", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j)
false
false
Pulse.Typing.LN.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 ln_weakening_list (t: list term) (i j: int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t)
[ "recursion" ]
Pulse.Typing.LN.ln_weakening_list
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.list Pulse.Syntax.Base.term -> i: Prims.int -> j: Prims.int -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_list' t i /\ i <= j) (ensures Pulse.Syntax.Naming.ln_list' t j) (decreases t)
{ "end_col": 30, "end_line": 395, "start_col": 4, "start_line": 391 }
FStar.Pervasives.Lemma
val close_comp_ln (c: comp) (v: var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let close_comp_ln (c:comp) (v:var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0) = close_comp_ln' c v 0
val close_comp_ln (c: comp) (v: var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0) let close_comp_ln (c: comp) (v: var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0) =
false
null
true
close_comp_ln' c v 0
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.var", "Pulse.Typing.LN.close_comp_ln'", "Prims.unit", "Prims.b2t", "Pulse.Syntax.Naming.ln_c", "Prims.squash", "Pulse.Syntax.Naming.ln_c'", "Pulse.Syntax.Naming.close_comp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i let close_term_pairs' (t:list (term & term)) (v:var) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ ND v i ] let rec close_term_ln_pairs (t:list (term & term)) (x:var) (i:index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) = match t with | [] -> () | (l, r)::tl -> close_term_ln' l x i; close_term_ln' r x i; close_term_ln_pairs tl x i let close_proof_hint_ln (ht:proof_hint_type) (v:var) (i:index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> close_term_ln' p v i | RENAME { pairs; goal } -> close_term_ln_pairs pairs v i; close_term_ln_opt' goal v i | REWRITE { t1; t2 } -> close_term_ln' t1 v i; close_term_ln' t2 v i let rec close_st_term_ln' (t:st_term) (x:var) (i:index) : Lemma (requires ln_st' t (i - 1)) (ensures ln_st' (close_st_term' t x i) i) (decreases t) = match t.term with | Tm_Return { term } -> close_term_ln' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> close_term_ln' p x i | Tm_IntroExists { p; witnesses } -> close_term_ln' p x i; close_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> close_term_ln' invariant x (i + 1); close_st_term_ln' condition x i; close_st_term_ln' body x i | Tm_If { b; then_; else_; post } -> close_term_ln' b x i; close_st_term_ln' then_ x i; close_st_term_ln' else_ x i; close_term_ln_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_st_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_STApp { head; arg } -> close_term_ln' head x i; close_term_ln' arg x i | Tm_Abs { b; ascription=c; body } -> close_term_ln' b.binder_ty x i; close_comp_ln' c x (i + 1); close_st_term_ln' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> close_term_ln' pre1 x i; close_st_term_ln' body1 x i; close_term_ln' post1 x (i + 1); close_term_ln' pre2 x i; close_st_term_ln' body2 x i; close_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> close_term_ln' t1 x i; close_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_term_ln' length x i; close_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> close_term_ln' typ x i; close_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in close_proof_hint_ln hint_type x (i + n); close_st_term_ln' t x (i + n) let close_comp_ln (c:comp) (v:var) : Lemma (requires ln_c c)
false
false
Pulse.Typing.LN.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 close_comp_ln (c: comp) (v: var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0)
[]
Pulse.Typing.LN.close_comp_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
c: Pulse.Syntax.Base.comp -> v: Pulse.Syntax.Base.var -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_c c) (ensures Pulse.Syntax.Naming.ln_c' (Pulse.Syntax.Naming.close_comp c v) 0)
{ "end_col": 24, "end_line": 901, "start_col": 4, "start_line": 901 }
FStar.Pervasives.Lemma
val ln_weakening (e: term) (i j: int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)]
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j
val ln_weakening (e: term) (i j: int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] let rec ln_weakening (e: term) (i j: int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] =
false
null
true
match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Pulse.Syntax.Base.term", "Prims.int", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Typing.LN.ln_weakening", "Prims.unit", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.binder", "Prims.op_Addition", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Syntax.Base.host_term", "Pulse.Typing.LN.r_ln_weakening", "Prims.l_and", "Prims.b2t", "Pulse.Syntax.Naming.ln'", "Prims.op_LessThanOrEqual", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.bool", "Prims.Nil" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j);
false
false
Pulse.Typing.LN.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 ln_weakening (e: term) (i j: int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)]
[ "recursion" ]
Pulse.Typing.LN.ln_weakening
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
e: Pulse.Syntax.Base.term -> i: Prims.int -> j: Prims.int -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln' e i /\ i <= j) (ensures Pulse.Syntax.Naming.ln' e j) (decreases e) [SMTPat (Pulse.Syntax.Naming.ln' e j); SMTPat (Pulse.Syntax.Naming.ln' e i)]
{ "end_col": 26, "end_line": 354, "start_col": 4, "start_line": 334 }
FStar.Pervasives.Lemma
val open_term_ln_inv_opt' (t: option term) (x: term{ln x}) (i: index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i
val open_term_ln_inv_opt' (t: option term) (x: term{ln x}) (i: index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) let open_term_ln_inv_opt' (t: option term) (x: term{ln x}) (i: index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) =
false
null
true
match t with | None -> () | Some t -> open_term_ln_inv' t x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.term", "Prims.b2t", "Pulse.Syntax.Naming.ln", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.open_term_ln_inv'", "Prims.unit", "Pulse.Syntax.Naming.ln_opt'", "Prims.squash", "Pulse.Syntax.Naming.open_term_opt'", "Prims.op_Subtraction", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1))
false
false
Pulse.Typing.LN.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 open_term_ln_inv_opt' (t: option term) (x: term{ln x}) (i: index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t)
[]
Pulse.Typing.LN.open_term_ln_inv_opt'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: FStar.Pervasives.Native.option Pulse.Syntax.Base.term -> x: Pulse.Syntax.Base.term{Pulse.Syntax.Naming.ln x} -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_opt' t i) (ensures Pulse.Syntax.Naming.ln_opt' (Pulse.Syntax.Naming.open_term_opt' t x i) (i - 1)) (decreases t)
{ "end_col": 39, "end_line": 574, "start_col": 4, "start_line": 572 }
FStar.Pervasives.Lemma
val open_term_ln_inv_list' (t: list term) (x: term{ln x}) (i: index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i
val open_term_ln_inv_list' (t: list term) (x: term{ln x}) (i: index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) let rec open_term_ln_inv_list' (t: list term) (x: term{ln x}) (i: index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) =
false
null
true
match t with | [] -> () | hd :: tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Prims.list", "Pulse.Syntax.Base.term", "Prims.b2t", "Pulse.Syntax.Naming.ln", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.open_term_ln_inv_list'", "Prims.unit", "Pulse.Typing.LN.open_term_ln_inv'", "Pulse.Syntax.Naming.ln_list'", "Prims.squash", "Pulse.Syntax.Naming.open_term_list'", "Prims.op_Subtraction", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1))
false
false
Pulse.Typing.LN.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 open_term_ln_inv_list' (t: list term) (x: term{ln x}) (i: index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t)
[ "recursion" ]
Pulse.Typing.LN.open_term_ln_inv_list'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.list Pulse.Syntax.Base.term -> x: Pulse.Syntax.Base.term{Pulse.Syntax.Naming.ln x} -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_list' t i) (ensures Pulse.Syntax.Naming.ln_list' (Pulse.Syntax.Naming.open_term_list' t x i) (i - 1)) (decreases t)
{ "end_col": 35, "end_line": 587, "start_col": 4, "start_line": 583 }
FStar.Pervasives.Lemma
val close_term_ln_pairs (t: list (term & term)) (x: var) (i: index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec close_term_ln_pairs (t:list (term & term)) (x:var) (i:index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) = match t with | [] -> () | (l, r)::tl -> close_term_ln' l x i; close_term_ln' r x i; close_term_ln_pairs tl x i
val close_term_ln_pairs (t: list (term & term)) (x: var) (i: index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) let rec close_term_ln_pairs (t: list (term & term)) (x: var) (i: index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) =
false
null
true
match t with | [] -> () | (l, r) :: tl -> close_term_ln' l x i; close_term_ln' r x i; close_term_ln_pairs tl x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.var", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.close_term_ln_pairs", "Prims.unit", "Pulse.Typing.LN.close_term_ln'", "Prims.b2t", "Pulse.Syntax.Naming.ln_terms'", "Prims.op_Subtraction", "Prims.squash", "Pulse.Typing.LN.close_term_pairs'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i let close_term_pairs' (t:list (term & term)) (v:var) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ ND v i ] let rec close_term_ln_pairs (t:list (term & term)) (x:var) (i:index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i)
false
false
Pulse.Typing.LN.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 close_term_ln_pairs (t: list (term & term)) (x: var) (i: index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t)
[ "recursion" ]
Pulse.Typing.LN.close_term_ln_pairs
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.list (Pulse.Syntax.Base.term * Pulse.Syntax.Base.term) -> x: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_terms' t (i - 1)) (ensures Pulse.Syntax.Naming.ln_terms' (Pulse.Typing.LN.close_term_pairs' t x i) i) (decreases t)
{ "end_col": 32, "end_line": 797, "start_col": 4, "start_line": 792 }
FStar.Pervasives.Lemma
val open_proof_hint_ln (t: proof_hint_type) (x: term) (i: index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i
val open_proof_hint_ln (t: proof_hint_type) (x: term) (i: index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) let open_proof_hint_ln (t: proof_hint_type) (x: term) (i: index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) =
false
null
true
match t with | ASSERT { p = p } | FOLD { p = p } | UNFOLD { p = p } -> open_term_ln' p x i | RENAME { pairs = pairs ; goal = goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1 = t1 ; t2 = t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Syntax.Base.proof_hint_type", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Syntax.Base.vprop", "Pulse.Typing.LN.open_term_ln'", "FStar.Pervasives.Native.option", "Prims.list", "Prims.string", "FStar.Pervasives.Native.tuple2", "Pulse.Typing.LN.open_term_ln_opt'", "Prims.unit", "Pulse.Typing.LN.open_term_ln_pairs", "Prims.b2t", "Pulse.Syntax.Naming.ln_proof_hint'", "Pulse.Syntax.Naming.open_proof_hint'", "Prims.op_Subtraction", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1))
false
false
Pulse.Typing.LN.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 open_proof_hint_ln (t: proof_hint_type) (x: term) (i: index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i)
[]
Pulse.Typing.LN.open_proof_hint_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Pulse.Syntax.Base.proof_hint_type -> x: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_proof_hint' (Pulse.Syntax.Naming.open_proof_hint' t x i) (i - 1)) (ensures Pulse.Syntax.Naming.ln_proof_hint' t i)
{ "end_col": 26, "end_line": 141, "start_col": 4, "start_line": 131 }
FStar.Pervasives.Lemma
val st_comp_typing_ln (#g #st: _) (d: st_comp_typing g st) : Lemma (ensures ln_st_comp st (- 1))
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let st_comp_typing_ln (#g:_) (#st:_) (d:st_comp_typing g st) : Lemma (ensures ln_st_comp st (-1)) = let STC _ {post} x res_typing pre_typing post_typing = d in tot_or_ghost_typing_ln res_typing; tot_or_ghost_typing_ln pre_typing; tot_or_ghost_typing_ln post_typing; open_term_ln' post (null_var x) 0
val st_comp_typing_ln (#g #st: _) (d: st_comp_typing g st) : Lemma (ensures ln_st_comp st (- 1)) let st_comp_typing_ln (#g #st: _) (d: st_comp_typing g st) : Lemma (ensures ln_st_comp st (- 1)) =
false
null
true
let STC _ { post = post } x res_typing pre_typing post_typing = d in tot_or_ghost_typing_ln res_typing; tot_or_ghost_typing_ln pre_typing; tot_or_ghost_typing_ln post_typing; open_term_ln' post (null_var x) 0
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.st_comp", "Pulse.Typing.st_comp_typing", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.vprop", "Pulse.Syntax.Base.var", "Prims.l_and", "Prims.b2t", "FStar.Pervasives.Native.uu___is_None", "Pulse.Syntax.Base.typ", "Pulse.Typing.Env.lookup", "Prims.l_not", "FStar.Set.mem", "Pulse.Syntax.Naming.freevars", "Pulse.Syntax.Base.__proj__Mkst_comp__item__post", "Pulse.Syntax.Base.Mkst_comp", "Pulse.Typing.universe_of", "Pulse.Syntax.Base.__proj__Mkst_comp__item__res", "Pulse.Syntax.Base.__proj__Mkst_comp__item__u", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.__proj__Mkst_comp__item__pre", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.Env.push_binding", "Pulse.Syntax.Base.ppname_default", "Pulse.Syntax.Naming.open_term", "Pulse.Typing.LN.open_term_ln'", "Pulse.Syntax.Pure.null_var", "Prims.unit", "Pulse.Typing.LN.tot_or_ghost_typing_ln", "FStar.Stubs.TypeChecker.Core.E_Total", "Pulse.Syntax.Pure.tm_type", "Prims.l_True", "Prims.squash", "Pulse.Syntax.Naming.ln_st_comp", "Prims.op_Minus", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i let close_term_pairs' (t:list (term & term)) (v:var) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ ND v i ] let rec close_term_ln_pairs (t:list (term & term)) (x:var) (i:index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) = match t with | [] -> () | (l, r)::tl -> close_term_ln' l x i; close_term_ln' r x i; close_term_ln_pairs tl x i let close_proof_hint_ln (ht:proof_hint_type) (v:var) (i:index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> close_term_ln' p v i | RENAME { pairs; goal } -> close_term_ln_pairs pairs v i; close_term_ln_opt' goal v i | REWRITE { t1; t2 } -> close_term_ln' t1 v i; close_term_ln' t2 v i let rec close_st_term_ln' (t:st_term) (x:var) (i:index) : Lemma (requires ln_st' t (i - 1)) (ensures ln_st' (close_st_term' t x i) i) (decreases t) = match t.term with | Tm_Return { term } -> close_term_ln' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> close_term_ln' p x i | Tm_IntroExists { p; witnesses } -> close_term_ln' p x i; close_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> close_term_ln' invariant x (i + 1); close_st_term_ln' condition x i; close_st_term_ln' body x i | Tm_If { b; then_; else_; post } -> close_term_ln' b x i; close_st_term_ln' then_ x i; close_st_term_ln' else_ x i; close_term_ln_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_st_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_STApp { head; arg } -> close_term_ln' head x i; close_term_ln' arg x i | Tm_Abs { b; ascription=c; body } -> close_term_ln' b.binder_ty x i; close_comp_ln' c x (i + 1); close_st_term_ln' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> close_term_ln' pre1 x i; close_st_term_ln' body1 x i; close_term_ln' post1 x (i + 1); close_term_ln' pre2 x i; close_st_term_ln' body2 x i; close_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> close_term_ln' t1 x i; close_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_term_ln' length x i; close_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> close_term_ln' typ x i; close_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in close_proof_hint_ln hint_type x (i + n); close_st_term_ln' t x (i + n) let close_comp_ln (c:comp) (v:var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0) = close_comp_ln' c v 0 #push-options "--ifuel 2 --z3rlimit_factor 4 --z3cliopt 'smt.qi.eager_threshold=100'" let lift_comp_ln #g #c1 #c2 (d:lift_comp g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = () let tot_or_ghost_typing_ln (#g:_) (#e:_) (#t:_) (#eff:_) (d:typing g e eff t) : Lemma (ensures ln e /\ ln t) = let E dt = d in well_typed_terms_are_ln _ _ _ dt; elab_ln_inverse e; elab_ln_inverse t let tot_typing_ln (#g:_) (#e:_) (#t:_) (d:tot_typing g e t) : Lemma (ensures ln e /\ ln t) = tot_or_ghost_typing_ln d let rec vprop_equiv_ln (#g:_) (#t0 #t1:_) (v:vprop_equiv g t0 t1) : Lemma (ensures ln t0 <==> ln t1) (decreases v) = match v with | VE_Refl _ _ -> () | VE_Sym _ _ _ v' -> vprop_equiv_ln v' | VE_Trans g t0 t2 t1 v02 v21 -> vprop_equiv_ln v02; vprop_equiv_ln v21 | VE_Ctxt g s0 s1 s0' s1' v0 v1 -> vprop_equiv_ln v0; vprop_equiv_ln v1 | VE_Unit g t -> () | VE_Comm g t0 t1 -> () | VE_Assoc g t0 t1 t2 -> () | VE_Ext g t0 t1 token -> let d0, d1 = vprop_eq_typing_inversion _ _ _ token in tot_or_ghost_typing_ln d0; tot_or_ghost_typing_ln d1 let st_equiv_ln #g #c1 #c2 (d:st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = let ST_VPropEquiv _ _ _ x (E dpre) _dres _dpost eq_res eq_pre eq_post = d in vprop_equiv_ln eq_pre; open_term_ln_inv' (comp_post c1) (term_of_no_name_var x) 0; vprop_equiv_ln eq_post; rt_equiv_ln _ _ _ eq_res; elab_ln_inverse (comp_res c2); open_term_ln' (comp_post c2) (term_of_no_name_var x) 0 let bind_comp_ln #g #x #c1 #c2 #c (d:bind_comp g x c1 c2 c) : Lemma (requires ln_c c1 /\ ln_c c2) (ensures ln_c c) = ()
false
false
Pulse.Typing.LN.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=100" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val st_comp_typing_ln (#g #st: _) (d: st_comp_typing g st) : Lemma (ensures ln_st_comp st (- 1))
[]
Pulse.Typing.LN.st_comp_typing_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
d: Pulse.Typing.st_comp_typing g st -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln_st_comp st (- 1))
{ "end_col": 35, "end_line": 974, "start_col": 40, "start_line": 968 }
FStar.Pervasives.Lemma
val ln_weakening_comp (c: comp) (i j: int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1)
val ln_weakening_comp (c: comp) (i j: int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) let ln_weakening_comp (c: comp) (i j: int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) =
false
null
true
match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1)
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Syntax.Base.comp", "Prims.int", "Pulse.Syntax.Base.term", "Pulse.Typing.LN.ln_weakening", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.__proj__Mkst_comp__item__post", "Prims.op_Addition", "Prims.unit", "Pulse.Syntax.Base.__proj__Mkst_comp__item__pre", "Pulse.Syntax.Base.__proj__Mkst_comp__item__res", "Prims.l_and", "Prims.b2t", "Pulse.Syntax.Naming.ln_c'", "Prims.op_LessThanOrEqual", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j)
false
false
Pulse.Typing.LN.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 ln_weakening_comp (c: comp) (i j: int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j)
[]
Pulse.Typing.LN.ln_weakening_comp
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
c: Pulse.Syntax.Base.comp -> i: Prims.int -> j: Prims.int -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_c' c i /\ i <= j) (ensures Pulse.Syntax.Naming.ln_c' c j)
{ "end_col": 41, "end_line": 374, "start_col": 4, "start_line": 360 }
FStar.Pervasives.Lemma
val open_proof_hint_ln_inv (ht: proof_hint_type) (x: term{ln x}) (i: index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1))
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i
val open_proof_hint_ln_inv (ht: proof_hint_type) (x: term{ln x}) (i: index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) let open_proof_hint_ln_inv (ht: proof_hint_type) (x: term{ln x}) (i: index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) =
false
null
true
match ht with | ASSERT { p = p } | FOLD { p = p } | UNFOLD { p = p } -> open_term_ln_inv' p x i | RENAME { pairs = pairs ; goal = goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1 = t1 ; t2 = t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Syntax.Base.proof_hint_type", "Pulse.Syntax.Base.term", "Prims.b2t", "Pulse.Syntax.Naming.ln", "Pulse.Syntax.Base.index", "Pulse.Syntax.Base.vprop", "Pulse.Typing.LN.open_term_ln_inv'", "FStar.Pervasives.Native.option", "Prims.list", "Prims.string", "FStar.Pervasives.Native.tuple2", "Pulse.Typing.LN.open_term_ln_inv_opt'", "Prims.unit", "Pulse.Typing.LN.open_term_ln_inv_pairs", "Pulse.Syntax.Naming.ln_proof_hint'", "Prims.squash", "Pulse.Syntax.Naming.open_proof_hint'", "Prims.op_Subtraction", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i)
false
false
Pulse.Typing.LN.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 open_proof_hint_ln_inv (ht: proof_hint_type) (x: term{ln x}) (i: index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1))
[]
Pulse.Typing.LN.open_proof_hint_ln_inv
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
ht: Pulse.Syntax.Base.proof_hint_type -> x: Pulse.Syntax.Base.term{Pulse.Syntax.Naming.ln x} -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_proof_hint' ht i) (ensures Pulse.Syntax.Naming.ln_proof_hint' (Pulse.Syntax.Naming.open_proof_hint' ht x i) (i - 1))
{ "end_col": 30, "end_line": 617, "start_col": 4, "start_line": 607 }
FStar.Pervasives.Lemma
val open_term_ln_inv_pairs (t: list (term & term)) (x: term{ln x}) (i: index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i
val open_term_ln_inv_pairs (t: list (term & term)) (x: term{ln x}) (i: index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) let rec open_term_ln_inv_pairs (t: list (term & term)) (x: term{ln x}) (i: index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) =
false
null
true
match t with | [] -> () | (l, r) :: tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.term", "Prims.b2t", "Pulse.Syntax.Naming.ln", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.open_term_ln_inv_pairs", "Prims.unit", "Pulse.Typing.LN.open_term_ln_inv'", "Pulse.Syntax.Naming.ln_terms'", "Prims.squash", "Pulse.Typing.LN.open_term_pairs'", "Prims.op_Subtraction", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1))
false
false
Pulse.Typing.LN.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 open_term_ln_inv_pairs (t: list (term & term)) (x: term{ln x}) (i: index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t)
[ "recursion" ]
Pulse.Typing.LN.open_term_ln_inv_pairs
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.list (Pulse.Syntax.Base.term * Pulse.Syntax.Base.term) -> x: Pulse.Syntax.Base.term{Pulse.Syntax.Naming.ln x} -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_terms' t i) (ensures Pulse.Syntax.Naming.ln_terms' (Pulse.Typing.LN.open_term_pairs' t x i) (i - 1)) (decreases t)
{ "end_col": 35, "end_line": 601, "start_col": 4, "start_line": 596 }
FStar.Pervasives.Lemma
val close_proof_hint_ln (ht: proof_hint_type) (v: var) (i: index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let close_proof_hint_ln (ht:proof_hint_type) (v:var) (i:index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> close_term_ln' p v i | RENAME { pairs; goal } -> close_term_ln_pairs pairs v i; close_term_ln_opt' goal v i | REWRITE { t1; t2 } -> close_term_ln' t1 v i; close_term_ln' t2 v i
val close_proof_hint_ln (ht: proof_hint_type) (v: var) (i: index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i) let close_proof_hint_ln (ht: proof_hint_type) (v: var) (i: index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i) =
false
null
true
match ht with | ASSERT { p = p } | FOLD { p = p } | UNFOLD { p = p } -> close_term_ln' p v i | RENAME { pairs = pairs ; goal = goal } -> close_term_ln_pairs pairs v i; close_term_ln_opt' goal v i | REWRITE { t1 = t1 ; t2 = t2 } -> close_term_ln' t1 v i; close_term_ln' t2 v i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Syntax.Base.proof_hint_type", "Pulse.Syntax.Base.var", "Pulse.Syntax.Base.index", "Pulse.Syntax.Base.vprop", "Pulse.Typing.LN.close_term_ln'", "FStar.Pervasives.Native.option", "Prims.list", "Prims.string", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.term", "Pulse.Typing.LN.close_term_ln_opt'", "Prims.unit", "Pulse.Typing.LN.close_term_ln_pairs", "Prims.b2t", "Pulse.Syntax.Naming.ln_proof_hint'", "Prims.op_Subtraction", "Prims.squash", "Pulse.Syntax.Naming.close_proof_hint'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i let close_term_pairs' (t:list (term & term)) (v:var) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ ND v i ] let rec close_term_ln_pairs (t:list (term & term)) (x:var) (i:index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) = match t with | [] -> () | (l, r)::tl -> close_term_ln' l x i; close_term_ln' r x i; close_term_ln_pairs tl x i let close_proof_hint_ln (ht:proof_hint_type) (v:var) (i:index) : Lemma (requires ln_proof_hint' ht (i - 1))
false
false
Pulse.Typing.LN.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 close_proof_hint_ln (ht: proof_hint_type) (v: var) (i: index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i)
[]
Pulse.Typing.LN.close_proof_hint_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
ht: Pulse.Syntax.Base.proof_hint_type -> v: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_proof_hint' ht (i - 1)) (ensures Pulse.Syntax.Naming.ln_proof_hint' (Pulse.Syntax.Naming.close_proof_hint' ht v i) i)
{ "end_col": 27, "end_line": 813, "start_col": 4, "start_line": 803 }
FStar.Pervasives.Lemma
val open_comp_ln' (c: comp) (x: term) (i: index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1)
val open_comp_ln' (c: comp) (x: term) (i: index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) let open_comp_ln' (c: comp) (x: term) (i: index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) =
false
null
true
match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1)
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.open_term_ln'", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.__proj__Mkst_comp__item__post", "Prims.op_Addition", "Prims.unit", "Pulse.Syntax.Base.__proj__Mkst_comp__item__pre", "Pulse.Syntax.Base.__proj__Mkst_comp__item__res", "Prims.b2t", "Pulse.Syntax.Naming.ln_c'", "Pulse.Syntax.Naming.open_comp'", "Prims.op_Subtraction", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1))
false
false
Pulse.Typing.LN.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 open_comp_ln' (c: comp) (x: term) (i: index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i)
[]
Pulse.Typing.LN.open_comp_ln'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
c: Pulse.Syntax.Base.comp -> x: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_c' (Pulse.Syntax.Naming.open_comp' c x i) (i - 1)) (ensures Pulse.Syntax.Naming.ln_c' c i)
{ "end_col": 36, "end_line": 84, "start_col": 4, "start_line": 70 }
FStar.Pervasives.Lemma
val open_term_ln_inv' (e: term) (x: term{ln x}) (i: index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i
val open_term_ln_inv' (e: term) (x: term{ln x}) (i: index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) let rec open_term_ln_inv' (e: term) (x: term{ln x}) (i: index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) =
false
null
true
match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (- 1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (- 1); r_open_term_ln_inv' t (elab_term x) i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Pulse.Syntax.Base.term", "Prims.b2t", "Pulse.Syntax.Naming.ln", "Pulse.Syntax.Base.index", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Typing.LN.ln_weakening", "Prims.op_Minus", "Prims.op_Subtraction", "Pulse.Typing.LN.open_term_ln_inv'", "Prims.unit", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.binder", "Prims.op_Addition", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Syntax.Base.host_term", "Pulse.Typing.LN.r_open_term_ln_inv'", "Pulse.Elaborate.Pure.elab_term", "Pulse.Elaborate.elab_ln", "Pulse.Syntax.Naming.ln'", "Prims.squash", "Pulse.Syntax.Naming.open_term'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1))
false
false
Pulse.Typing.LN.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 open_term_ln_inv' (e: term) (x: term{ln x}) (i: index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e)
[ "recursion" ]
Pulse.Typing.LN.open_term_ln_inv'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
e: Pulse.Syntax.Base.term -> x: Pulse.Syntax.Base.term{Pulse.Syntax.Naming.ln x} -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln' e i) (ensures Pulse.Syntax.Naming.ln' (Pulse.Syntax.Naming.open_term' e x i) (i - 1)) (decreases e)
{ "end_col": 43, "end_line": 541, "start_col": 4, "start_line": 518 }
FStar.Pervasives.Lemma
val open_term_ln' (e x: term) (i: index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i
val open_term_ln' (e x: term) (i: index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) let rec open_term_ln' (e x: term) (i: index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) =
false
null
true
match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Typing.LN.open_term_ln'", "Prims.unit", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.binder", "Prims.op_Addition", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Syntax.Base.host_term", "Pulse.Typing.LN.open_term_ln_host'", "Pulse.Elaborate.Pure.elab_term", "Prims.b2t", "Pulse.Syntax.Naming.ln'", "Pulse.Syntax.Naming.open_term'", "Prims.op_Subtraction", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i)
false
false
Pulse.Typing.LN.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 open_term_ln' (e x: term) (i: index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e)
[ "recursion" ]
Pulse.Typing.LN.open_term_ln'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
e: Pulse.Syntax.Base.term -> x: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln' (Pulse.Syntax.Naming.open_term' e x i) (i - 1)) (ensures Pulse.Syntax.Naming.ln' e i) (decreases e)
{ "end_col": 42, "end_line": 62, "start_col": 4, "start_line": 42 }
FStar.Pervasives.Lemma
val st_equiv_ln (#g #c1 #c2: _) (d: st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let st_equiv_ln #g #c1 #c2 (d:st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = let ST_VPropEquiv _ _ _ x (E dpre) _dres _dpost eq_res eq_pre eq_post = d in vprop_equiv_ln eq_pre; open_term_ln_inv' (comp_post c1) (term_of_no_name_var x) 0; vprop_equiv_ln eq_post; rt_equiv_ln _ _ _ eq_res; elab_ln_inverse (comp_res c2); open_term_ln' (comp_post c2) (term_of_no_name_var x) 0
val st_equiv_ln (#g #c1 #c2: _) (d: st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) let st_equiv_ln #g #c1 #c2 (d: st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) =
false
null
true
let ST_VPropEquiv _ _ _ x (E dpre) _dres _dpost eq_res eq_pre eq_post = d in vprop_equiv_ln eq_pre; open_term_ln_inv' (comp_post c1) (term_of_no_name_var x) 0; vprop_equiv_ln eq_post; rt_equiv_ln _ _ _ eq_res; elab_ln_inverse (comp_res c2); open_term_ln' (comp_post c2) (term_of_no_name_var x) 0
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.comp", "Pulse.Typing.st_equiv", "Pulse.Syntax.Base.comp_st", "Pulse.Typing.st_equiv_pre", "Pulse.Syntax.Base.var", "Prims.l_and", "Prims.b2t", "FStar.Pervasives.Native.uu___is_None", "Pulse.Syntax.Base.typ", "Pulse.Typing.Env.lookup", "Prims.l_not", "FStar.Set.mem", "Pulse.Syntax.Naming.freevars", "Pulse.Syntax.Base.comp_post", "FStar.Reflection.Typing.typing", "Pulse.Typing.elab_env", "Pulse.Elaborate.Pure.elab_term", "Pulse.Syntax.Base.comp_pre", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "FStar.Reflection.Types.typ", "FStar.Stubs.TypeChecker.Core.E_Total", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.comp_res", "Pulse.Syntax.Pure.tm_type", "Pulse.Syntax.Base.comp_u", "Pulse.Typing.Env.push_binding", "Pulse.Syntax.Base.ppname_default", "Pulse.Syntax.Naming.open_term", "FStar.Reflection.Typing.equiv", "Pulse.Typing.vprop_equiv", "Pulse.Typing.LN.open_term_ln'", "Pulse.Syntax.Pure.term_of_no_name_var", "Prims.unit", "Pulse.Typing.LN.elab_ln_inverse", "Pulse.Typing.LN.rt_equiv_ln", "Pulse.Typing.LN.vprop_equiv_ln", "Pulse.Typing.LN.open_term_ln_inv'", "Pulse.Syntax.Naming.ln_c", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i let close_term_pairs' (t:list (term & term)) (v:var) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ ND v i ] let rec close_term_ln_pairs (t:list (term & term)) (x:var) (i:index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) = match t with | [] -> () | (l, r)::tl -> close_term_ln' l x i; close_term_ln' r x i; close_term_ln_pairs tl x i let close_proof_hint_ln (ht:proof_hint_type) (v:var) (i:index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> close_term_ln' p v i | RENAME { pairs; goal } -> close_term_ln_pairs pairs v i; close_term_ln_opt' goal v i | REWRITE { t1; t2 } -> close_term_ln' t1 v i; close_term_ln' t2 v i let rec close_st_term_ln' (t:st_term) (x:var) (i:index) : Lemma (requires ln_st' t (i - 1)) (ensures ln_st' (close_st_term' t x i) i) (decreases t) = match t.term with | Tm_Return { term } -> close_term_ln' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> close_term_ln' p x i | Tm_IntroExists { p; witnesses } -> close_term_ln' p x i; close_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> close_term_ln' invariant x (i + 1); close_st_term_ln' condition x i; close_st_term_ln' body x i | Tm_If { b; then_; else_; post } -> close_term_ln' b x i; close_st_term_ln' then_ x i; close_st_term_ln' else_ x i; close_term_ln_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_st_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_STApp { head; arg } -> close_term_ln' head x i; close_term_ln' arg x i | Tm_Abs { b; ascription=c; body } -> close_term_ln' b.binder_ty x i; close_comp_ln' c x (i + 1); close_st_term_ln' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> close_term_ln' pre1 x i; close_st_term_ln' body1 x i; close_term_ln' post1 x (i + 1); close_term_ln' pre2 x i; close_st_term_ln' body2 x i; close_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> close_term_ln' t1 x i; close_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_term_ln' length x i; close_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> close_term_ln' typ x i; close_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in close_proof_hint_ln hint_type x (i + n); close_st_term_ln' t x (i + n) let close_comp_ln (c:comp) (v:var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0) = close_comp_ln' c v 0 #push-options "--ifuel 2 --z3rlimit_factor 4 --z3cliopt 'smt.qi.eager_threshold=100'" let lift_comp_ln #g #c1 #c2 (d:lift_comp g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = () let tot_or_ghost_typing_ln (#g:_) (#e:_) (#t:_) (#eff:_) (d:typing g e eff t) : Lemma (ensures ln e /\ ln t) = let E dt = d in well_typed_terms_are_ln _ _ _ dt; elab_ln_inverse e; elab_ln_inverse t let tot_typing_ln (#g:_) (#e:_) (#t:_) (d:tot_typing g e t) : Lemma (ensures ln e /\ ln t) = tot_or_ghost_typing_ln d let rec vprop_equiv_ln (#g:_) (#t0 #t1:_) (v:vprop_equiv g t0 t1) : Lemma (ensures ln t0 <==> ln t1) (decreases v) = match v with | VE_Refl _ _ -> () | VE_Sym _ _ _ v' -> vprop_equiv_ln v' | VE_Trans g t0 t2 t1 v02 v21 -> vprop_equiv_ln v02; vprop_equiv_ln v21 | VE_Ctxt g s0 s1 s0' s1' v0 v1 -> vprop_equiv_ln v0; vprop_equiv_ln v1 | VE_Unit g t -> () | VE_Comm g t0 t1 -> () | VE_Assoc g t0 t1 t2 -> () | VE_Ext g t0 t1 token -> let d0, d1 = vprop_eq_typing_inversion _ _ _ token in tot_or_ghost_typing_ln d0; tot_or_ghost_typing_ln d1 let st_equiv_ln #g #c1 #c2 (d:st_equiv g c1 c2) : Lemma (requires ln_c c1)
false
false
Pulse.Typing.LN.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=100" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val st_equiv_ln (#g #c1 #c2: _) (d: st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2)
[]
Pulse.Typing.LN.st_equiv_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
d: Pulse.Typing.st_equiv g c1 c2 -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_c c1) (ensures Pulse.Syntax.Naming.ln_c c2)
{ "end_col": 58, "end_line": 959, "start_col": 3, "start_line": 953 }
FStar.Pervasives.Lemma
val comp_typing_ln (#g #c #u: _) (d: comp_typing g c u) : Lemma (ensures ln_c c)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let comp_typing_ln (#g:_) (#c:_) (#u:_) (d:comp_typing g c u) : Lemma (ensures ln_c c) = match d with | CT_Tot _ _ _ t_typing -> tot_or_ghost_typing_ln t_typing | CT_ST _ _ st_typing -> st_comp_typing_ln st_typing | CT_STAtomic _ _ _ inames_typing st_typing | CT_STGhost _ _ _ inames_typing st_typing -> tot_or_ghost_typing_ln inames_typing; st_comp_typing_ln st_typing
val comp_typing_ln (#g #c #u: _) (d: comp_typing g c u) : Lemma (ensures ln_c c) let comp_typing_ln (#g #c #u: _) (d: comp_typing g c u) : Lemma (ensures ln_c c) =
false
null
true
match d with | CT_Tot _ _ _ t_typing -> tot_or_ghost_typing_ln t_typing | CT_ST _ _ st_typing -> st_comp_typing_ln st_typing | CT_STAtomic _ _ _ inames_typing st_typing | CT_STGhost _ _ _ inames_typing st_typing -> tot_or_ghost_typing_ln inames_typing; st_comp_typing_ln st_typing
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.universe", "Pulse.Typing.comp_typing", "Pulse.Syntax.Base.term", "Pulse.Typing.universe_of", "Pulse.Typing.LN.tot_or_ghost_typing_ln", "Pulse.Syntax.Pure.tm_type", "FStar.Stubs.TypeChecker.Core.E_Total", "Pulse.Syntax.Base.st_comp", "Pulse.Typing.st_comp_typing", "Pulse.Typing.LN.st_comp_typing_ln", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_inames", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.b2t", "Pulse.Syntax.Naming.ln_c", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i let close_term_pairs' (t:list (term & term)) (v:var) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ ND v i ] let rec close_term_ln_pairs (t:list (term & term)) (x:var) (i:index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) = match t with | [] -> () | (l, r)::tl -> close_term_ln' l x i; close_term_ln' r x i; close_term_ln_pairs tl x i let close_proof_hint_ln (ht:proof_hint_type) (v:var) (i:index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> close_term_ln' p v i | RENAME { pairs; goal } -> close_term_ln_pairs pairs v i; close_term_ln_opt' goal v i | REWRITE { t1; t2 } -> close_term_ln' t1 v i; close_term_ln' t2 v i let rec close_st_term_ln' (t:st_term) (x:var) (i:index) : Lemma (requires ln_st' t (i - 1)) (ensures ln_st' (close_st_term' t x i) i) (decreases t) = match t.term with | Tm_Return { term } -> close_term_ln' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> close_term_ln' p x i | Tm_IntroExists { p; witnesses } -> close_term_ln' p x i; close_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> close_term_ln' invariant x (i + 1); close_st_term_ln' condition x i; close_st_term_ln' body x i | Tm_If { b; then_; else_; post } -> close_term_ln' b x i; close_st_term_ln' then_ x i; close_st_term_ln' else_ x i; close_term_ln_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_st_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_STApp { head; arg } -> close_term_ln' head x i; close_term_ln' arg x i | Tm_Abs { b; ascription=c; body } -> close_term_ln' b.binder_ty x i; close_comp_ln' c x (i + 1); close_st_term_ln' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> close_term_ln' pre1 x i; close_st_term_ln' body1 x i; close_term_ln' post1 x (i + 1); close_term_ln' pre2 x i; close_st_term_ln' body2 x i; close_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> close_term_ln' t1 x i; close_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_term_ln' length x i; close_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> close_term_ln' typ x i; close_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in close_proof_hint_ln hint_type x (i + n); close_st_term_ln' t x (i + n) let close_comp_ln (c:comp) (v:var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0) = close_comp_ln' c v 0 #push-options "--ifuel 2 --z3rlimit_factor 4 --z3cliopt 'smt.qi.eager_threshold=100'" let lift_comp_ln #g #c1 #c2 (d:lift_comp g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = () let tot_or_ghost_typing_ln (#g:_) (#e:_) (#t:_) (#eff:_) (d:typing g e eff t) : Lemma (ensures ln e /\ ln t) = let E dt = d in well_typed_terms_are_ln _ _ _ dt; elab_ln_inverse e; elab_ln_inverse t let tot_typing_ln (#g:_) (#e:_) (#t:_) (d:tot_typing g e t) : Lemma (ensures ln e /\ ln t) = tot_or_ghost_typing_ln d let rec vprop_equiv_ln (#g:_) (#t0 #t1:_) (v:vprop_equiv g t0 t1) : Lemma (ensures ln t0 <==> ln t1) (decreases v) = match v with | VE_Refl _ _ -> () | VE_Sym _ _ _ v' -> vprop_equiv_ln v' | VE_Trans g t0 t2 t1 v02 v21 -> vprop_equiv_ln v02; vprop_equiv_ln v21 | VE_Ctxt g s0 s1 s0' s1' v0 v1 -> vprop_equiv_ln v0; vprop_equiv_ln v1 | VE_Unit g t -> () | VE_Comm g t0 t1 -> () | VE_Assoc g t0 t1 t2 -> () | VE_Ext g t0 t1 token -> let d0, d1 = vprop_eq_typing_inversion _ _ _ token in tot_or_ghost_typing_ln d0; tot_or_ghost_typing_ln d1 let st_equiv_ln #g #c1 #c2 (d:st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = let ST_VPropEquiv _ _ _ x (E dpre) _dres _dpost eq_res eq_pre eq_post = d in vprop_equiv_ln eq_pre; open_term_ln_inv' (comp_post c1) (term_of_no_name_var x) 0; vprop_equiv_ln eq_post; rt_equiv_ln _ _ _ eq_res; elab_ln_inverse (comp_res c2); open_term_ln' (comp_post c2) (term_of_no_name_var x) 0 let bind_comp_ln #g #x #c1 #c2 #c (d:bind_comp g x c1 c2 c) : Lemma (requires ln_c c1 /\ ln_c c2) (ensures ln_c c) = () let st_comp_typing_ln (#g:_) (#st:_) (d:st_comp_typing g st) : Lemma (ensures ln_st_comp st (-1)) = let STC _ {post} x res_typing pre_typing post_typing = d in tot_or_ghost_typing_ln res_typing; tot_or_ghost_typing_ln pre_typing; tot_or_ghost_typing_ln post_typing; open_term_ln' post (null_var x) 0 let comp_typing_ln (#g:_) (#c:_) (#u:_) (d:comp_typing g c u) : Lemma (ensures ln_c c) =
false
false
Pulse.Typing.LN.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=100" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val comp_typing_ln (#g #c #u: _) (d: comp_typing g c u) : Lemma (ensures ln_c c)
[]
Pulse.Typing.LN.comp_typing_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
d: Pulse.Typing.comp_typing g c u171 -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln_c c)
{ "end_col": 31, "end_line": 985, "start_col": 2, "start_line": 979 }
FStar.Pervasives.Lemma
val ln_weakening_opt (t: option term) (i j: int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j
val ln_weakening_opt (t: option term) (i j: int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) let ln_weakening_opt (t: option term) (i j: int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) =
false
null
true
match t with | None -> () | Some t -> ln_weakening t i j
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.term", "Prims.int", "Pulse.Typing.LN.ln_weakening", "Prims.unit", "Prims.l_and", "Prims.b2t", "Pulse.Syntax.Naming.ln_opt'", "Prims.op_LessThanOrEqual", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j)
false
false
Pulse.Typing.LN.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 ln_weakening_opt (t: option term) (i j: int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t)
[]
Pulse.Typing.LN.ln_weakening_opt
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: FStar.Pervasives.Native.option Pulse.Syntax.Base.term -> i: Prims.int -> j: Prims.int -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_opt' t i /\ i <= j) (ensures Pulse.Syntax.Naming.ln_opt' t j) (decreases t)
{ "end_col": 34, "end_line": 383, "start_col": 4, "start_line": 381 }
FStar.Pervasives.Lemma
val ln_weakening_proof_hint (t: proof_hint_type) (i j: int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j
val ln_weakening_proof_hint (t: proof_hint_type) (i j: int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) let ln_weakening_proof_hint (t: proof_hint_type) (i j: int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) =
false
null
true
match t with | ASSERT { p = p } | FOLD { p = p } | UNFOLD { p = p } -> ln_weakening p i j | RENAME { pairs = pairs ; goal = goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1 = t1 ; t2 = t2 } -> ln_weakening t1 i j; ln_weakening t2 i j
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Syntax.Base.proof_hint_type", "Prims.int", "Pulse.Syntax.Base.vprop", "Pulse.Typing.LN.ln_weakening", "FStar.Pervasives.Native.option", "Prims.list", "Prims.string", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.term", "Pulse.Typing.LN.ln_weakening_opt", "Prims.unit", "Pulse.Typing.LN.ln_weakening_pairs", "Prims.l_and", "Prims.b2t", "Pulse.Syntax.Naming.ln_proof_hint'", "Prims.op_LessThanOrEqual", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j)
false
false
Pulse.Typing.LN.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 ln_weakening_proof_hint (t: proof_hint_type) (i j: int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j)
[]
Pulse.Typing.LN.ln_weakening_proof_hint
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Pulse.Syntax.Base.proof_hint_type -> i: Prims.int -> j: Prims.int -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_proof_hint' t i /\ i <= j) (ensures Pulse.Syntax.Naming.ln_proof_hint' t j)
{ "end_col": 25, "end_line": 423, "start_col": 4, "start_line": 413 }
FStar.Pervasives.Lemma
val open_term_ln_opt' (t: option term) (x: term) (i: index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i
val open_term_ln_opt' (t: option term) (x: term) (i: index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) let open_term_ln_opt' (t: option term) (x: term) (i: index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) =
false
null
true
match t with | None -> () | Some t -> open_term_ln' t x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.open_term_ln'", "Prims.unit", "Prims.b2t", "Pulse.Syntax.Naming.ln_opt'", "Pulse.Syntax.Naming.open_term_opt'", "Prims.op_Subtraction", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i)
false
false
Pulse.Typing.LN.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 open_term_ln_opt' (t: option term) (x: term) (i: index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t)
[]
Pulse.Typing.LN.open_term_ln_opt'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: FStar.Pervasives.Native.option Pulse.Syntax.Base.term -> x: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_opt' (Pulse.Syntax.Naming.open_term_opt' t x i) (i - 1)) (ensures Pulse.Syntax.Naming.ln_opt' t i) (decreases t)
{ "end_col": 35, "end_line": 93, "start_col": 4, "start_line": 91 }
FStar.Pervasives.Lemma
val open_term_ln_pairs (t: list (term & term)) (x: term) (i: index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i
val open_term_ln_pairs (t: list (term & term)) (x: term) (i: index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) let rec open_term_ln_pairs (t: list (term & term)) (x: term) (i: index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) =
false
null
true
match t with | [] -> () | (l, r) :: tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.open_term_ln_pairs", "Prims.unit", "Pulse.Typing.LN.open_term_ln'", "Prims.b2t", "Pulse.Syntax.Naming.ln_terms'", "Pulse.Typing.LN.open_term_pairs'", "Prims.op_Subtraction", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i)
false
false
Pulse.Typing.LN.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 open_term_ln_pairs (t: list (term & term)) (x: term) (i: index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t)
[ "recursion" ]
Pulse.Typing.LN.open_term_ln_pairs
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Prims.list (Pulse.Syntax.Base.term * Pulse.Syntax.Base.term) -> x: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_terms' (Pulse.Typing.LN.open_term_pairs' t x i) (i - 1)) (ensures Pulse.Syntax.Naming.ln_terms' t i) (decreases t)
{ "end_col": 31, "end_line": 125, "start_col": 4, "start_line": 120 }
FStar.Pervasives.Lemma
val close_comp_ln' (c: comp) (x: var) (i: index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1)
val close_comp_ln' (c: comp) (x: var) (i: index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) let close_comp_ln' (c: comp) (x: var) (i: index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) =
false
null
true
match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1)
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.var", "Pulse.Syntax.Base.index", "Pulse.Syntax.Base.term", "Pulse.Typing.LN.close_term_ln'", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.__proj__Mkst_comp__item__post", "Prims.op_Addition", "Prims.unit", "Pulse.Syntax.Base.__proj__Mkst_comp__item__pre", "Pulse.Syntax.Base.__proj__Mkst_comp__item__res", "Prims.b2t", "Pulse.Syntax.Naming.ln_c'", "Prims.op_Subtraction", "Prims.squash", "Pulse.Syntax.Naming.close_comp'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1))
false
false
Pulse.Typing.LN.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 close_comp_ln' (c: comp) (x: var) (i: index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i)
[]
Pulse.Typing.LN.close_comp_ln'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
c: Pulse.Syntax.Base.comp -> x: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_c' c (i - 1)) (ensures Pulse.Syntax.Naming.ln_c' (Pulse.Syntax.Naming.close_comp' c x i) i)
{ "end_col": 37, "end_line": 761, "start_col": 4, "start_line": 747 }
FStar.Pervasives.Lemma
val close_term_ln' (e: term) (x: var) (i: index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i
val close_term_ln' (e: term) (x: var) (i: index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) let rec close_term_ln' (e: term) (x: var) (i: index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) =
false
null
true
match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.var", "Pulse.Syntax.Base.index", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Typing.LN.close_term_ln'", "Prims.unit", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.binder", "Prims.op_Addition", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Syntax.Base.host_term", "Pulse.Typing.LN.r_close_term_ln'", "Prims.b2t", "Pulse.Syntax.Naming.ln'", "Prims.op_Subtraction", "Prims.squash", "Pulse.Syntax.Naming.close_term'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i)
false
false
Pulse.Typing.LN.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 close_term_ln' (e: term) (x: var) (i: index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e)
[ "recursion" ]
Pulse.Typing.LN.close_term_ln'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
e: Pulse.Syntax.Base.term -> x: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln' e (i - 1)) (ensures Pulse.Syntax.Naming.ln' (Pulse.Syntax.Naming.close_term' e x i) i) (decreases e)
{ "end_col": 28, "end_line": 739, "start_col": 4, "start_line": 719 }
FStar.Pervasives.Lemma
val open_comp_ln_inv' (c: comp) (x: term{ln x}) (i: index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1))
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1)
val open_comp_ln_inv' (c: comp) (x: term{ln x}) (i: index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) let open_comp_ln_inv' (c: comp) (x: term{ln x}) (i: index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) =
false
null
true
match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1)
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.term", "Prims.b2t", "Pulse.Syntax.Naming.ln", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.open_term_ln_inv'", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.__proj__Mkst_comp__item__post", "Prims.op_Addition", "Prims.unit", "Pulse.Syntax.Base.__proj__Mkst_comp__item__pre", "Pulse.Syntax.Base.__proj__Mkst_comp__item__res", "Pulse.Syntax.Naming.ln_c'", "Prims.squash", "Pulse.Syntax.Naming.open_comp'", "Prims.op_Subtraction", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i)
false
false
Pulse.Typing.LN.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 open_comp_ln_inv' (c: comp) (x: term{ln x}) (i: index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1))
[]
Pulse.Typing.LN.open_comp_ln_inv'
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
c: Pulse.Syntax.Base.comp -> x: Pulse.Syntax.Base.term{Pulse.Syntax.Naming.ln x} -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_c' c i) (ensures Pulse.Syntax.Naming.ln_c' (Pulse.Syntax.Naming.open_comp' c x i) (i - 1))
{ "end_col": 40, "end_line": 563, "start_col": 4, "start_line": 549 }
FStar.Pervasives.Lemma
val vprop_equiv_ln (#g #t0 #t1: _) (v: vprop_equiv g t0 t1) : Lemma (ensures ln t0 <==> ln t1) (decreases v)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec vprop_equiv_ln (#g:_) (#t0 #t1:_) (v:vprop_equiv g t0 t1) : Lemma (ensures ln t0 <==> ln t1) (decreases v) = match v with | VE_Refl _ _ -> () | VE_Sym _ _ _ v' -> vprop_equiv_ln v' | VE_Trans g t0 t2 t1 v02 v21 -> vprop_equiv_ln v02; vprop_equiv_ln v21 | VE_Ctxt g s0 s1 s0' s1' v0 v1 -> vprop_equiv_ln v0; vprop_equiv_ln v1 | VE_Unit g t -> () | VE_Comm g t0 t1 -> () | VE_Assoc g t0 t1 t2 -> () | VE_Ext g t0 t1 token -> let d0, d1 = vprop_eq_typing_inversion _ _ _ token in tot_or_ghost_typing_ln d0; tot_or_ghost_typing_ln d1
val vprop_equiv_ln (#g #t0 #t1: _) (v: vprop_equiv g t0 t1) : Lemma (ensures ln t0 <==> ln t1) (decreases v) let rec vprop_equiv_ln (#g #t0 #t1: _) (v: vprop_equiv g t0 t1) : Lemma (ensures ln t0 <==> ln t1) (decreases v) =
false
null
true
match v with | VE_Refl _ _ -> () | VE_Sym _ _ _ v' -> vprop_equiv_ln v' | VE_Trans g t0 t2 t1 v02 v21 -> vprop_equiv_ln v02; vprop_equiv_ln v21 | VE_Ctxt g s0 s1 s0' s1' v0 v1 -> vprop_equiv_ln v0; vprop_equiv_ln v1 | VE_Unit g t -> () | VE_Comm g t0 t1 -> () | VE_Assoc g t0 t1 t2 -> () | VE_Ext g t0 t1 token -> let d0, d1 = vprop_eq_typing_inversion _ _ _ token in tot_or_ghost_typing_ln d0; tot_or_ghost_typing_ln d1
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma", "" ]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.vprop_equiv", "Pulse.Typing.LN.vprop_equiv_ln", "Prims.unit", "FStar.Tactics.Types.equiv_token", "Pulse.Typing.elab_env", "Pulse.Elaborate.Pure.elab_term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.LN.tot_or_ghost_typing_ln", "FStar.Stubs.TypeChecker.Core.E_Total", "FStar.Pervasives.Native.tuple2", "Pulse.Typing.vprop_eq_typing_inversion", "Prims.l_True", "Prims.squash", "Prims.l_iff", "Prims.b2t", "Pulse.Syntax.Naming.ln", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i let close_term_pairs' (t:list (term & term)) (v:var) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ ND v i ] let rec close_term_ln_pairs (t:list (term & term)) (x:var) (i:index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) = match t with | [] -> () | (l, r)::tl -> close_term_ln' l x i; close_term_ln' r x i; close_term_ln_pairs tl x i let close_proof_hint_ln (ht:proof_hint_type) (v:var) (i:index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> close_term_ln' p v i | RENAME { pairs; goal } -> close_term_ln_pairs pairs v i; close_term_ln_opt' goal v i | REWRITE { t1; t2 } -> close_term_ln' t1 v i; close_term_ln' t2 v i let rec close_st_term_ln' (t:st_term) (x:var) (i:index) : Lemma (requires ln_st' t (i - 1)) (ensures ln_st' (close_st_term' t x i) i) (decreases t) = match t.term with | Tm_Return { term } -> close_term_ln' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> close_term_ln' p x i | Tm_IntroExists { p; witnesses } -> close_term_ln' p x i; close_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> close_term_ln' invariant x (i + 1); close_st_term_ln' condition x i; close_st_term_ln' body x i | Tm_If { b; then_; else_; post } -> close_term_ln' b x i; close_st_term_ln' then_ x i; close_st_term_ln' else_ x i; close_term_ln_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_st_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_STApp { head; arg } -> close_term_ln' head x i; close_term_ln' arg x i | Tm_Abs { b; ascription=c; body } -> close_term_ln' b.binder_ty x i; close_comp_ln' c x (i + 1); close_st_term_ln' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> close_term_ln' pre1 x i; close_st_term_ln' body1 x i; close_term_ln' post1 x (i + 1); close_term_ln' pre2 x i; close_st_term_ln' body2 x i; close_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> close_term_ln' t1 x i; close_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_term_ln' length x i; close_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> close_term_ln' typ x i; close_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in close_proof_hint_ln hint_type x (i + n); close_st_term_ln' t x (i + n) let close_comp_ln (c:comp) (v:var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0) = close_comp_ln' c v 0 #push-options "--ifuel 2 --z3rlimit_factor 4 --z3cliopt 'smt.qi.eager_threshold=100'" let lift_comp_ln #g #c1 #c2 (d:lift_comp g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = () let tot_or_ghost_typing_ln (#g:_) (#e:_) (#t:_) (#eff:_) (d:typing g e eff t) : Lemma (ensures ln e /\ ln t) = let E dt = d in well_typed_terms_are_ln _ _ _ dt; elab_ln_inverse e; elab_ln_inverse t let tot_typing_ln (#g:_) (#e:_) (#t:_) (d:tot_typing g e t) : Lemma (ensures ln e /\ ln t) = tot_or_ghost_typing_ln d let rec vprop_equiv_ln (#g:_) (#t0 #t1:_) (v:vprop_equiv g t0 t1) : Lemma (ensures ln t0 <==> ln t1)
false
false
Pulse.Typing.LN.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=100" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vprop_equiv_ln (#g #t0 #t1: _) (v: vprop_equiv g t0 t1) : Lemma (ensures ln t0 <==> ln t1) (decreases v)
[ "recursion" ]
Pulse.Typing.LN.vprop_equiv_ln
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
v: Pulse.Typing.vprop_equiv g t0 t1 -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln t0 <==> Pulse.Syntax.Naming.ln t1) (decreases v)
{ "end_col": 31, "end_line": 947, "start_col": 4, "start_line": 931 }
FStar.Pervasives.Lemma
val st_typing_ln_tot_or_ghost_bind (#g #t #c: _) (d: st_typing g t c {T_TotBind? d \/ T_GhostBind? d}) (typing_ln: (#g: env -> #e: st_term -> #c: comp -> d': st_typing g e c {d' << d} -> Lemma (ensures ln_st e /\ ln_c c))) : Lemma (ensures ln_st t /\ ln_c c)
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Naming", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let st_typing_ln_tot_or_ghost_bind #g #t #c (d:st_typing g t c { T_TotBind? d \/ T_GhostBind? d }) (typing_ln: (#g:env -> #e:st_term -> #c:comp -> d':st_typing g e c{d' << d} -> Lemma (ensures ln_st e /\ ln_c c))) : Lemma (ensures ln_st t /\ ln_c c) = match d with | T_TotBind _ e1 e2 _ c2 b x e1_typing e2_typing | T_GhostBind _ e1 e2 _ c2 b x e1_typing e2_typing _ -> tot_or_ghost_typing_ln e1_typing; typing_ln e2_typing; open_st_term_ln e2 x; close_comp_ln' c2 x 0; open_comp_ln_inv' (close_comp c2 x) e1 0
val st_typing_ln_tot_or_ghost_bind (#g #t #c: _) (d: st_typing g t c {T_TotBind? d \/ T_GhostBind? d}) (typing_ln: (#g: env -> #e: st_term -> #c: comp -> d': st_typing g e c {d' << d} -> Lemma (ensures ln_st e /\ ln_c c))) : Lemma (ensures ln_st t /\ ln_c c) let st_typing_ln_tot_or_ghost_bind #g #t #c (d: st_typing g t c {T_TotBind? d \/ T_GhostBind? d}) (typing_ln: (#g: env -> #e: st_term -> #c: comp -> d': st_typing g e c {d' << d} -> Lemma (ensures ln_st e /\ ln_c c))) : Lemma (ensures ln_st t /\ ln_c c) =
false
null
false
match d with | T_TotBind _ e1 e2 _ c2 b x e1_typing e2_typing | T_GhostBind _ e1 e2 _ c2 b x e1_typing e2_typing _ -> tot_or_ghost_typing_ln e1_typing; typing_ln e2_typing; open_st_term_ln e2 x; close_comp_ln' c2 x 0; open_comp_ln_inv' (close_comp c2 x) e1 0
{ "checked_file": "Pulse.Typing.LN.fst.checked", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ "lemma" ]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.comp", "Pulse.Typing.st_typing", "Prims.l_or", "Prims.b2t", "Pulse.Typing.uu___is_T_TotBind", "Pulse.Typing.uu___is_T_GhostBind", "Prims.precedes", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_and", "Pulse.Syntax.Naming.ln_st", "Pulse.Syntax.Naming.ln_c", "Prims.Nil", "FStar.Pervasives.pattern", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.comp_st", "Pulse.Syntax.Base.binder", "Prims.eq2", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Syntax.Base.var", "FStar.Pervasives.Native.uu___is_None", "Pulse.Syntax.Base.typ", "Pulse.Typing.Env.lookup", "Prims.l_not", "FStar.Set.mem", "Pulse.Syntax.Naming.freevars_st", "Pulse.Typing.tot_typing", "Pulse.Typing.Env.push_binding", "Pulse.Syntax.Base.ppname_default", "Pulse.Syntax.Naming.open_st_term_nv", "Pulse.Syntax.Base.v_as_nv", "Pulse.Typing.LN.open_comp_ln_inv'", "Pulse.Syntax.Naming.close_comp", "Pulse.Typing.LN.close_comp_ln'", "Pulse.Typing.LN.open_st_term_ln", "Pulse.Typing.LN.tot_or_ghost_typing_ln", "FStar.Stubs.TypeChecker.Core.E_Total", "Pulse.Typing.ghost_typing", "Pulse.Typing.non_informative", "FStar.Stubs.TypeChecker.Core.E_Ghost" ]
[]
module Pulse.Typing.LN module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot open FStar.List.Tot open Pulse.Syntax open Pulse.Typing // // TODO: this is needed only for the E_Total flag, // may be the flag should move to reflection // module T = FStar.Tactics.V2 let well_typed_terms_are_ln (g:R.env) (e:R.term) (t:R.term) (#eff:_) (d:RT.typing g e (eff, t)) : Lemma (ensures RT.ln e /\ RT.ln t) = RT.well_typed_terms_are_ln g e (eff, t) d let rt_equiv_ln (g:R.env) (e1 e2:R.term) (d:RT.equiv g e1 e2) : Lemma (RT.ln e1 /\ RT.ln e2) = admit () assume val elab_ln_inverse (e:term) : Lemma (requires RT.ln (elab_term e)) (ensures ln e) assume val open_term_ln_host' (t:host_term) (x:R.term) (i:index) : Lemma (requires RT.ln' (RT.subst_term t [ RT.DT i x ]) (i - 1)) (ensures RT.ln' t i) let rec open_term_ln' (e:term) (x:term) (i:index) : Lemma (requires ln' (open_term' e x i) (i - 1)) (ensures ln' e i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> open_term_ln' p x i | Tm_Star l r -> open_term_ln' l x i; open_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln' t.binder_ty x i; open_term_ln' b x (i + 1) | Tm_FStar t -> open_term_ln_host' t (elab_term x) i let open_comp_ln' (c:comp) (x:term) (i:index) : Lemma (requires ln_c' (open_comp' c x i) (i - 1)) (ensures ln_c' c i) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s -> open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln' n x i; open_term_ln' s.res x i; open_term_ln' s.pre x i; open_term_ln' s.post x (i + 1) let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i // aux let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs let rec open_term_ln_list' (t:list term) (x:term) (i:index) : Lemma (requires ln_list' (open_term_list' t x i) (i - 1)) (ensures ln_list' t i) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i let open_term_pairs' (t:list (term & term)) (v:term) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ DT i v ] let rec open_term_ln_pairs (t:list (term & term)) (x:term) (i:index) : Lemma (requires ln_terms' (open_term_pairs' t x i) (i - 1)) (ensures ln_terms' t i) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln' l x i; open_term_ln' r x i; open_term_ln_pairs tl x i let open_proof_hint_ln (t:proof_hint_type) (x:term) (i:index) : Lemma (requires ln_proof_hint' (open_proof_hint' t x i) (i - 1)) (ensures ln_proof_hint' t i) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln' p x i | RENAME { pairs; goal } -> open_term_ln_pairs pairs x i; open_term_ln_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i] let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v] let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i] let rec pattern_shift_subst_invariant (p:pattern) (s:subst) : Lemma (ensures pattern_shift_n p == pattern_shift_n (subst_pat p s)) [SMTPat (pattern_shift_n (subst_pat p s))] = match p with | Pat_Cons _ subpats -> admit() | _ -> () and pattern_args_shift_subst_invariant (ps:list (pattern & bool)) (s:subst) : Lemma (ensures pattern_args_shift_n ps == pattern_args_shift_n (subst_pat_args ps s)) = match ps with | [] -> () | (hd, _)::tl -> pattern_shift_subst_invariant hd s; pattern_args_shift_subst_invariant tl (shift_subst_n (pattern_shift_n hd) s) let rec open_pattern_ln (p:pattern) (x:term) (i:index) : Lemma (requires ln_pattern' (open_pattern' p x i) (i - 1)) (ensures ln_pattern' p i) (decreases p) = match p with | Pat_Constant _ | Pat_Var _ _ | Pat_Dot_Term None -> () | Pat_Dot_Term (Some e) -> open_term_ln' e x i | Pat_Cons _ subpats -> open_pattern_args_ln subpats x i and open_pattern_args_ln (pats:list (pattern & bool)) (x:term) (i:index) : Lemma (requires ln_pattern_args' (open_pattern_args' pats x i) (i - 1)) (ensures ln_pattern_args' pats i) (decreases pats) = match pats with | [] -> () | (hd, b)::tl -> open_pattern_ln hd x i; open_pattern_args_ln tl x (i + pattern_shift_n hd) let rec open_st_term_ln' (e:st_term) (x:term) (i:index) : Lemma (requires ln_st' (open_st_term' e x i) (i - 1)) (ensures ln_st' e i) (decreases e) = match e.term with | Tm_Return { term = e } -> open_term_ln' e x i | Tm_STApp { head=l; arg=r } -> open_term_ln' l x i; open_term_ln' r x i | Tm_Abs { b; ascription=c; body } -> open_term_ln' b.binder_ty x i; open_comp_ln' c x (i + 1); open_st_term_ln' body x (i + 1) | Tm_Bind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_st_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' head x i; open_st_term_ln' body x (i + 1) | Tm_If { b; then_; else_; post } -> open_term_ln' b x i; open_st_term_ln' then_ x i; open_st_term_ln' else_ x i; open_term_ln_opt' post x (i + 1) | Tm_Match {sc;returns_;brs} -> open_term_ln' sc x i; open_term_ln_opt' returns_ x i; assert (__brs_of e == brs); open_branches_ln' e brs x i; () | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln' p x i; open_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln' invariant x (i + 1); open_st_term_ln' condition x i; open_st_term_ln' body x i | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln' pre1 x i; open_st_term_ln' body1 x i; open_term_ln' post1 x (i + 1); open_term_ln' pre2 x i; open_st_term_ln' body2 x i; open_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln' t1 x i; open_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln' binder.binder_ty x i; open_term_ln' initializer x i; open_term_ln' length x i; open_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln' typ x i; open_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln hint_type x (i + n); open_st_term_ln' t x (i + n) // The Tm_Match? and __brs_of conditions are to prove that the ln_branches' below // satisfies the termination refinment. and open_branches_ln' (t:st_term{Tm_Match? t.term}) (brs:list branch{brs << t /\ __brs_of t == brs}) (x:term) (i:index) : Lemma (requires ( assert (subst_branches t [DT i x] brs == __brs_of (subst_st_term t [DT i x])); // hint ln_branches' (open_st_term' t x i) (subst_branches t [DT i x] brs) (i - 1))) (ensures ln_branches' t brs i) (decreases brs) = match brs with | [] -> () | br::brs -> assume (ln_branch' (subst_branch [DT i x] br) (i - 1)); // Should be immediate. Unfold open_branch_ln' br x i; admit () and open_branch_ln' (br : branch) (x:term) (i:index) : Lemma (requires ln_branch' (subst_branch [DT i x] br) (i - 1)) (ensures ln_branch' br i) = let (p, e) = br in open_pattern_ln p x i; open_st_term_ln' e x (i + pattern_shift_n p) let open_term_ln (e:term) (v:var) : Lemma (requires ln (open_term e v)) (ensures ln' e 0) = open_term_ln' e (term_of_no_name_var v) 0 let open_st_term_ln (e:st_term) (v:var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 0) = open_st_term_ln' e (term_of_no_name_var v) 0 assume val r_ln_weakening (e:R.term) (i j:int) : Lemma (requires RT.ln' e i /\ i <= j) (ensures RT.ln' e j) let rec ln_weakening (e:term) (i j:int) : Lemma (requires ln' e i /\ i <= j) (ensures ln' e j) (decreases e) [SMTPat (ln' e j); SMTPat (ln' e i)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_Star l r -> ln_weakening l i j; ln_weakening r i j | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> ln_weakening t.binder_ty i j; ln_weakening b (i + 1) (j + 1) | Tm_FStar t -> r_ln_weakening t i j let ln_weakening_comp (c:comp) (i j:int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j) = match c with | C_Tot t -> ln_weakening t i j | C_ST s -> ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) | C_STAtomic n s | C_STGhost n s -> ln_weakening n i j; ln_weakening s.res i j; ln_weakening s.pre i j; ln_weakening s.post (i + 1) (j + 1) let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' t i /\ i <= j) (ensures ln_opt' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j let rec ln_weakening_list (t:list term) (i j:int) : Lemma (requires ln_list' t i /\ i <= j) (ensures ln_list' t j) (decreases t) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j let rec ln_weakening_pairs (t:list (term & term)) (i j:int) : Lemma (requires ln_terms' t i /\ i <= j) (ensures ln_terms' t j) (decreases t) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j let ln_weakening_proof_hint (t:proof_hint_type) (i j:int) : Lemma (requires ln_proof_hint' t i /\ i <= j) (ensures ln_proof_hint' t j) = match t with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> ln_weakening p i j | RENAME { pairs; goal } -> ln_weakening_pairs pairs i j; ln_weakening_opt goal i j | REWRITE { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j let rec ln_weakening_st (t:st_term) (i j:int) : Lemma (requires ln_st' t i /\ i <= j) (ensures ln_st' t j) (decreases t) = match t.term with | Tm_Return { term } -> ln_weakening term i j | Tm_IntroPure { p } | Tm_ElimExists { p } -> ln_weakening p i j | Tm_IntroExists { p; witnesses } -> ln_weakening p i j; ln_weakening_list witnesses i j | Tm_While { invariant; condition; body } -> ln_weakening invariant (i + 1) (j + 1); ln_weakening_st condition i j; ln_weakening_st body i j | Tm_If { b; then_; else_; post } -> ln_weakening b i j; ln_weakening_st then_ i j; ln_weakening_st else_ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_Match _ -> admit () | Tm_STApp { head; arg } -> ln_weakening head i j; ln_weakening arg i j | Tm_Bind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening_st head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_TotBind { binder; head; body } -> ln_weakening binder.binder_ty i j; ln_weakening head i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Abs { b; ascription=c; body } -> ln_weakening b.binder_ty i j; ln_weakening_comp c (i + 1) (j + 1); ln_weakening_st body (i + 1) (j + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> ln_weakening pre1 i j; ln_weakening_st body1 i j; ln_weakening post1 (i + 1) (j + 1); ln_weakening pre2 i j; ln_weakening_st body2 i j; ln_weakening post2 (i + 1) (j + 1) | Tm_Rewrite { t1; t2 } -> ln_weakening t1 i j; ln_weakening t2 i j | Tm_WithLocal { initializer; body } -> ln_weakening initializer i j; ln_weakening_st body (i + 1) (j + 1) | Tm_WithLocalArray { initializer; length; body } -> ln_weakening initializer i j; ln_weakening length i j; ln_weakening_st body (i + 1) (j + 1) | Tm_Admit { typ; post } -> ln_weakening typ i j; ln_weakening_opt post (i + 1) (j + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in ln_weakening_proof_hint hint_type (i + n) (j + n); ln_weakening_st t (i + n) (j + n) assume val r_open_term_ln_inv' (e:R.term) (x:R.term { RT.ln x }) (i:index) : Lemma (requires RT.ln' e i) (ensures RT.ln' (RT.subst_term e [ RT.DT i x ]) (i - 1)) let rec open_term_ln_inv' (e:term) (x:term { ln x }) (i:index) : Lemma (requires ln' e i) (ensures ln' (open_term' e x i) (i - 1)) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_Star l r -> open_term_ln_inv' l x i; open_term_ln_inv' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> open_term_ln_inv' t.binder_ty x i; open_term_ln_inv' b x (i + 1) | Tm_FStar t -> Pulse.Elaborate.elab_ln x (-1); r_open_term_ln_inv' t (elab_term x) i let open_comp_ln_inv' (c:comp) (x:term { ln x }) (i:index) : Lemma (requires ln_c' c i) (ensures ln_c' (open_comp' c x i) (i - 1)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s -> open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> open_term_ln_inv' n x i; open_term_ln_inv' s.res x i; open_term_ln_inv' s.pre x i; open_term_ln_inv' s.post x (i + 1) let open_term_ln_inv_opt' (t:option term) (x:term { ln x }) (i:index) : Lemma (requires ln_opt' t i) (ensures ln_opt' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i let rec open_term_ln_inv_list' (t:list term) (x:term { ln x }) (i:index) : Lemma (requires ln_list' t i) (ensures ln_list' (open_term_list' t x i) (i - 1)) (decreases t) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i let rec open_term_ln_inv_pairs (t:list (term & term)) (x:term { ln x }) (i:index) : Lemma (requires ln_terms' t i) (ensures ln_terms' (open_term_pairs' t x i) (i - 1)) (decreases t) = match t with | [] -> () | (l, r)::tl -> open_term_ln_inv' l x i; open_term_ln_inv' r x i; open_term_ln_inv_pairs tl x i let open_proof_hint_ln_inv (ht:proof_hint_type) (x:term { ln x }) (i:index) : Lemma (requires ln_proof_hint' ht i) (ensures ln_proof_hint' (open_proof_hint' ht x i) (i - 1)) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> open_term_ln_inv' p x i | RENAME { pairs; goal } -> open_term_ln_inv_pairs pairs x i; open_term_ln_inv_opt' goal x i | REWRITE { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i #push-options "--z3rlimit_factor 2 --fuel 2 --ifuel 2" let rec open_term_ln_inv_st' (t:st_term) (x:term { ln x }) (i:index) : Lemma (requires ln_st' t i) (ensures ln_st' (open_st_term' t x i) (i - 1)) (decreases t) = match t.term with | Tm_Return { term } -> open_term_ln_inv' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> open_term_ln_inv' p x i | Tm_IntroExists { p; witnesses } -> open_term_ln_inv' p x i; open_term_ln_inv_list' witnesses x i | Tm_While { invariant; condition; body } -> open_term_ln_inv' invariant x (i + 1); open_term_ln_inv_st' condition x i; open_term_ln_inv_st' body x i | Tm_If { b; then_; else_; post } -> open_term_ln_inv' b x i; open_term_ln_inv_st' then_ x i; open_term_ln_inv_st' else_ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv_st' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_TotBind { binder; head; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' head x i; open_term_ln_inv_st' body x (i + 1) | Tm_STApp { head; arg} -> open_term_ln_inv' head x i; open_term_ln_inv' arg x i | Tm_Abs { b; ascription=c; body } -> open_term_ln_inv' b.binder_ty x i; open_comp_ln_inv' c x (i + 1); open_term_ln_inv_st' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> open_term_ln_inv' pre1 x i; open_term_ln_inv_st' body1 x i; open_term_ln_inv' post1 x (i + 1); open_term_ln_inv' pre2 x i; open_term_ln_inv_st' body2 x i; open_term_ln_inv' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> open_term_ln_inv' t1 x i; open_term_ln_inv' t2 x i | Tm_WithLocal { binder; initializer; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv_st' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> open_term_ln_inv' binder.binder_ty x i; open_term_ln_inv' initializer x i; open_term_ln_inv' length x i; open_term_ln_inv_st' body x (i + 1) | Tm_Admit { typ; post } -> open_term_ln_inv' typ x i; open_term_ln_inv_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in open_proof_hint_ln_inv hint_type x (i + n); open_term_ln_inv_st' t x (i + n) #pop-options assume val r_close_term_ln' (e:R.term) (x:var) (i:index) : Lemma (requires RT.ln' e (i - 1)) (ensures RT.ln' (RT.subst_term e [ RT.ND x i ]) i) let rec close_term_ln' (e:term) (x:var) (i:index) : Lemma (requires ln' e (i - 1)) (ensures ln' (close_term' e x i) i) (decreases e) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Pure p -> close_term_ln' p x i | Tm_Star l r -> close_term_ln' l x i; close_term_ln' r x i | Tm_ExistsSL _ t b | Tm_ForallSL _ t b -> close_term_ln' t.binder_ty x i; close_term_ln' b x (i + 1) | Tm_FStar t -> r_close_term_ln' t x i let close_comp_ln' (c:comp) (x:var) (i:index) : Lemma (requires ln_c' c (i - 1)) (ensures ln_c' (close_comp' c x i) i) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s -> close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) | C_STAtomic n s | C_STGhost n s -> close_term_ln' n x i; close_term_ln' s.res x i; close_term_ln' s.pre x i; close_term_ln' s.post x (i + 1) let close_term_ln_opt' (t:option term) (x:var) (i:index) : Lemma (requires ln_opt' t (i - 1)) (ensures ln_opt' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i let rec close_term_ln_list' (t:list term) (x:var) (i:index) : Lemma (requires ln_list' t (i - 1)) (ensures ln_list' (close_term_list' t x i) i) (decreases t) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i let close_term_pairs' (t:list (term & term)) (v:var) (i:index) : Tot (list (term & term)) = subst_term_pairs t [ ND v i ] let rec close_term_ln_pairs (t:list (term & term)) (x:var) (i:index) : Lemma (requires ln_terms' t (i - 1)) (ensures ln_terms' (close_term_pairs' t x i) i) (decreases t) = match t with | [] -> () | (l, r)::tl -> close_term_ln' l x i; close_term_ln' r x i; close_term_ln_pairs tl x i let close_proof_hint_ln (ht:proof_hint_type) (v:var) (i:index) : Lemma (requires ln_proof_hint' ht (i - 1)) (ensures ln_proof_hint' (close_proof_hint' ht v i) i) = match ht with | ASSERT { p } | FOLD { p } | UNFOLD { p } -> close_term_ln' p v i | RENAME { pairs; goal } -> close_term_ln_pairs pairs v i; close_term_ln_opt' goal v i | REWRITE { t1; t2 } -> close_term_ln' t1 v i; close_term_ln' t2 v i let rec close_st_term_ln' (t:st_term) (x:var) (i:index) : Lemma (requires ln_st' t (i - 1)) (ensures ln_st' (close_st_term' t x i) i) (decreases t) = match t.term with | Tm_Return { term } -> close_term_ln' term x i | Tm_IntroPure { p } | Tm_ElimExists { p } -> close_term_ln' p x i | Tm_IntroExists { p; witnesses } -> close_term_ln' p x i; close_term_ln_list' witnesses x i | Tm_While { invariant; condition; body } -> close_term_ln' invariant x (i + 1); close_st_term_ln' condition x i; close_st_term_ln' body x i | Tm_If { b; then_; else_; post } -> close_term_ln' b x i; close_st_term_ln' then_ x i; close_st_term_ln' else_ x i; close_term_ln_opt' post x (i + 1) | Tm_Match _ -> admit () | Tm_Bind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_st_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_TotBind { binder; head; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' head x i; close_st_term_ln' body x (i + 1) | Tm_STApp { head; arg } -> close_term_ln' head x i; close_term_ln' arg x i | Tm_Abs { b; ascription=c; body } -> close_term_ln' b.binder_ty x i; close_comp_ln' c x (i + 1); close_st_term_ln' body x (i + 1) | Tm_Par { pre1; body1; post1; pre2; body2; post2 } -> close_term_ln' pre1 x i; close_st_term_ln' body1 x i; close_term_ln' post1 x (i + 1); close_term_ln' pre2 x i; close_st_term_ln' body2 x i; close_term_ln' post2 x (i + 1) | Tm_Rewrite { t1; t2 } -> close_term_ln' t1 x i; close_term_ln' t2 x i | Tm_WithLocal { binder; initializer; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_st_term_ln' body x (i + 1) | Tm_WithLocalArray { binder; initializer; length; body } -> close_term_ln' binder.binder_ty x i; close_term_ln' initializer x i; close_term_ln' length x i; close_st_term_ln' body x (i + 1) | Tm_Admit { typ; post } -> close_term_ln' typ x i; close_term_ln_opt' post x (i + 1) | Tm_ProofHintWithBinders { binders; hint_type; t } -> let n = L.length binders in close_proof_hint_ln hint_type x (i + n); close_st_term_ln' t x (i + n) let close_comp_ln (c:comp) (v:var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp c v) 0) = close_comp_ln' c v 0 #push-options "--ifuel 2 --z3rlimit_factor 4 --z3cliopt 'smt.qi.eager_threshold=100'" let lift_comp_ln #g #c1 #c2 (d:lift_comp g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = () let tot_or_ghost_typing_ln (#g:_) (#e:_) (#t:_) (#eff:_) (d:typing g e eff t) : Lemma (ensures ln e /\ ln t) = let E dt = d in well_typed_terms_are_ln _ _ _ dt; elab_ln_inverse e; elab_ln_inverse t let tot_typing_ln (#g:_) (#e:_) (#t:_) (d:tot_typing g e t) : Lemma (ensures ln e /\ ln t) = tot_or_ghost_typing_ln d let rec vprop_equiv_ln (#g:_) (#t0 #t1:_) (v:vprop_equiv g t0 t1) : Lemma (ensures ln t0 <==> ln t1) (decreases v) = match v with | VE_Refl _ _ -> () | VE_Sym _ _ _ v' -> vprop_equiv_ln v' | VE_Trans g t0 t2 t1 v02 v21 -> vprop_equiv_ln v02; vprop_equiv_ln v21 | VE_Ctxt g s0 s1 s0' s1' v0 v1 -> vprop_equiv_ln v0; vprop_equiv_ln v1 | VE_Unit g t -> () | VE_Comm g t0 t1 -> () | VE_Assoc g t0 t1 t2 -> () | VE_Ext g t0 t1 token -> let d0, d1 = vprop_eq_typing_inversion _ _ _ token in tot_or_ghost_typing_ln d0; tot_or_ghost_typing_ln d1 let st_equiv_ln #g #c1 #c2 (d:st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = let ST_VPropEquiv _ _ _ x (E dpre) _dres _dpost eq_res eq_pre eq_post = d in vprop_equiv_ln eq_pre; open_term_ln_inv' (comp_post c1) (term_of_no_name_var x) 0; vprop_equiv_ln eq_post; rt_equiv_ln _ _ _ eq_res; elab_ln_inverse (comp_res c2); open_term_ln' (comp_post c2) (term_of_no_name_var x) 0 let bind_comp_ln #g #x #c1 #c2 #c (d:bind_comp g x c1 c2 c) : Lemma (requires ln_c c1 /\ ln_c c2) (ensures ln_c c) = () let st_comp_typing_ln (#g:_) (#st:_) (d:st_comp_typing g st) : Lemma (ensures ln_st_comp st (-1)) = let STC _ {post} x res_typing pre_typing post_typing = d in tot_or_ghost_typing_ln res_typing; tot_or_ghost_typing_ln pre_typing; tot_or_ghost_typing_ln post_typing; open_term_ln' post (null_var x) 0 let comp_typing_ln (#g:_) (#c:_) (#u:_) (d:comp_typing g c u) : Lemma (ensures ln_c c) = match d with | CT_Tot _ _ _ t_typing -> tot_or_ghost_typing_ln t_typing | CT_ST _ _ st_typing -> st_comp_typing_ln st_typing | CT_STAtomic _ _ _ inames_typing st_typing | CT_STGhost _ _ _ inames_typing st_typing -> tot_or_ghost_typing_ln inames_typing; st_comp_typing_ln st_typing let st_typing_ln_tot_or_ghost_bind #g #t #c (d:st_typing g t c { T_TotBind? d \/ T_GhostBind? d }) (typing_ln: (#g:env -> #e:st_term -> #c:comp -> d':st_typing g e c{d' << d} -> Lemma (ensures ln_st e /\ ln_c c))) : Lemma (ensures ln_st t /\ ln_c c) =
false
false
Pulse.Typing.LN.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=100" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val st_typing_ln_tot_or_ghost_bind (#g #t #c: _) (d: st_typing g t c {T_TotBind? d \/ T_GhostBind? d}) (typing_ln: (#g: env -> #e: st_term -> #c: comp -> d': st_typing g e c {d' << d} -> Lemma (ensures ln_st e /\ ln_c c))) : Lemma (ensures ln_st t /\ ln_c c)
[]
Pulse.Typing.LN.st_typing_ln_tot_or_ghost_bind
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
d: Pulse.Typing.st_typing g t c {T_TotBind? d \/ T_GhostBind? d} -> typing_ln: (d': Pulse.Typing.st_typing g e c {d' << d} -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln_st e /\ Pulse.Syntax.Naming.ln_c c)) -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln_st t /\ Pulse.Syntax.Naming.ln_c c)
{ "end_col": 44, "end_line": 1003, "start_col": 2, "start_line": 996 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n)
let a_spec (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len {0 < BD.bn_v n}) =
false
null
false
Lib.NatMod.nat_mod (BD.bn_v n)
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.NatMod.nat_mod" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract
false
false
Hacl.Bignum.AlmostMontExponentiation.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 a_spec : n: Hacl.Spec.Bignum.Definitions.lbignum t len {0 < Hacl.Spec.Bignum.Definitions.bn_v n} -> Type0
[]
Hacl.Bignum.AlmostMontExponentiation.a_spec
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len {0 < Hacl.Spec.Bignum.Definitions.bn_v n} -> Type0
{ "end_col": 32, "end_line": 38, "start_col": 2, "start_line": 38 }
Prims.Tot
val linv (#t: limb_t) (#len: SN.bn_len t) (n a: BD.lbignum t len) : Type0
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len)
val linv (#t: limb_t) (#len: SN.bn_len t) (n a: BD.lbignum t len) : Type0 let linv (#t: limb_t) (#len: SN.bn_len t) (n a: BD.lbignum t len) : Type0 =
false
null
false
BD.bn_v a < pow2 (bits t * len)
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.pow2", "FStar.Mul.op_Star", "Lib.IntTypes.bits" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract
false
false
Hacl.Bignum.AlmostMontExponentiation.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 linv (#t: limb_t) (#len: SN.bn_len t) (n a: BD.lbignum t len) : Type0
[]
Hacl.Bignum.AlmostMontExponentiation.linv
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> Type0
{ "end_col": 33, "end_line": 42, "start_col": 2, "start_line": 42 }
Prims.Tot
val refl (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len {0 < BD.bn_v n}) (a: BD.lbignum t len {linv n a}) : a_spec n
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n
val refl (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len {0 < BD.bn_v n}) (a: BD.lbignum t len {linv n a}) : a_spec n let refl (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len {0 < BD.bn_v n}) (a: BD.lbignum t len {linv n a}) : a_spec n =
false
null
false
BD.bn_v a % BD.bn_v n
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Bignum.AlmostMontExponentiation.linv", "Prims.op_Modulus", "Hacl.Bignum.AlmostMontExponentiation.a_spec" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract
false
false
Hacl.Bignum.AlmostMontExponentiation.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 refl (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len {0 < BD.bn_v n}) (a: BD.lbignum t len {linv n a}) : a_spec n
[]
Hacl.Bignum.AlmostMontExponentiation.refl
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len {0 < Hacl.Spec.Bignum.Definitions.bn_v n} -> a: Hacl.Spec.Bignum.Definitions.lbignum t len {Hacl.Bignum.AlmostMontExponentiation.linv n a} -> Hacl.Bignum.AlmostMontExponentiation.a_spec n
{ "end_col": 23, "end_line": 46, "start_col": 2, "start_line": 46 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_almost_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_almost_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM % bn_v h0 n == LE.pow k1 (bn_v h0 aM) (bn_v h0 b)))
let bn_exp_almost_mont_st (t: limb_t) (len: BN.meta_len t) =
false
null
false
n: lbignum t len -> mu: limb t -> r2: lbignum t len -> aM: lbignum t len -> bBits: size_t -> b: lbignum t (blocks0 bBits (size (bits t))) -> resM: lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_almost_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM % bn_v h0 n == LE.pow k1 (bn_v h0 aM) (bn_v h0 b)))
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Hacl.Bignum.Definitions.bn_v", "Lib.Exponentiation.Definition.pow", "Lib.NatMod.nat_mod", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.SEC" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_almost_mont_concrete_ops (t:limb_t) (k:AM.almost_mont t) (n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu; BE.lone = bn_almost_mont_one k n mu; BE.lmul = bn_almost_mont_mul k n mu; BE.lsqr = bn_almost_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_almost_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract
false
false
Hacl.Bignum.AlmostMontExponentiation.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 bn_exp_almost_mont_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
[]
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
{ "end_col": 68, "end_line": 214, "start_col": 4, "start_line": 198 }
Prims.Tot
val mk_to_nat_mont_ll_comm_monoid (t: limb_t) (len: BN.meta_len t) (n: BD.lbignum t (v len)) (mu: limb t {SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; }
val mk_to_nat_mont_ll_comm_monoid (t: limb_t) (len: BN.meta_len t) (n: BD.lbignum t (v len)) (mu: limb t {SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) let mk_to_nat_mont_ll_comm_monoid (t: limb_t) (len: BN.meta_len t) (n: BD.lbignum t (v len)) (mu: limb t {SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) =
false
null
false
{ BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n }
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Hacl.Impl.Exponentiation.Definitions.Mkto_comm_monoid", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.AlmostMontExponentiation.a_spec", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.IntTypes.SEC", "Hacl.Bignum.AlmostMontExponentiation.linv_ctx", "Hacl.Bignum.AlmostMontExponentiation.linv", "Hacl.Bignum.AlmostMontExponentiation.refl", "Hacl.Impl.Exponentiation.Definitions.to_comm_monoid" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) =
false
false
Hacl.Bignum.AlmostMontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mk_to_nat_mont_ll_comm_monoid (t: limb_t) (len: BN.meta_len t) (n: BD.lbignum t (v len)) (mu: limb t {SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len)
[]
Hacl.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> n: Hacl.Spec.Bignum.Definitions.lbignum t (Lib.IntTypes.v len) -> mu: Hacl.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu} -> Hacl.Impl.Exponentiation.Definitions.to_comm_monoid t len (len +! len)
{ "end_col": 19, "end_line": 68, "start_col": 2, "start_line": 64 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_almost_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n
let bn_exp_almost_mont_pre (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (mu: limb t) (r2 aM: BD.lbignum t len) (bBits: size_nat) (b: BD.lbignum t (BD.blocks0 bBits (bits t))) =
false
null
false
SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 ((2 * bits t) * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.blocks0", "Lib.IntTypes.bits", "Prims.l_and", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Prims.eq2", "Prims.int", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.op_Modulus", "Prims.pow2", "FStar.Mul.op_Star", "Prims.b2t", "Prims.op_LessThan", "Prims.logical" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_almost_mont_concrete_ops (t:limb_t) (k:AM.almost_mont t) (n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu; BE.lone = bn_almost_mont_one k n mu; BE.lmul = bn_almost_mont_mul k n mu; BE.lsqr = bn_almost_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_almost_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t)))
false
false
Hacl.Bignum.AlmostMontExponentiation.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 bn_exp_almost_mont_pre : n: Hacl.Spec.Bignum.Definitions.lbignum t len -> mu: Hacl.Bignum.Definitions.limb t -> r2: Hacl.Spec.Bignum.Definitions.lbignum t len -> aM: Hacl.Spec.Bignum.Definitions.lbignum t len -> bBits: Lib.IntTypes.size_nat -> b: Hacl.Spec.Bignum.Definitions.lbignum t (Hacl.Spec.Bignum.Definitions.blocks0 bBits (Lib.IntTypes.bits t)) -> Prims.logical
[]
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_pre
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> mu: Hacl.Bignum.Definitions.limb t -> r2: Hacl.Spec.Bignum.Definitions.lbignum t len -> aM: Hacl.Spec.Bignum.Definitions.lbignum t len -> bBits: Lib.IntTypes.size_nat -> b: Hacl.Spec.Bignum.Definitions.lbignum t (Hacl.Spec.Bignum.Definitions.blocks0 bBits (Lib.IntTypes.bits t)) -> Prims.logical
{ "end_col": 25, "end_line": 193, "start_col": 3, "start_line": 190 }
Prims.Tot
val linv_ctx (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (ctx: BD.lbignum t (len + len)) : Type0
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n
val linv_ctx (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (ctx: BD.lbignum t (len + len)) : Type0 let linv_ctx (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (ctx: BD.lbignum t (len + len)) : Type0 =
false
null
false
let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 ((2 * bits t) * len) % BD.bn_v n
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.op_Addition", "Prims.l_and", "Prims.eq2", "Lib.Sequence.lseq", "Hacl.Spec.Bignum.Definitions.limb", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.pow2", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.l_Forall", "Prims.nat", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.sub" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n
false
false
Hacl.Bignum.AlmostMontExponentiation.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 linv_ctx (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (ctx: BD.lbignum t (len + len)) : Type0
[]
Hacl.Bignum.AlmostMontExponentiation.linv_ctx
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> ctx: Hacl.Spec.Bignum.Definitions.lbignum t (len + len) -> Type0
{ "end_col": 71, "end_line": 53, "start_col": 105, "start_line": 49 }
Prims.Tot
val bn_exp_almost_mont_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_almost_mont_vartime #t k n mu r2 aM bBits b resM = if bBits <. size ME.bn_exp_mont_vartime_threshold then bn_exp_almost_mont_bm_vartime k n mu r2 aM bBits b resM else bn_exp_almost_mont_fw_vartime k 4ul n mu r2 aM bBits b resM
val bn_exp_almost_mont_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_vartime #t k n mu r2 aM bBits b resM =
false
null
false
if bBits <. size ME.bn_exp_mont_vartime_threshold then bn_exp_almost_mont_bm_vartime k n mu r2 aM bBits b resM else bn_exp_almost_mont_fw_vartime k 4ul n mu r2 aM bBits b resM
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.AlmostMontgomery.almost_mont", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__bn", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.IntTypes.op_Less_Dot", "Lib.IntTypes.U32", "Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_vartime_threshold", "Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_vartime", "Prims.unit", "Prims.bool", "Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_fw_vartime", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_almost_mont_concrete_ops (t:limb_t) (k:AM.almost_mont t) (n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu; BE.lone = bn_almost_mont_one k n mu; BE.lmul = bn_almost_mont_mul k n mu; BE.lsqr = bn_almost_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_almost_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_almost_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_almost_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM % bn_v h0 n == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_bm_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BD.bn_eval_bound (as_seq h0 aM) (v len); BE.lexp_rl_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_bm_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_bm_consttime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_fw_vartime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_fw_vartime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b) (v l); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_fw_consttime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_fw_consttime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_consttime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b) (v l); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () /////////////////////////////////////////////// // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
false
false
Hacl.Bignum.AlmostMontExponentiation.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 bn_exp_almost_mont_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[]
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_vartime
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t (Mkbn?.len (Mkalmost_mont?.bn k))
{ "end_col": 63, "end_line": 309, "start_col": 2, "start_line": 306 }
Prims.Tot
val bn_exp_almost_mont_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_almost_mont_consttime #t k n mu r2 aM bBits b resM = if bBits <. size ME.bn_exp_mont_consttime_threshold then bn_exp_almost_mont_bm_consttime k n mu r2 aM bBits b resM else bn_exp_almost_mont_fw_consttime k 4ul n mu r2 aM bBits b resM
val bn_exp_almost_mont_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_consttime #t k n mu r2 aM bBits b resM =
false
null
false
if bBits <. size ME.bn_exp_mont_consttime_threshold then bn_exp_almost_mont_bm_consttime k n mu r2 aM bBits b resM else bn_exp_almost_mont_fw_consttime k 4ul n mu r2 aM bBits b resM
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.AlmostMontgomery.almost_mont", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__bn", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.IntTypes.op_Less_Dot", "Lib.IntTypes.U32", "Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_consttime_threshold", "Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_consttime", "Prims.unit", "Prims.bool", "Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_fw_consttime", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_almost_mont_concrete_ops (t:limb_t) (k:AM.almost_mont t) (n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu; BE.lone = bn_almost_mont_one k n mu; BE.lmul = bn_almost_mont_mul k n mu; BE.lsqr = bn_almost_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_almost_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_almost_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_almost_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM % bn_v h0 n == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_bm_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BD.bn_eval_bound (as_seq h0 aM) (v len); BE.lexp_rl_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_bm_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_bm_consttime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_fw_vartime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_fw_vartime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b) (v l); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_fw_consttime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_fw_consttime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_consttime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b) (v l); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () /////////////////////////////////////////////// // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_vartime #t k n mu r2 aM bBits b resM = if bBits <. size ME.bn_exp_mont_vartime_threshold then bn_exp_almost_mont_bm_vartime k n mu r2 aM bBits b resM else bn_exp_almost_mont_fw_vartime k 4ul n mu r2 aM bBits b resM // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
false
false
Hacl.Bignum.AlmostMontExponentiation.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 bn_exp_almost_mont_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[]
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_consttime
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t (Mkbn?.len (Mkalmost_mont?.bn k))
{ "end_col": 65, "end_line": 319, "start_col": 2, "start_line": 316 }
Prims.Tot
val mk_bn_almost_mont_concrete_ops (t: limb_t) (k: AM.almost_mont t) (n: Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu: limb t {SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_bn_almost_mont_concrete_ops (t:limb_t) (k:AM.almost_mont t) (n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu; BE.lone = bn_almost_mont_one k n mu; BE.lmul = bn_almost_mont_mul k n mu; BE.lsqr = bn_almost_mont_sqr k n mu; }
val mk_bn_almost_mont_concrete_ops (t: limb_t) (k: AM.almost_mont t) (n: Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu: limb t {SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) let mk_bn_almost_mont_concrete_ops (t: limb_t) (k: AM.almost_mont t) (n: Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu: limb t {SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) =
false
null
false
{ BE.to = mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu; BE.lone = bn_almost_mont_one k n mu; BE.lmul = bn_almost_mont_mul k n mu; BE.lsqr = bn_almost_mont_sqr k n mu }
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.AlmostMontgomery.almost_mont", "FStar.Ghost.erased", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__bn", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "FStar.Ghost.reveal", "Hacl.Impl.Exponentiation.Definitions.Mkconcrete_ops", "Lib.IntTypes.op_Plus_Bang", "FStar.Ghost.hide", "Hacl.Impl.Exponentiation.Definitions.to_comm_monoid", "Hacl.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid", "Hacl.Bignum.AlmostMontExponentiation.bn_almost_mont_one", "Hacl.Bignum.AlmostMontExponentiation.bn_almost_mont_mul", "Hacl.Bignum.AlmostMontExponentiation.bn_almost_mont_sqr", "Hacl.Impl.Exponentiation.Definitions.concrete_ops" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_almost_mont_concrete_ops (t:limb_t) (k:AM.almost_mont t) (n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) =
false
false
Hacl.Bignum.AlmostMontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mk_bn_almost_mont_concrete_ops (t: limb_t) (k: AM.almost_mont t) (n: Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu: limb t {SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len)
[]
Hacl.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> n: FStar.Ghost.erased (Hacl.Spec.Bignum.Definitions.lbignum t (Lib.IntTypes.v (Mkbn?.len (Mkalmost_mont?.bn k)))) -> mu: Hacl.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre (FStar.Ghost.reveal n) mu} -> Hacl.Impl.Exponentiation.Definitions.concrete_ops t (Mkbn?.len (Mkalmost_mont?.bn k)) (Mkbn?.len (Mkalmost_mont?.bn k) +! Mkbn?.len (Mkalmost_mont?.bn k))
{ "end_col": 38, "end_line": 145, "start_col": 2, "start_line": 142 }
Prims.Tot
val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_almost_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM
val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_sqr #t k n mu ctx aM resM =
false
null
false
let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.AlmostMontgomery.almost_mont", "FStar.Ghost.erased", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__bn", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "FStar.Ghost.reveal", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__sqr", "Prims.unit", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Hacl.Spec.AlmostMontgomery.Lemmas.almost_mont_mul_is_mont_mul_lemma", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_mul_lemma", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_sqr_lemma", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu)
false
false
Hacl.Bignum.AlmostMontExponentiation.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 bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu)
[]
Hacl.Bignum.AlmostMontExponentiation.bn_almost_mont_sqr
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> n: FStar.Ghost.erased (Hacl.Spec.Bignum.Definitions.lbignum t (Lib.IntTypes.v (Mkbn?.len (Mkalmost_mont?.bn k)))) -> mu: Hacl.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre (FStar.Ghost.reveal n) mu} -> Hacl.Impl.Exponentiation.Definitions.lsqr_st t (Mkbn?.len (Mkalmost_mont?.bn k)) (Mkbn?.len (Mkalmost_mont?.bn k) +! Mkbn?.len (Mkalmost_mont?.bn k)) (Hacl.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid t (Mkbn?.len (Mkalmost_mont?.bn k)) (FStar.Ghost.reveal n) mu)
{ "end_col": 27, "end_line": 131, "start_col": 46, "start_line": 125 }
Prims.Tot
val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM
val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM =
false
null
false
let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.AlmostMontgomery.almost_mont", "FStar.Ghost.erased", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__bn", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "FStar.Ghost.reveal", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__mul", "Prims.unit", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Hacl.Spec.AlmostMontgomery.Lemmas.almost_mont_mul_is_mont_mul_lemma", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_mul_lemma", "Lib.Buffer.as_seq", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu)
false
false
Hacl.Bignum.AlmostMontExponentiation.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 bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu)
[]
Hacl.Bignum.AlmostMontExponentiation.bn_almost_mont_mul
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> n: FStar.Ghost.erased (Hacl.Spec.Bignum.Definitions.lbignum t (Lib.IntTypes.v (Mkbn?.len (Mkalmost_mont?.bn k)))) -> mu: Hacl.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre (FStar.Ghost.reveal n) mu} -> Hacl.Impl.Exponentiation.Definitions.lmul_st t (Mkbn?.len (Mkalmost_mont?.bn k)) (Mkbn?.len (Mkalmost_mont?.bn k) +! Mkbn?.len (Mkalmost_mont?.bn k)) (Hacl.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid t (Mkbn?.len (Mkalmost_mont?.bn k)) (FStar.Ghost.reveal n) mu)
{ "end_col": 30, "end_line": 113, "start_col": 49, "start_line": 108 }
FStar.HyperStack.ST.Stack
val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx))
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2)
val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx =
true
null
false
let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2)
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims._assert", "Prims.eq2", "Lib.Sequence.lseq", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.v", "Lib.Sequence.sub", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims.unit", "Lib.Sequence.eq_intro", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.update_sub", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_almost_mont_concrete_ops (t:limb_t) (k:AM.almost_mont t) (n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu; BE.lone = bn_almost_mont_one k n mu; BE.lmul = bn_almost_mont_mul k n mu; BE.lsqr = bn_almost_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx))
false
false
Hacl.Bignum.AlmostMontExponentiation.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx))
[]
Hacl.Bignum.AlmostMontExponentiation.mk_ctx
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len t -> n: Hacl.Bignum.Definitions.lbignum t len -> r2: Hacl.Bignum.Definitions.lbignum t len -> ctx: Hacl.Bignum.Definitions.lbignum t (len +! len) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 67, "end_line": 176, "start_col": 28, "start_line": 165 }
Prims.Tot
val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu))
val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM =
false
null
false
[@@ inline_let ]let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu))
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.AlmostMontgomery.almost_mont", "FStar.Ghost.erased", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__bn", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "FStar.Ghost.reveal", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Plus_Bang", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Spec.Exponentiation.Lemmas.mont_one_ll", "Lib.IntTypes.bits", "Prims.unit", "FStar.Math.Lemmas.small_mod", "Hacl.Bignum.AlmostMontExponentiation.linv", "Hacl.Spec.Bignum.Definitions.bn_eval_bound", "Prims.b2t", "Prims.op_LessThan", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_one", "Hacl.Spec.Bignum.Montgomery.bn_mont_one_lemma", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Bignum.Montgomery.bn_mont_one", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__from", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Lib.Exponentiation.Definition.comm_monoid", "Lib.NatMod.nat_mod", "FStar.Ghost.hide", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Hacl.Bignum.meta_len" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu)
false
false
Hacl.Bignum.AlmostMontExponentiation.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 bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu)
[]
Hacl.Bignum.AlmostMontExponentiation.bn_almost_mont_one
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> n: FStar.Ghost.erased (Hacl.Spec.Bignum.Definitions.lbignum t (Lib.IntTypes.v (Mkbn?.len (Mkalmost_mont?.bn k)))) -> mu: Hacl.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre (FStar.Ghost.reveal n) mu} -> Hacl.Impl.Exponentiation.Definitions.lone_st t (Mkbn?.len (Mkalmost_mont?.bn k)) (Mkbn?.len (Mkalmost_mont?.bn k) +! Mkbn?.len (Mkalmost_mont?.bn k)) (Hacl.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid t (Mkbn?.len (Mkalmost_mont?.bn k)) (FStar.Ghost.reveal n) mu)
{ "end_col": 54, "end_line": 96, "start_col": 2, "start_line": 82 }
Prims.Tot
val bn_exp_almost_mont_fw_vartime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_almost_mont_fw_vartime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b) (v l); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame ()
val bn_exp_almost_mont_fw_vartime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_fw_vartime #t k l n mu r2 aM bBits b resM =
false
null
false
push_frame (); let h0 = ST.get () in [@@ inline_let ]let len = k.AM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b) (v l); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame ()
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.AlmostMontgomery.almost_mont", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.bits", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Prims.pow2", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__bn", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_mod_base", "Hacl.Bignum.Definitions.bn_v", "Lib.IntTypes.SEC", "Lib.Exponentiation.exp_fw_lemma", "Lib.NatMod.nat_mod", "FStar.Ghost.reveal", "Lib.Exponentiation.Definition.comm_monoid", "Prims.op_Modulus", "Hacl.Impl.Exponentiation.lexp_fw_vartime", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops", "FStar.Ghost.hide", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.AlmostMontExponentiation.mk_ctx", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.add", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.Buffer.lbuffer", "FStar.Ghost.erased", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_Subtraction", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks0", "Hacl.Bignum.meta_len", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_almost_mont_concrete_ops (t:limb_t) (k:AM.almost_mont t) (n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu; BE.lone = bn_almost_mont_one k n mu; BE.lmul = bn_almost_mont_mul k n mu; BE.lsqr = bn_almost_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_almost_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_almost_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_almost_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM % bn_v h0 n == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_bm_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BD.bn_eval_bound (as_seq h0 aM) (v len); BE.lexp_rl_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_bm_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_bm_consttime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_fw_vartime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len
false
false
Hacl.Bignum.AlmostMontExponentiation.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 bn_exp_almost_mont_fw_vartime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[]
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_fw_vartime
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> l: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v l /\ Lib.IntTypes.v l < Lib.IntTypes.bits Lib.IntTypes.U32 /\ Prims.pow2 (Lib.IntTypes.v l) * Lib.IntTypes.v (Mkbn?.len (Mkalmost_mont?.bn k)) <= Lib.IntTypes.max_size_t } -> Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t (Mkbn?.len (Mkalmost_mont?.bn k))
{ "end_col": 14, "end_line": 275, "start_col": 2, "start_line": 264 }
Prims.Tot
val bn_exp_almost_mont_fw_consttime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_almost_mont_fw_consttime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_consttime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b) (v l); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame ()
val bn_exp_almost_mont_fw_consttime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_fw_consttime #t k l n mu r2 aM bBits b resM =
false
null
false
push_frame (); let h0 = ST.get () in [@@ inline_let ]let len = k.AM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_consttime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b) (v l); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame ()
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.AlmostMontgomery.almost_mont", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.bits", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Prims.pow2", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__bn", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_mod_base", "Hacl.Bignum.Definitions.bn_v", "Lib.IntTypes.SEC", "Lib.Exponentiation.exp_fw_lemma", "Lib.NatMod.nat_mod", "FStar.Ghost.reveal", "Lib.Exponentiation.Definition.comm_monoid", "Prims.op_Modulus", "Hacl.Impl.Exponentiation.lexp_fw_consttime", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops", "FStar.Ghost.hide", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.AlmostMontExponentiation.mk_ctx", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.add", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.Buffer.lbuffer", "FStar.Ghost.erased", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_Subtraction", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks0", "Hacl.Bignum.meta_len", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_almost_mont_concrete_ops (t:limb_t) (k:AM.almost_mont t) (n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu; BE.lone = bn_almost_mont_one k n mu; BE.lmul = bn_almost_mont_mul k n mu; BE.lsqr = bn_almost_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_almost_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_almost_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_almost_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM % bn_v h0 n == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_bm_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BD.bn_eval_bound (as_seq h0 aM) (v len); BE.lexp_rl_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_bm_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_bm_consttime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_fw_vartime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_fw_vartime #t k l n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_fw_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) l ctx aM bLen bBits b resM; LE.exp_fw_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b) (v l); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_fw_consttime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len
false
false
Hacl.Bignum.AlmostMontExponentiation.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 bn_exp_almost_mont_fw_consttime: #t:limb_t -> k:AM.almost_mont t -> l:size_t{0 < v l /\ v l < bits U32 /\ pow2 (v l) * v k.AM.bn.BN.len <= max_size_t} -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[]
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_fw_consttime
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> l: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v l /\ Lib.IntTypes.v l < Lib.IntTypes.bits Lib.IntTypes.U32 /\ Prims.pow2 (Lib.IntTypes.v l) * Lib.IntTypes.v (Mkbn?.len (Mkalmost_mont?.bn k)) <= Lib.IntTypes.max_size_t } -> Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t (Mkbn?.len (Mkalmost_mont?.bn k))
{ "end_col": 14, "end_line": 298, "start_col": 2, "start_line": 287 }
Prims.Tot
val bn_exp_almost_mont_bm_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_almost_mont_bm_consttime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame ()
val bn_exp_almost_mont_bm_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_bm_consttime #t k n mu r2 aM bBits b resM =
false
null
false
push_frame (); let h0 = ST.get () in [@@ inline_let ]let len = k.AM.bn.BN.len in [@@ inline_let ]let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BE.lexp_mont_ladder_swap_consttime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_mont_ladder_swap_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); LE.exp_mont_ladder_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame ()
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.AlmostMontgomery.almost_mont", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__bn", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_mod_base", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.bn_v", "Lib.IntTypes.SEC", "Lib.Exponentiation.exp_mont_ladder_lemma", "Lib.NatMod.nat_mod", "FStar.Ghost.reveal", "Lib.Exponentiation.Definition.comm_monoid", "Prims.op_Modulus", "Lib.Exponentiation.exp_mont_ladder_swap_lemma", "Hacl.Impl.Exponentiation.lexp_mont_ladder_swap_consttime", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops", "FStar.Ghost.hide", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.AlmostMontExponentiation.mk_ctx", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.add", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.Buffer.lbuffer", "FStar.Ghost.erased", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks0", "Hacl.Bignum.meta_len", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_almost_mont_concrete_ops (t:limb_t) (k:AM.almost_mont t) (n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu; BE.lone = bn_almost_mont_one k n mu; BE.lmul = bn_almost_mont_mul k n mu; BE.lsqr = bn_almost_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_almost_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_almost_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_almost_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM % bn_v h0 n == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_bm_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BD.bn_eval_bound (as_seq h0 aM) (v len); BE.lexp_rl_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame () // This function is constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_bm_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
false
false
Hacl.Bignum.AlmostMontExponentiation.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 bn_exp_almost_mont_bm_consttime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[]
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_consttime
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t (Mkbn?.len (Mkalmost_mont?.bn k))
{ "end_col": 14, "end_line": 252, "start_col": 2, "start_line": 240 }
Prims.Tot
val bn_exp_almost_mont_bm_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontExponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "A" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "SA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "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": "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.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_exp_almost_mont_bm_vartime #t k n mu r2 aM bBits b resM = push_frame (); let h0 = ST.get () in [@inline_let] let len = k.AM.bn.BN.len in [@inline_let] let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BD.bn_eval_bound (as_seq h0 aM) (v len); BE.lexp_rl_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame ()
val bn_exp_almost_mont_bm_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len let bn_exp_almost_mont_bm_vartime #t k n mu r2 aM bBits b resM =
false
null
false
push_frame (); let h0 = ST.get () in [@@ inline_let ]let len = k.AM.bn.BN.len in [@@ inline_let ]let bLen = blocks0 bBits (size (bits t)) in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu)) in let ctx = create (len +! len) (uint #t #SEC 0) in mk_ctx #t len n r2 ctx; BD.bn_eval_bound (as_seq h0 aM) (v len); BE.lexp_rl_vartime len (len +! len) (mk_bn_almost_mont_concrete_ops t k (as_seq h0 n) mu) ctx aM bLen bBits b resM; LE.exp_rl_lemma k1 (bn_v h0 aM % bn_v h0 n) (v bBits) (bn_v h0 b); E.pow_nat_mont_ll_mod_base (bits t) (v len) (bn_v h0 n) (v mu) (bn_v h0 aM) (bn_v h0 b); pop_frame ()
{ "checked_file": "Hacl.Bignum.AlmostMontExponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.AlmostMontExponentiation.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.AlmostMontgomery.almost_mont", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__bn", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_mod_base", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.bn_v", "Lib.IntTypes.SEC", "Lib.Exponentiation.exp_rl_lemma", "Lib.NatMod.nat_mod", "FStar.Ghost.reveal", "Lib.Exponentiation.Definition.comm_monoid", "Prims.op_Modulus", "Hacl.Impl.Exponentiation.lexp_rl_vartime", "Lib.IntTypes.op_Plus_Bang", "Hacl.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops", "FStar.Ghost.hide", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Spec.Bignum.Definitions.bn_eval_bound", "Hacl.Bignum.AlmostMontExponentiation.mk_ctx", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.add", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.Buffer.lbuffer", "FStar.Ghost.erased", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks0", "Hacl.Bignum.meta_len", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.AlmostMontExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BD = Hacl.Spec.Bignum.Definitions module SN = Hacl.Spec.Bignum module SM = Hacl.Spec.Bignum.Montgomery module SA = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module LE = Lib.Exponentiation module BE = Hacl.Impl.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module A = Hacl.Spec.AlmostMontgomery.Lemmas module M = Hacl.Spec.Montgomery.Lemmas module ME = Hacl.Spec.Bignum.MontExponentiation module S = Hacl.Spec.Bignum.AlmostMontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let a_spec (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) = Lib.NatMod.nat_mod (BD.bn_v n) inline_for_extraction noextract let linv (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len) inline_for_extraction noextract let refl (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len{0 < BD.bn_v n}) (a:BD.lbignum t len{linv n a}) : a_spec n = BD.bn_v a % BD.bn_v n inline_for_extraction noextract let linv_ctx (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (ctx:BD.lbignum t (len + len)) : Type0 = let ctx_n = LSeq.sub ctx 0 len in let ctx_r2 = LSeq.sub ctx len len in ctx_n == n /\ 0 < BD.bn_v n /\ BD.bn_v ctx_r2 = pow2 (2 * bits t * len) % BD.bn_v n inline_for_extraction noextract let mk_to_nat_mont_ll_comm_monoid (t:limb_t) (len:BN.meta_len t) (n:BD.lbignum t (v len)) (mu:limb t{SM.bn_mont_pre n mu}) : BE.to_comm_monoid t len (len +! len) = { BE.a_spec = a_spec n; BE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu); BE.linv_ctx = linv_ctx n; BE.linv = linv n; BE.refl = refl n; } inline_for_extraction noextract val bn_almost_mont_one: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lone_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_one #t k n mu ctx oneM = [@inline_let] let len = k.AM.bn.BN.len in let k1 = Ghost.hide (E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (BD.bn_v n) (v mu)) in let ctx_n = sub ctx 0ul len in let ctx_r2 = sub ctx len len in let h0 = ST.get () in BM.bn_mont_one len k.AM.from ctx_n mu ctx_r2 oneM; let h1 = ST.get () in SM.bn_mont_one_lemma n mu (as_seq h0 ctx_r2); assert (BD.bn_v (as_seq h1 oneM) == M.mont_one (bits t) (v len) (BD.bn_v n) (v mu)); assert (BD.bn_v (as_seq h1 oneM) < BD.bn_v n); BD.bn_eval_bound n (v len); assert (linv n (as_seq h1 oneM)); Math.Lemmas.small_mod (BD.bn_v (as_seq h1 oneM)) (BD.bn_v n); assert (BD.bn_v (as_seq h1 oneM) % BD.bn_v n == E.mont_one_ll (bits t) (v len) (BD.bn_v n) (v mu)) inline_for_extraction noextract val bn_almost_mont_mul: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lmul_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_mul #t k n mu ctx aM bM resM = let h0 = ST.get () in SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 bM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 bM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.mul ctx_n mu aM bM resM inline_for_extraction noextract val bn_almost_mont_sqr: #t:limb_t -> k:AM.almost_mont t -> n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len)) -> mu:limb t{SM.bn_mont_pre n mu} -> BE.lsqr_st t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) (mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu) let bn_almost_mont_sqr #t k n mu ctx aM resM = let h0 = ST.get () in SA.bn_almost_mont_sqr_lemma n mu (as_seq h0 aM); SA.bn_almost_mont_mul_lemma n mu (as_seq h0 aM) (as_seq h0 aM); A.almost_mont_mul_is_mont_mul_lemma (bits t) (v k.AM.bn.BN.len) (BD.bn_v n) (v mu) (bn_v h0 aM) (bn_v h0 aM); let ctx_n = sub ctx 0ul k.AM.bn.BN.len in k.AM.sqr ctx_n mu aM resM inline_for_extraction noextract let mk_bn_almost_mont_concrete_ops (t:limb_t) (k:AM.almost_mont t) (n:Ghost.erased (BD.lbignum t (v k.AM.bn.BN.len))) (mu:limb t{SM.bn_mont_pre n mu}) : BE.concrete_ops t k.AM.bn.BN.len (k.AM.bn.BN.len +! k.AM.bn.BN.len) = { BE.to = mk_to_nat_mont_ll_comm_monoid t k.AM.bn.BN.len n mu; BE.lone = bn_almost_mont_one k n mu; BE.lmul = bn_almost_mont_mul k n mu; BE.lsqr = bn_almost_mont_sqr k n mu; } /////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val mk_ctx: #t:limb_t -> len:BN.meta_len t -> n:lbignum t len -> r2:lbignum t len -> ctx:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h r2 /\ live h ctx /\ disjoint n ctx /\ disjoint r2 ctx /\ 0 < bn_v h n /\ bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ linv_ctx (as_seq h0 n) (as_seq h1 ctx)) let mk_ctx #t len n r2 ctx = let h0 = ST.get () in update_sub ctx 0ul len n; let h1 = ST.get () in assert (LSeq.sub (as_seq h1 ctx) 0 (v len) == as_seq h0 n); update_sub ctx len len r2; let h2 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h2 ctx) 0 (v len)) (LSeq.sub (as_seq h1 ctx) 0 (v len)); assert (LSeq.sub (as_seq h2 ctx) 0 (v len) == as_seq h0 n); assert (LSeq.sub (as_seq h2 ctx) (v len) (v len) == as_seq h0 r2) noextract let bn_exp_almost_mont_pre (#t:limb_t) (#len:SN.bn_len t) (n:BD.lbignum t len) (mu:limb t) (r2:BD.lbignum t len) (aM:BD.lbignum t len) (bBits:size_nat) (b:BD.lbignum t (BD.blocks0 bBits (bits t))) = SM.bn_mont_pre n mu /\ BD.bn_v r2 == pow2 (2 * bits t * len) % BD.bn_v n /\ BD.bn_v b < pow2 bBits /\ BD.bn_v aM < BD.bn_v n inline_for_extraction noextract let bn_exp_almost_mont_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> mu:limb t -> r2:lbignum t len -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> live h n /\ live h aM /\ live h b /\ live h resM /\ live h r2 /\ disjoint resM aM /\ disjoint resM b /\ disjoint resM n /\ disjoint n aM /\ disjoint resM r2 /\ disjoint aM r2 /\ disjoint n r2 /\ disjoint aM b /\ bn_exp_almost_mont_pre (as_seq h n) mu (as_seq h r2) (as_seq h aM) (v bBits) (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc aM |+| loc resM) h0 h1 /\ (let k1 = E.mk_nat_mont_ll_comm_monoid (bits t) (v len) (bn_v h0 n) (v mu) in bn_v h1 resM % bn_v h0 n == LE.pow k1 (bn_v h0 aM) (bn_v h0 b))) // This function is *NOT* constant-time on the exponent b. inline_for_extraction noextract val bn_exp_almost_mont_bm_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
false
false
Hacl.Bignum.AlmostMontExponentiation.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 bn_exp_almost_mont_bm_vartime: #t:limb_t -> k:AM.almost_mont t -> bn_exp_almost_mont_st t k.AM.bn.BN.len
[]
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_vartime
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t (Mkbn?.len (Mkalmost_mont?.bn k))
{ "end_col": 14, "end_line": 233, "start_col": 2, "start_line": 221 }
Prims.Tot
[ { "abbrev": false, "full_module": "LowParse.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Tot", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse_u8 = tot_parse_u8
let parse_u8 =
false
null
false
tot_parse_u8
{ "checked_file": "LowParse.Tot.Int.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Tot.Base.fst.checked", "LowParse.Spec.Int.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Tot.Int.fst" }
[ "total" ]
[ "LowParse.Spec.Int.tot_parse_u8" ]
[]
module LowParse.Tot.Int include LowParse.Spec.Int include LowParse.Tot.Base
false
true
LowParse.Tot.Int.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse_u8 : LowParse.Spec.Base.tot_parser LowParse.Spec.Int.parse_u8_kind FStar.UInt8.t
[]
LowParse.Tot.Int.parse_u8
{ "file_name": "src/lowparse/LowParse.Tot.Int.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Spec.Base.tot_parser LowParse.Spec.Int.parse_u8_kind FStar.UInt8.t
{ "end_col": 27, "end_line": 6, "start_col": 15, "start_line": 6 }
Prims.Tot
val serialize_u8 : serializer parse_u8
[ { "abbrev": false, "full_module": "LowParse.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Tot", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize_u8 = serialize_ext _ serialize_u8 _
val serialize_u8 : serializer parse_u8 let serialize_u8 =
false
null
false
serialize_ext _ serialize_u8 _
{ "checked_file": "LowParse.Tot.Int.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Tot.Base.fst.checked", "LowParse.Spec.Int.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Tot.Int.fst" }
[ "total" ]
[ "LowParse.Spec.Base.serialize_ext", "LowParse.Spec.Int.parse_u8_kind", "FStar.UInt8.t", "LowParse.Spec.Int.parse_u8", "LowParse.Spec.Int.serialize_u8", "LowParse.Tot.Int.parse_u8" ]
[]
module LowParse.Tot.Int include LowParse.Spec.Int include LowParse.Tot.Base inline_for_extraction let parse_u8 = tot_parse_u8 val serialize_u8 : serializer parse_u8
false
true
LowParse.Tot.Int.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize_u8 : serializer parse_u8
[]
LowParse.Tot.Int.serialize_u8
{ "file_name": "src/lowparse/LowParse.Tot.Int.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Tot.Base.serializer LowParse.Tot.Int.parse_u8
{ "end_col": 32, "end_line": 10, "start_col": 2, "start_line": 10 }
Prims.Pure
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let op_Greater_Equals_Hat = gte
let op_Greater_Equals_Hat =
false
null
false
gte
{ "checked_file": "FStar.PtrdiffT.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int16.fsti.checked" ], "interface_file": false, "source_file": "FStar.PtrdiffT.fsti" }
[]
[ "FStar.PtrdiffT.gte" ]
[]
module FStar.PtrdiffT module I16 = FStar.Int16 module US = FStar.SizeT val t : eqtype val fits (x: int) : Tot prop val fits_lt (x y: int) : Lemma (requires (abs x < abs y /\ fits y)) (ensures (fits x)) [SMTPat (fits x); SMTPat (fits y)] [@@noextract_to "krml"] val v (x: t) : Pure int (requires True) (ensures (fun y -> fits y)) [@@noextract_to "krml"] val int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) /// v and int_to_t are inverses val ptrdiff_v_inj (x: t) : Lemma (ensures int_to_t (v x) == x) [SMTPat (v x)] val ptrdiff_int_to_t_inj (x: int) : Lemma (requires fits x) (ensures v (int_to_t x) == x) [SMTPat (int_to_t x)] /// According to the C standard, "the bit width of ptrdiff_t is not less than 17 since c99, /// 16 since C23" /// (https://en.cppreference.com/w/c/types/ptrdiff_t) /// We therefore only offer a function to create a ptrdiff_t when we are sure it fits noextract inline_for_extraction val mk (x: I16.t) : Pure t (requires True) (ensures (fun y -> v y == I16.v x)) noextract inline_for_extraction let zero : (zero_ptrdiff: t { v zero_ptrdiff == 0 }) = mk 0s (** Cast from ptrdiff_to to size_t. We restrict the cast to positive integers to avoid reasoning about modular arithmetic *) val ptrdifft_to_sizet (x:t{v x >= 0}) : Pure US.t (requires True) (ensures fun c -> v x == US.v c) val add (x y: t) : Pure t (requires (fits (v x + v y))) (ensures (fun z -> v z == v x + v y)) (** Division primitive As for rem below, we only provide division on positive signed integers, to avoid having to reason about possible overflows *) val div (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures fun c -> v a / v b == v c) (** Modulo specification, similar to FStar.Int.mod *) let mod_spec (a:int{fits a}) (b:int{fits b /\ b <> 0}) : GTot (n:int{fits n}) = let open FStar.Mul in let res = a - ((a/b) * b) in fits_lt res b; res (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b]. Note, according to the C standard, this operation is only defined if a/b is representable. To avoid requiring the precondition `fits (v a / v b)`, we instead restrict this primitive to positive integers only. *) val rem (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures (fun c -> mod_spec (v a) (v b) = v c)) (** Greater than *) val gt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x > v y))) (** Greater than or equal *) val gte (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x >= v y))) (** Less than *) val lt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x < v y))) (** Less than or equal *) val lte (x y: t) : Pure bool (requires True) (ensures (fun z -> z == (v x <= v y))) (** Infix notations *) unfold let op_Plus_Hat = add
false
false
FStar.PtrdiffT.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 op_Greater_Equals_Hat : x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
[]
FStar.PtrdiffT.op_Greater_Equals_Hat
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
{ "end_col": 38, "end_line": 112, "start_col": 35, "start_line": 112 }
Prims.Pure
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let op_Less_Hat = lt
let op_Less_Hat =
false
null
false
lt
{ "checked_file": "FStar.PtrdiffT.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int16.fsti.checked" ], "interface_file": false, "source_file": "FStar.PtrdiffT.fsti" }
[]
[ "FStar.PtrdiffT.lt" ]
[]
module FStar.PtrdiffT module I16 = FStar.Int16 module US = FStar.SizeT val t : eqtype val fits (x: int) : Tot prop val fits_lt (x y: int) : Lemma (requires (abs x < abs y /\ fits y)) (ensures (fits x)) [SMTPat (fits x); SMTPat (fits y)] [@@noextract_to "krml"] val v (x: t) : Pure int (requires True) (ensures (fun y -> fits y)) [@@noextract_to "krml"] val int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) /// v and int_to_t are inverses val ptrdiff_v_inj (x: t) : Lemma (ensures int_to_t (v x) == x) [SMTPat (v x)] val ptrdiff_int_to_t_inj (x: int) : Lemma (requires fits x) (ensures v (int_to_t x) == x) [SMTPat (int_to_t x)] /// According to the C standard, "the bit width of ptrdiff_t is not less than 17 since c99, /// 16 since C23" /// (https://en.cppreference.com/w/c/types/ptrdiff_t) /// We therefore only offer a function to create a ptrdiff_t when we are sure it fits noextract inline_for_extraction val mk (x: I16.t) : Pure t (requires True) (ensures (fun y -> v y == I16.v x)) noextract inline_for_extraction let zero : (zero_ptrdiff: t { v zero_ptrdiff == 0 }) = mk 0s (** Cast from ptrdiff_to to size_t. We restrict the cast to positive integers to avoid reasoning about modular arithmetic *) val ptrdifft_to_sizet (x:t{v x >= 0}) : Pure US.t (requires True) (ensures fun c -> v x == US.v c) val add (x y: t) : Pure t (requires (fits (v x + v y))) (ensures (fun z -> v z == v x + v y)) (** Division primitive As for rem below, we only provide division on positive signed integers, to avoid having to reason about possible overflows *) val div (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures fun c -> v a / v b == v c) (** Modulo specification, similar to FStar.Int.mod *) let mod_spec (a:int{fits a}) (b:int{fits b /\ b <> 0}) : GTot (n:int{fits n}) = let open FStar.Mul in let res = a - ((a/b) * b) in fits_lt res b; res (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b]. Note, according to the C standard, this operation is only defined if a/b is representable. To avoid requiring the precondition `fits (v a / v b)`, we instead restrict this primitive to positive integers only. *) val rem (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures (fun c -> mod_spec (v a) (v b) = v c)) (** Greater than *) val gt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x > v y))) (** Greater than or equal *) val gte (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x >= v y))) (** Less than *) val lt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x < v y))) (** Less than or equal *) val lte (x y: t) : Pure bool (requires True) (ensures (fun z -> z == (v x <= v y))) (** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Greater_Hat = gt
false
false
FStar.PtrdiffT.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 op_Less_Hat : x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
[]
FStar.PtrdiffT.op_Less_Hat
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
{ "end_col": 27, "end_line": 113, "start_col": 25, "start_line": 113 }
Prims.Pure
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let op_Greater_Hat = gt
let op_Greater_Hat =
false
null
false
gt
{ "checked_file": "FStar.PtrdiffT.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int16.fsti.checked" ], "interface_file": false, "source_file": "FStar.PtrdiffT.fsti" }
[]
[ "FStar.PtrdiffT.gt" ]
[]
module FStar.PtrdiffT module I16 = FStar.Int16 module US = FStar.SizeT val t : eqtype val fits (x: int) : Tot prop val fits_lt (x y: int) : Lemma (requires (abs x < abs y /\ fits y)) (ensures (fits x)) [SMTPat (fits x); SMTPat (fits y)] [@@noextract_to "krml"] val v (x: t) : Pure int (requires True) (ensures (fun y -> fits y)) [@@noextract_to "krml"] val int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) /// v and int_to_t are inverses val ptrdiff_v_inj (x: t) : Lemma (ensures int_to_t (v x) == x) [SMTPat (v x)] val ptrdiff_int_to_t_inj (x: int) : Lemma (requires fits x) (ensures v (int_to_t x) == x) [SMTPat (int_to_t x)] /// According to the C standard, "the bit width of ptrdiff_t is not less than 17 since c99, /// 16 since C23" /// (https://en.cppreference.com/w/c/types/ptrdiff_t) /// We therefore only offer a function to create a ptrdiff_t when we are sure it fits noextract inline_for_extraction val mk (x: I16.t) : Pure t (requires True) (ensures (fun y -> v y == I16.v x)) noextract inline_for_extraction let zero : (zero_ptrdiff: t { v zero_ptrdiff == 0 }) = mk 0s (** Cast from ptrdiff_to to size_t. We restrict the cast to positive integers to avoid reasoning about modular arithmetic *) val ptrdifft_to_sizet (x:t{v x >= 0}) : Pure US.t (requires True) (ensures fun c -> v x == US.v c) val add (x y: t) : Pure t (requires (fits (v x + v y))) (ensures (fun z -> v z == v x + v y)) (** Division primitive As for rem below, we only provide division on positive signed integers, to avoid having to reason about possible overflows *) val div (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures fun c -> v a / v b == v c) (** Modulo specification, similar to FStar.Int.mod *) let mod_spec (a:int{fits a}) (b:int{fits b /\ b <> 0}) : GTot (n:int{fits n}) = let open FStar.Mul in let res = a - ((a/b) * b) in fits_lt res b; res (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b]. Note, according to the C standard, this operation is only defined if a/b is representable. To avoid requiring the precondition `fits (v a / v b)`, we instead restrict this primitive to positive integers only. *) val rem (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures (fun c -> mod_spec (v a) (v b) = v c)) (** Greater than *) val gt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x > v y))) (** Greater than or equal *) val gte (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x >= v y))) (** Less than *) val lt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x < v y))) (** Less than or equal *) val lte (x y: t) : Pure bool (requires True) (ensures (fun z -> z == (v x <= v y))) (** Infix notations *)
false
false
FStar.PtrdiffT.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 op_Greater_Hat : x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
[]
FStar.PtrdiffT.op_Greater_Hat
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
{ "end_col": 30, "end_line": 111, "start_col": 28, "start_line": 111 }
Prims.Pure
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let op_Less_Equals_Hat = lte
let op_Less_Equals_Hat =
false
null
false
lte
{ "checked_file": "FStar.PtrdiffT.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int16.fsti.checked" ], "interface_file": false, "source_file": "FStar.PtrdiffT.fsti" }
[]
[ "FStar.PtrdiffT.lte" ]
[]
module FStar.PtrdiffT module I16 = FStar.Int16 module US = FStar.SizeT val t : eqtype val fits (x: int) : Tot prop val fits_lt (x y: int) : Lemma (requires (abs x < abs y /\ fits y)) (ensures (fits x)) [SMTPat (fits x); SMTPat (fits y)] [@@noextract_to "krml"] val v (x: t) : Pure int (requires True) (ensures (fun y -> fits y)) [@@noextract_to "krml"] val int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) /// v and int_to_t are inverses val ptrdiff_v_inj (x: t) : Lemma (ensures int_to_t (v x) == x) [SMTPat (v x)] val ptrdiff_int_to_t_inj (x: int) : Lemma (requires fits x) (ensures v (int_to_t x) == x) [SMTPat (int_to_t x)] /// According to the C standard, "the bit width of ptrdiff_t is not less than 17 since c99, /// 16 since C23" /// (https://en.cppreference.com/w/c/types/ptrdiff_t) /// We therefore only offer a function to create a ptrdiff_t when we are sure it fits noextract inline_for_extraction val mk (x: I16.t) : Pure t (requires True) (ensures (fun y -> v y == I16.v x)) noextract inline_for_extraction let zero : (zero_ptrdiff: t { v zero_ptrdiff == 0 }) = mk 0s (** Cast from ptrdiff_to to size_t. We restrict the cast to positive integers to avoid reasoning about modular arithmetic *) val ptrdifft_to_sizet (x:t{v x >= 0}) : Pure US.t (requires True) (ensures fun c -> v x == US.v c) val add (x y: t) : Pure t (requires (fits (v x + v y))) (ensures (fun z -> v z == v x + v y)) (** Division primitive As for rem below, we only provide division on positive signed integers, to avoid having to reason about possible overflows *) val div (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures fun c -> v a / v b == v c) (** Modulo specification, similar to FStar.Int.mod *) let mod_spec (a:int{fits a}) (b:int{fits b /\ b <> 0}) : GTot (n:int{fits n}) = let open FStar.Mul in let res = a - ((a/b) * b) in fits_lt res b; res (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b]. Note, according to the C standard, this operation is only defined if a/b is representable. To avoid requiring the precondition `fits (v a / v b)`, we instead restrict this primitive to positive integers only. *) val rem (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures (fun c -> mod_spec (v a) (v b) = v c)) (** Greater than *) val gt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x > v y))) (** Greater than or equal *) val gte (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x >= v y))) (** Less than *) val lt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x < v y))) (** Less than or equal *) val lte (x y: t) : Pure bool (requires True) (ensures (fun z -> z == (v x <= v y))) (** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Greater_Hat = gt unfold let op_Greater_Equals_Hat = gte
false
false
FStar.PtrdiffT.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 op_Less_Equals_Hat : x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
[]
FStar.PtrdiffT.op_Less_Equals_Hat
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
{ "end_col": 35, "end_line": 114, "start_col": 32, "start_line": 114 }
Prims.Pure
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let op_Plus_Hat = add
let op_Plus_Hat =
false
null
false
add
{ "checked_file": "FStar.PtrdiffT.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int16.fsti.checked" ], "interface_file": false, "source_file": "FStar.PtrdiffT.fsti" }
[]
[ "FStar.PtrdiffT.add" ]
[]
module FStar.PtrdiffT module I16 = FStar.Int16 module US = FStar.SizeT val t : eqtype val fits (x: int) : Tot prop val fits_lt (x y: int) : Lemma (requires (abs x < abs y /\ fits y)) (ensures (fits x)) [SMTPat (fits x); SMTPat (fits y)] [@@noextract_to "krml"] val v (x: t) : Pure int (requires True) (ensures (fun y -> fits y)) [@@noextract_to "krml"] val int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) /// v and int_to_t are inverses val ptrdiff_v_inj (x: t) : Lemma (ensures int_to_t (v x) == x) [SMTPat (v x)] val ptrdiff_int_to_t_inj (x: int) : Lemma (requires fits x) (ensures v (int_to_t x) == x) [SMTPat (int_to_t x)] /// According to the C standard, "the bit width of ptrdiff_t is not less than 17 since c99, /// 16 since C23" /// (https://en.cppreference.com/w/c/types/ptrdiff_t) /// We therefore only offer a function to create a ptrdiff_t when we are sure it fits noextract inline_for_extraction val mk (x: I16.t) : Pure t (requires True) (ensures (fun y -> v y == I16.v x)) noextract inline_for_extraction let zero : (zero_ptrdiff: t { v zero_ptrdiff == 0 }) = mk 0s (** Cast from ptrdiff_to to size_t. We restrict the cast to positive integers to avoid reasoning about modular arithmetic *) val ptrdifft_to_sizet (x:t{v x >= 0}) : Pure US.t (requires True) (ensures fun c -> v x == US.v c) val add (x y: t) : Pure t (requires (fits (v x + v y))) (ensures (fun z -> v z == v x + v y)) (** Division primitive As for rem below, we only provide division on positive signed integers, to avoid having to reason about possible overflows *) val div (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures fun c -> v a / v b == v c) (** Modulo specification, similar to FStar.Int.mod *) let mod_spec (a:int{fits a}) (b:int{fits b /\ b <> 0}) : GTot (n:int{fits n}) = let open FStar.Mul in let res = a - ((a/b) * b) in fits_lt res b; res (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b]. Note, according to the C standard, this operation is only defined if a/b is representable. To avoid requiring the precondition `fits (v a / v b)`, we instead restrict this primitive to positive integers only. *) val rem (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures (fun c -> mod_spec (v a) (v b) = v c)) (** Greater than *) val gt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x > v y))) (** Greater than or equal *) val gte (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x >= v y))) (** Less than *) val lt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x < v y))) (** Less than or equal *) val lte (x y: t) : Pure bool (requires True) (ensures (fun z -> z == (v x <= v y))) (** Infix notations *)
false
false
FStar.PtrdiffT.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 op_Plus_Hat : x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure FStar.PtrdiffT.t
[]
FStar.PtrdiffT.op_Plus_Hat
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure FStar.PtrdiffT.t
{ "end_col": 28, "end_line": 110, "start_col": 25, "start_line": 110 }
Prims.Tot
val zero:(zero_ptrdiff: t{v zero_ptrdiff == 0})
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let zero : (zero_ptrdiff: t { v zero_ptrdiff == 0 }) = mk 0s
val zero:(zero_ptrdiff: t{v zero_ptrdiff == 0}) let zero:(zero_ptrdiff: t{v zero_ptrdiff == 0}) =
false
null
false
mk 0s
{ "checked_file": "FStar.PtrdiffT.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int16.fsti.checked" ], "interface_file": false, "source_file": "FStar.PtrdiffT.fsti" }
[ "total" ]
[ "FStar.PtrdiffT.mk", "FStar.Int16.__int_to_t" ]
[]
module FStar.PtrdiffT module I16 = FStar.Int16 module US = FStar.SizeT val t : eqtype val fits (x: int) : Tot prop val fits_lt (x y: int) : Lemma (requires (abs x < abs y /\ fits y)) (ensures (fits x)) [SMTPat (fits x); SMTPat (fits y)] [@@noextract_to "krml"] val v (x: t) : Pure int (requires True) (ensures (fun y -> fits y)) [@@noextract_to "krml"] val int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) /// v and int_to_t are inverses val ptrdiff_v_inj (x: t) : Lemma (ensures int_to_t (v x) == x) [SMTPat (v x)] val ptrdiff_int_to_t_inj (x: int) : Lemma (requires fits x) (ensures v (int_to_t x) == x) [SMTPat (int_to_t x)] /// According to the C standard, "the bit width of ptrdiff_t is not less than 17 since c99, /// 16 since C23" /// (https://en.cppreference.com/w/c/types/ptrdiff_t) /// We therefore only offer a function to create a ptrdiff_t when we are sure it fits noextract inline_for_extraction val mk (x: I16.t) : Pure t (requires True) (ensures (fun y -> v y == I16.v x)) noextract inline_for_extraction
false
false
FStar.PtrdiffT.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:(zero_ptrdiff: t{v zero_ptrdiff == 0})
[]
FStar.PtrdiffT.zero
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
zero_ptrdiff: FStar.PtrdiffT.t{FStar.PtrdiffT.v zero_ptrdiff == 0}
{ "end_col": 7, "end_line": 48, "start_col": 2, "start_line": 48 }
Prims.GTot
val mod_spec (a: int{fits a}) (b: int{fits b /\ b <> 0}) : GTot (n: int{fits n})
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mod_spec (a:int{fits a}) (b:int{fits b /\ b <> 0}) : GTot (n:int{fits n}) = let open FStar.Mul in let res = a - ((a/b) * b) in fits_lt res b; res
val mod_spec (a: int{fits a}) (b: int{fits b /\ b <> 0}) : GTot (n: int{fits n}) let mod_spec (a: int{fits a}) (b: int{fits b /\ b <> 0}) : GTot (n: int{fits n}) =
false
null
false
let open FStar.Mul in let res = a - ((a / b) * b) in fits_lt res b; res
{ "checked_file": "FStar.PtrdiffT.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int16.fsti.checked" ], "interface_file": false, "source_file": "FStar.PtrdiffT.fsti" }
[ "sometrivial" ]
[ "Prims.int", "FStar.PtrdiffT.fits", "Prims.l_and", "Prims.b2t", "Prims.op_disEquality", "Prims.unit", "FStar.PtrdiffT.fits_lt", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Prims.op_Division" ]
[]
module FStar.PtrdiffT module I16 = FStar.Int16 module US = FStar.SizeT val t : eqtype val fits (x: int) : Tot prop val fits_lt (x y: int) : Lemma (requires (abs x < abs y /\ fits y)) (ensures (fits x)) [SMTPat (fits x); SMTPat (fits y)] [@@noextract_to "krml"] val v (x: t) : Pure int (requires True) (ensures (fun y -> fits y)) [@@noextract_to "krml"] val int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) /// v and int_to_t are inverses val ptrdiff_v_inj (x: t) : Lemma (ensures int_to_t (v x) == x) [SMTPat (v x)] val ptrdiff_int_to_t_inj (x: int) : Lemma (requires fits x) (ensures v (int_to_t x) == x) [SMTPat (int_to_t x)] /// According to the C standard, "the bit width of ptrdiff_t is not less than 17 since c99, /// 16 since C23" /// (https://en.cppreference.com/w/c/types/ptrdiff_t) /// We therefore only offer a function to create a ptrdiff_t when we are sure it fits noextract inline_for_extraction val mk (x: I16.t) : Pure t (requires True) (ensures (fun y -> v y == I16.v x)) noextract inline_for_extraction let zero : (zero_ptrdiff: t { v zero_ptrdiff == 0 }) = mk 0s (** Cast from ptrdiff_to to size_t. We restrict the cast to positive integers to avoid reasoning about modular arithmetic *) val ptrdifft_to_sizet (x:t{v x >= 0}) : Pure US.t (requires True) (ensures fun c -> v x == US.v c) val add (x y: t) : Pure t (requires (fits (v x + v y))) (ensures (fun z -> v z == v x + v y)) (** Division primitive As for rem below, we only provide division on positive signed integers, to avoid having to reason about possible overflows *) val div (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures fun c -> v a / v b == v c) (** Modulo specification, similar to FStar.Int.mod *)
false
false
FStar.PtrdiffT.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 mod_spec (a: int{fits a}) (b: int{fits b /\ b <> 0}) : GTot (n: int{fits n})
[]
FStar.PtrdiffT.mod_spec
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Prims.int{FStar.PtrdiffT.fits a} -> b: Prims.int{FStar.PtrdiffT.fits b /\ b <> 0} -> Prims.GTot (n: Prims.int{FStar.PtrdiffT.fits n})
{ "end_col": 5, "end_line": 74, "start_col": 2, "start_line": 71 }
Prims.Tot
val va_codegen_success_InnerMemcpy : va_dummy:unit -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test.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 va_codegen_success_InnerMemcpy () = (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) 8 Secret) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_ttrue ())))))
val va_codegen_success_InnerMemcpy : va_dummy:unit -> Tot va_pbool let va_codegen_success_InnerMemcpy () =
false
null
false
(va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) 8 Secret) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_ttrue ())))))
{ "checked_file": "Vale.Test.X64.Vale_memcpy.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Test.X64.Vale_memcpy.fst" }
[ "total" ]
[ "Prims.unit", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsMem.va_codegen_success_Load64_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRax", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdx", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Machine_s.rR9", "Vale.X64.InsMem.va_codegen_success_Store64_buffer", "Vale.X64.Machine_s.rRcx", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.Test.X64.Vale_memcpy open Vale.Arch.HeapImpl open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.QuickCode open Vale.X64.QuickCodes #set-options "--z3rlimit 20" //-- InnerMemcpy val va_code_InnerMemcpy : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_InnerMemcpy () = (va_Block (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) 8 Secret) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_CNil ())))))) val va_codegen_success_InnerMemcpy : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr]
false
true
Vale.Test.X64.Vale_memcpy.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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_InnerMemcpy : va_dummy:unit -> Tot va_pbool
[]
Vale.Test.X64.Vale_memcpy.va_codegen_success_InnerMemcpy
{ "file_name": "obj/Vale.Test.X64.Vale_memcpy.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_dummy: Prims.unit -> Vale.X64.Decls.va_pbool
{ "end_col": 88, "end_line": 36, "start_col": 2, "start_line": 30 }
Prims.Tot
val va_code_InnerMemcpy : va_dummy:unit -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Test.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 va_code_InnerMemcpy () = (va_Block (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) 8 Secret) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_CNil ()))))))
val va_code_InnerMemcpy : va_dummy:unit -> Tot va_code let va_code_InnerMemcpy () =
false
null
false
(va_Block (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) 8 Secret) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_CNil ()))))))
{ "checked_file": "Vale.Test.X64.Vale_memcpy.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Test.X64.Vale_memcpy.fst" }
[ "total" ]
[ "Prims.unit", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsMem.va_code_Load64_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRax", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdx", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Machine_s.rR9", "Vale.X64.InsMem.va_code_Store64_buffer", "Vale.X64.Machine_s.rRcx", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
module Vale.Test.X64.Vale_memcpy open Vale.Arch.HeapImpl open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.QuickCode open Vale.X64.QuickCodes #set-options "--z3rlimit 20" //-- InnerMemcpy val va_code_InnerMemcpy : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr]
false
true
Vale.Test.X64.Vale_memcpy.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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_InnerMemcpy : va_dummy:unit -> Tot va_code
[]
Vale.Test.X64.Vale_memcpy.va_code_InnerMemcpy
{ "file_name": "obj/Vale.Test.X64.Vale_memcpy.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_dummy: Prims.unit -> Vale.X64.Decls.va_code
{ "end_col": 29, "end_line": 25, "start_col": 2, "start_line": 19 }