file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
Hacl.Impl.Chacha20.Core32xN.fst
Hacl.Impl.Chacha20.Core32xN.transpose8
val transpose8: st:state 8 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose8 (as_seq h0 st)))
val transpose8: st:state 8 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose8 (as_seq h0 st)))
let transpose8 st = let (st0,st1,st2,st3,st4,st5,st6,st7) = (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in let (st8,st9,st10,st11,st12,st13,st14,st15) = (st.(8ul),st.(9ul),st.(10ul),st.(11ul),st.(12ul),st.(13ul),st.(14ul),st.(15ul)) in let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st0,st1,st2,st3,st4,st5,st6,st7) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st8,st9,st10,st11,st12,st13,st14,st15) in create16 #(uint32xN 8) st v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.Core32xN.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 81, "end_line": 110, "start_col": 0, "start_line": 105 }
module Hacl.Impl.Chacha20.Core32xN module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Hacl.Spec.Chacha20.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let lanes = Spec.lanes inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w inline_for_extraction let state (w:lanes) = lbuffer (uint32xN w) 16ul inline_for_extraction let index = (i:size_t{size_v i < 16}) inline_for_extraction noextract val create_state: w:lanes -> StackInline (state w) (requires (fun h -> True)) (ensures (fun h0 r h1 -> live h1 r /\ as_seq h1 r == Seq.create 16 (vec_zero U32 w) /\ stack_allocated r h0 h1 (Seq.create 16 (vec_zero U32 w)))) let create_state w = create (size 16) (vec_zero U32 w) inline_for_extraction noextract val add_counter: #w:lanes -> st:state w -> c:size_t{w * v c <= max_size_t} -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.add_counter #w (v c) (as_seq h0 st))) let add_counter #w st c = let v = vec_load #U32 (u32 w *! size_to_uint32 c) w in let old_c = st.(12ul) in st.(size 12) <- old_c +| v inline_for_extraction noextract val copy_state: #w:lanes -> st:state w -> ost:state w -> Stack unit (requires (fun h -> live h st /\ live h ost /\ disjoint st ost)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == as_seq h0 ost)) let copy_state #w st ost = copy st ost inline_for_extraction noextract val sum_state: #w:lanes -> st:state w -> ost:state w -> Stack unit (requires (fun h -> live h st /\ live h ost /\ eq_or_disjoint st ost)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.sum_state (as_seq h0 st) (as_seq h0 ost))) let sum_state #w st ost = map2T (size 16) st ( +| ) st ost inline_for_extraction noextract val transpose1: st:state 1 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose1 (as_seq h0 st))) let transpose1 st = () inline_for_extraction noextract val transpose4: st:state 4 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose4 (as_seq h0 st))) let transpose4 st = let (st0, st1, st2, st3) = (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4, st5, st6, st7) = (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in let (st8, st9, st10, st11) = (st.(8ul),st.(9ul),st.(10ul),st.(11ul)) in let (st12, st13, st14, st15) = (st.(12ul),st.(13ul),st.(14ul),st.(15ul)) in let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st0, st1, st2, st3) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st4, st5, st6, st7) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st8, st9, st10, st11) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st12, st13, st14, st15) in create16 #(uint32xN 4) st v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15 inline_for_extraction noextract val transpose8: st:state 8 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Chacha20.Vec.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.Core32xN.fst" }
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.Chacha20.Vec", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.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 } ]
{ "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" }
false
st: Hacl.Impl.Chacha20.Core32xN.state 8 -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Chacha20.Core32xN.state", "Lib.IntVector.vec_t", "Lib.IntTypes.U32", "Lib.Buffer.create16", "Hacl.Impl.Chacha20.Core32xN.uint32xN", "Prims.unit", "Lib.IntVector.Transpose.vec_t8", "Lib.IntVector.Transpose.transpose8x8", "FStar.Pervasives.Native.Mktuple8", "FStar.Pervasives.Native.tuple8", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t" ]
[]
false
true
false
false
false
let transpose8 st =
let st0, st1, st2, st3, st4, st5, st6, st7 = (st.(0ul), st.(1ul), st.(2ul), st.(3ul), st.(4ul), st.(5ul), st.(6ul), st.(7ul)) in let st8, st9, st10, st11, st12, st13, st14, st15 = (st.(8ul), st.(9ul), st.(10ul), st.(11ul), st.(12ul), st.(13ul), st.(14ul), st.(15ul)) in let v0, v1, v2, v3, v4, v5, v6, v7 = VecTranspose.transpose8x8 (st0, st1, st2, st3, st4, st5, st6, st7) in let v8, v9, v10, v11, v12, v13, v14, v15 = VecTranspose.transpose8x8 (st8, st9, st10, st11, st12, st13, st14, st15) in create16 #(uint32xN 8) st v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.transpose
val transpose (#w: lanes) (st: state w) : state w
val transpose (#w: lanes) (st: state w) : state w
let transpose (#w:lanes) (st:state w) : state w = match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 144, "start_col": 0, "start_line": 140 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
st: Hacl.Spec.Chacha20.Vec.state w -> Hacl.Spec.Chacha20.Vec.state w
Prims.Tot
[ "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" ]
[]
false
false
false
false
false
let transpose (#w: lanes) (st: state w) : state w =
match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.chacha20_constants
val chacha20_constants:lseq size_t 4
val chacha20_constants:lseq size_t 4
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
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 112, "start_col": 0, "start_line": 108 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB) 4
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.chacha20_init
val chacha20_init (#w: lanes) (k: key) (n: nonce) (ctr0: counter) : state w
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 = 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
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 124, "start_col": 0, "start_line": 120 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
k: Hacl.Spec.Chacha20.Vec.key -> n: Hacl.Spec.Chacha20.Vec.nonce -> ctr0: Hacl.Spec.Chacha20.Vec.counter -> Hacl.Spec.Chacha20.Vec.state w
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.chacha20_encrypt_last
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)
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
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 186, "start_col": 0, "start_line": 182 }
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 ->
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Impl.Chacha20.Core32xN.fst
Hacl.Impl.Chacha20.Core32xN.xor_block
val xor_block: #w:lanes -> o:lbuffer uint8 ((4ul *! size w) *! 16ul) -> st:state w -> b:lbuffer uint8 ((4ul *! size w) *! 16ul) -> Stack unit (requires (fun h -> live h o /\ live h st /\ live h b /\ disjoint st b /\ disjoint st o /\ eq_or_disjoint b o)) (ensures (fun h0 _ h1 -> modifies (loc st |+| loc o) h0 h1 /\ as_seq h1 o == Spec.xor_block #w (as_seq h0 st) (as_seq h0 b)))
val xor_block: #w:lanes -> o:lbuffer uint8 ((4ul *! size w) *! 16ul) -> st:state w -> b:lbuffer uint8 ((4ul *! size w) *! 16ul) -> Stack unit (requires (fun h -> live h o /\ live h st /\ live h b /\ disjoint st b /\ disjoint st o /\ eq_or_disjoint b o)) (ensures (fun h0 _ h1 -> modifies (loc st |+| loc o) h0 h1 /\ as_seq h1 o == Spec.xor_block #w (as_seq h0 st) (as_seq h0 b)))
let xor_block #w o st b = let h0 = ST.get () in map_blocks_multi h0 (size w *! 4ul) 16ul b o (fun h -> Spec.xor_block_f #w (as_seq h0 st)) (fun i -> [@inline_let] let bs = normalize_term (size w *! 4ul) in let x = vec_load_le U32 w (sub b (i *! bs) bs) in let y = x ^| st.(i) in vec_store_le #U32 #w (sub o (i *! bs) bs) y )
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.Core32xN.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 147, "start_col": 0, "start_line": 137 }
module Hacl.Impl.Chacha20.Core32xN module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Hacl.Spec.Chacha20.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let lanes = Spec.lanes inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w inline_for_extraction let state (w:lanes) = lbuffer (uint32xN w) 16ul inline_for_extraction let index = (i:size_t{size_v i < 16}) inline_for_extraction noextract val create_state: w:lanes -> StackInline (state w) (requires (fun h -> True)) (ensures (fun h0 r h1 -> live h1 r /\ as_seq h1 r == Seq.create 16 (vec_zero U32 w) /\ stack_allocated r h0 h1 (Seq.create 16 (vec_zero U32 w)))) let create_state w = create (size 16) (vec_zero U32 w) inline_for_extraction noextract val add_counter: #w:lanes -> st:state w -> c:size_t{w * v c <= max_size_t} -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.add_counter #w (v c) (as_seq h0 st))) let add_counter #w st c = let v = vec_load #U32 (u32 w *! size_to_uint32 c) w in let old_c = st.(12ul) in st.(size 12) <- old_c +| v inline_for_extraction noextract val copy_state: #w:lanes -> st:state w -> ost:state w -> Stack unit (requires (fun h -> live h st /\ live h ost /\ disjoint st ost)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == as_seq h0 ost)) let copy_state #w st ost = copy st ost inline_for_extraction noextract val sum_state: #w:lanes -> st:state w -> ost:state w -> Stack unit (requires (fun h -> live h st /\ live h ost /\ eq_or_disjoint st ost)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.sum_state (as_seq h0 st) (as_seq h0 ost))) let sum_state #w st ost = map2T (size 16) st ( +| ) st ost inline_for_extraction noextract val transpose1: st:state 1 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose1 (as_seq h0 st))) let transpose1 st = () inline_for_extraction noextract val transpose4: st:state 4 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose4 (as_seq h0 st))) let transpose4 st = let (st0, st1, st2, st3) = (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4, st5, st6, st7) = (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in let (st8, st9, st10, st11) = (st.(8ul),st.(9ul),st.(10ul),st.(11ul)) in let (st12, st13, st14, st15) = (st.(12ul),st.(13ul),st.(14ul),st.(15ul)) in let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st0, st1, st2, st3) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st4, st5, st6, st7) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st8, st9, st10, st11) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st12, st13, st14, st15) in create16 #(uint32xN 4) st v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15 inline_for_extraction noextract val transpose8: st:state 8 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose8 (as_seq h0 st))) let transpose8 st = let (st0,st1,st2,st3,st4,st5,st6,st7) = (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in let (st8,st9,st10,st11,st12,st13,st14,st15) = (st.(8ul),st.(9ul),st.(10ul),st.(11ul),st.(12ul),st.(13ul),st.(14ul),st.(15ul)) in let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st0,st1,st2,st3,st4,st5,st6,st7) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st8,st9,st10,st11,st12,st13,st14,st15) in create16 #(uint32xN 8) st v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15 inline_for_extraction noextract val transpose: #w:lanes -> st:state w -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose (as_seq h0 st))) let transpose #w st = match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st inline_for_extraction noextract val xor_block: #w:lanes -> o:lbuffer uint8 ((4ul *! size w) *! 16ul) -> st:state w -> b:lbuffer uint8 ((4ul *! size w) *! 16ul) -> Stack unit (requires (fun h -> live h o /\ live h st /\ live h b /\ disjoint st b /\ disjoint st o /\ eq_or_disjoint b o)) (ensures (fun h0 _ h1 -> modifies (loc st |+| loc o) h0 h1 /\
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Chacha20.Vec.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.Core32xN.fst" }
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.Chacha20.Vec", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.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 } ]
{ "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" }
false
o: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (4ul *! Lib.IntTypes.size w *! 16ul) -> st: Hacl.Impl.Chacha20.Core32xN.state w -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (4ul *! Lib.IntTypes.size w *! 16ul) -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Chacha20.Core32xN.lanes", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size", "Hacl.Impl.Chacha20.Core32xN.state", "Lib.Buffer.map_blocks_multi", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "Hacl.Spec.Chacha20.Vec.xor_block_f", "Lib.Buffer.as_seq", "Hacl.Impl.Chacha20.Core32xN.uint32xN", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.Sequence.lseq", "Lib.IntTypes.size_t", "Lib.IntVector.vec_store_le", "Prims.unit", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.mul", "Lib.IntTypes.mk_int", "Lib.Buffer.sub", "Lib.IntVector.vec_t", "Lib.IntVector.op_Hat_Bar", "Lib.Buffer.op_Array_Access", "Lib.IntVector.vec_load_le", "FStar.Pervasives.normalize_term", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let xor_block #w o st b =
let h0 = ST.get () in map_blocks_multi h0 (size w *! 4ul) 16ul b o (fun h -> Spec.xor_block_f #w (as_seq h0 st)) (fun i -> [@@ inline_let ]let bs = normalize_term (size w *! 4ul) in let x = vec_load_le U32 w (sub b (i *! bs) bs) in let y = x ^| st.(i) in vec_store_le #U32 #w (sub o (i *! bs) bs) y)
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.chacha20_decrypt_bytes
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}
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 = let st0 = chacha20_init #w key nonce ctr0 in chacha20_update #w st0 cipher
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 221, "start_col": 0, "start_line": 219 }
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}
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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}
Prims.Tot
[ "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" ]
[]
false
false
false
false
false
let chacha20_decrypt_bytes #w key nonce ctr0 cipher =
let st0 = chacha20_init #w key nonce ctr0 in chacha20_update #w st0 cipher
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.chacha20_encrypt_block
val chacha20_encrypt_block: #w: lanes -> st0: state w -> incr: counter{incr * w <= max_size_t} -> b: blocks w -> Tot (blocks w)
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
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 173, "start_col": 0, "start_line": 170 }
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 ->
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.xor_block
val xor_block (#w: lanes) (k: state w) (b: blocks w) : blocks w
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 = map_blocks_multi (w * 4) 16 16 b (xor_block_f #w k)
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 53, "end_line": 162, "start_col": 0, "start_line": 161 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
k: Hacl.Spec.Chacha20.Vec.state w -> b: Hacl.Spec.Chacha20.Vec.blocks w -> Hacl.Spec.Chacha20.Vec.blocks w
Prims.Tot
[ "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" ]
[]
false
false
false
false
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)
false
Vale.Lib.Tactics.fst
Vale.Lib.Tactics.iterate_env
val iterate_env (bs: binders) : Tac unit
val iterate_env (bs: binders) : Tac unit
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
{ "file_name": "vale/code/lib/util/Vale.Lib.Tactics.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 40, "start_col": 0, "start_line": 25 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
bs: FStar.Stubs.Reflection.Types.binders -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.binders", "Prims.unit", "FStar.Stubs.Reflection.Types.binder", "Prims.list", "FStar.Stubs.Reflection.Types.term", "Vale.Lib.Tactics.iterate_env", "Prims.Cons", "FStar.Tactics.V1.Logic.implies_intro", "FStar.Stubs.Tactics.V1.Builtins.clear", "FStar.Stubs.Tactics.V1.Builtins.pack", "FStar.Stubs.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.Stubs.Reflection.Types.typ", "FStar.Reflection.V1.Derived.type_of_binder" ]
[ "recursion" ]
false
true
false
false
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 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
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.chacha20_update
val chacha20_update: #w:lanes -> st0: state w -> msg: bytes{length msg <= max_size_t} -> cipher: bytes{length cipher == length msg}
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)
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 197, "start_col": 0, "start_line": 193 }
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}
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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}
Prims.Tot
[ "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" ]
[]
false
false
false
false
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)
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.transpose1
val transpose1 (st: state 1) : state 1
val transpose1 (st: state 1) : state 1
let transpose1 (st:state 1) : state 1 = st
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 42, "end_line": 126, "start_col": 0, "start_line": 126 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
st: Hacl.Spec.Chacha20.Vec.state 1 -> Hacl.Spec.Chacha20.Vec.state 1
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Chacha20.Vec.state" ]
[]
false
false
false
false
false
let transpose1 (st: state 1) : state 1 =
st
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.xor_block_f
val xor_block_f (#w: lanes) (k: state w) (i: nat{i < 16}) (b: lbytes (w * 4)) : lbytes (w * 4)
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) = let x = vec_from_bytes_le U32 w b in let y = x ^| k.[i] in vec_to_bytes_le y
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 159, "start_col": 0, "start_line": 156 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
k: Hacl.Spec.Chacha20.Vec.state w -> i: Prims.nat{i < 16} -> b: Lib.ByteSequence.lbytes (w * 4) -> Lib.ByteSequence.lbytes (w * 4)
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.transpose4
val transpose4 (st: state 4) : state 4
val transpose4 (st: state 4) : state 4
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
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 64, "end_line": 133, "start_col": 0, "start_line": 128 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
st: Hacl.Spec.Chacha20.Vec.state 4 -> Hacl.Spec.Chacha20.Vec.state 4
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Spec.Chacha20.Vec.fst
Hacl.Spec.Chacha20.Vec.transpose8
val transpose8 (st: state 8) : state 8
val transpose8 (st: state 8) : state 8
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
{ "file_name": "code/chacha20/Hacl.Spec.Chacha20.Vec.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 64, "end_line": 138, "start_col": 0, "start_line": 135 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
st: Hacl.Spec.Chacha20.Vec.state 8 -> Hacl.Spec.Chacha20.Vec.state 8
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Impl.Chacha20.Core32xN.fst
Hacl.Impl.Chacha20.Core32xN.double_round
val double_round: #w:lanes -> st:state w -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.double_round (as_seq h0 st)))
val double_round: #w:lanes -> st:state w -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.double_round (as_seq h0 st)))
let double_round #w st = quarter_round st (size 0) (size 4) (size 8) (size 12); quarter_round st (size 1) (size 5) (size 9) (size 13); quarter_round st (size 2) (size 6) (size 10) (size 14); quarter_round st (size 3) (size 7) (size 11) (size 15); quarter_round st (size 0) (size 5) (size 10) (size 15); quarter_round st (size 1) (size 6) (size 11) (size 12); quarter_round st (size 2) (size 7) (size 8) (size 13); quarter_round st (size 3) (size 4) (size 9) (size 14)
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.Core32xN.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 198, "start_col": 0, "start_line": 189 }
module Hacl.Impl.Chacha20.Core32xN module ST = FStar.HyperStack.ST open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector module Spec = Hacl.Spec.Chacha20.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let lanes = Spec.lanes inline_for_extraction let uint32xN (w:lanes) = vec_t U32 w inline_for_extraction let state (w:lanes) = lbuffer (uint32xN w) 16ul inline_for_extraction let index = (i:size_t{size_v i < 16}) inline_for_extraction noextract val create_state: w:lanes -> StackInline (state w) (requires (fun h -> True)) (ensures (fun h0 r h1 -> live h1 r /\ as_seq h1 r == Seq.create 16 (vec_zero U32 w) /\ stack_allocated r h0 h1 (Seq.create 16 (vec_zero U32 w)))) let create_state w = create (size 16) (vec_zero U32 w) inline_for_extraction noextract val add_counter: #w:lanes -> st:state w -> c:size_t{w * v c <= max_size_t} -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.add_counter #w (v c) (as_seq h0 st))) let add_counter #w st c = let v = vec_load #U32 (u32 w *! size_to_uint32 c) w in let old_c = st.(12ul) in st.(size 12) <- old_c +| v inline_for_extraction noextract val copy_state: #w:lanes -> st:state w -> ost:state w -> Stack unit (requires (fun h -> live h st /\ live h ost /\ disjoint st ost)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == as_seq h0 ost)) let copy_state #w st ost = copy st ost inline_for_extraction noextract val sum_state: #w:lanes -> st:state w -> ost:state w -> Stack unit (requires (fun h -> live h st /\ live h ost /\ eq_or_disjoint st ost)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.sum_state (as_seq h0 st) (as_seq h0 ost))) let sum_state #w st ost = map2T (size 16) st ( +| ) st ost inline_for_extraction noextract val transpose1: st:state 1 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose1 (as_seq h0 st))) let transpose1 st = () inline_for_extraction noextract val transpose4: st:state 4 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose4 (as_seq h0 st))) let transpose4 st = let (st0, st1, st2, st3) = (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4, st5, st6, st7) = (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in let (st8, st9, st10, st11) = (st.(8ul),st.(9ul),st.(10ul),st.(11ul)) in let (st12, st13, st14, st15) = (st.(12ul),st.(13ul),st.(14ul),st.(15ul)) in let (v0,v1,v2,v3) = VecTranspose.transpose4x4 (st0, st1, st2, st3) in let (v4,v5,v6,v7) = VecTranspose.transpose4x4 (st4, st5, st6, st7) in let (v8,v9,v10,v11) = VecTranspose.transpose4x4 (st8, st9, st10, st11) in let (v12,v13,v14,v15) = VecTranspose.transpose4x4 (st12, st13, st14, st15) in create16 #(uint32xN 4) st v0 v4 v8 v12 v1 v5 v9 v13 v2 v6 v10 v14 v3 v7 v11 v15 inline_for_extraction noextract val transpose8: st:state 8 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose8 (as_seq h0 st))) let transpose8 st = let (st0,st1,st2,st3,st4,st5,st6,st7) = (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in let (st8,st9,st10,st11,st12,st13,st14,st15) = (st.(8ul),st.(9ul),st.(10ul),st.(11ul),st.(12ul),st.(13ul),st.(14ul),st.(15ul)) in let (v0,v1,v2,v3,v4,v5,v6,v7) = VecTranspose.transpose8x8 (st0,st1,st2,st3,st4,st5,st6,st7) in let (v8,v9,v10,v11,v12,v13,v14,v15) = VecTranspose.transpose8x8 (st8,st9,st10,st11,st12,st13,st14,st15) in create16 #(uint32xN 8) st v0 v8 v1 v9 v2 v10 v3 v11 v4 v12 v5 v13 v6 v14 v7 v15 inline_for_extraction noextract val transpose: #w:lanes -> st:state w -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.transpose (as_seq h0 st))) let transpose #w st = match w with | 1 -> transpose1 st | 4 -> transpose4 st | 8 -> transpose8 st inline_for_extraction noextract val xor_block: #w:lanes -> o:lbuffer uint8 ((4ul *! size w) *! 16ul) -> st:state w -> b:lbuffer uint8 ((4ul *! size w) *! 16ul) -> Stack unit (requires (fun h -> live h o /\ live h st /\ live h b /\ disjoint st b /\ disjoint st o /\ eq_or_disjoint b o)) (ensures (fun h0 _ h1 -> modifies (loc st |+| loc o) h0 h1 /\ as_seq h1 o == Spec.xor_block #w (as_seq h0 st) (as_seq h0 b))) let xor_block #w o st b = let h0 = ST.get () in map_blocks_multi h0 (size w *! 4ul) 16ul b o (fun h -> Spec.xor_block_f #w (as_seq h0 st)) (fun i -> [@inline_let] let bs = normalize_term (size w *! 4ul) in let x = vec_load_le U32 w (sub b (i *! bs) bs) in let y = x ^| st.(i) in vec_store_le #U32 #w (sub o (i *! bs) bs) y ) inline_for_extraction noextract val line: #w:lanes -> st:state w -> a:index -> b:index -> d:index -> r:rotval U32 -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.line (v a) (v b) (v d) r (as_seq h0 st))) let line #w st a b d r = st.(a) <- st.(a) +| st.(b); let std = st.(d) ^| st.(a) in st.(d) <- std <<<| r inline_for_extraction noextract val quarter_round: #w:lanes -> st:state w -> a:index -> b:index -> c:index -> d:index -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.quarter_round (v a) (v b) (v c) (v d) (as_seq h0 st))) let quarter_round #w st a b c d = line st a b d (size 16); line st c d b (size 12); line st a b d (size 8); line st c d b (size 7) inline_for_extraction noextract val double_round: #w:lanes -> st:state w -> Stack unit (requires (fun h -> live h st)) (ensures (fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.double_round (as_seq h0 st)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Chacha20.Vec.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.Core32xN.fst" }
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.Chacha20.Vec", "short_module": "Spec" }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.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 } ]
{ "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" }
false
st: Hacl.Impl.Chacha20.Core32xN.state w -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Chacha20.Core32xN.lanes", "Hacl.Impl.Chacha20.Core32xN.state", "Hacl.Impl.Chacha20.Core32xN.quarter_round", "Lib.IntTypes.size", "Prims.unit" ]
[]
false
true
false
false
false
let double_round #w st =
quarter_round st (size 0) (size 4) (size 8) (size 12); quarter_round st (size 1) (size 5) (size 9) (size 13); quarter_round st (size 2) (size 6) (size 10) (size 14); quarter_round st (size 3) (size 7) (size 11) (size 15); quarter_round st (size 0) (size 5) (size 10) (size 15); quarter_round st (size 1) (size 6) (size 11) (size 12); quarter_round st (size 2) (size 7) (size 8) (size 13); quarter_round st (size 3) (size 4) (size 9) (size 14)
false
HACL.fst
HACL.signable_len
val signable_len : Type0
let signable_len = v:US.t{ is_signable_len v }
{ "file_name": "share/steel/examples/pulse/dice/common/HACL.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 46, "end_line": 51, "start_col": 0, "start_line": 51 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module HACL open Pulse.Lib.Pervasives module R = Pulse.Lib.Reference module A = Pulse.Lib.Array module US = FStar.SizeT module U8 = FStar.UInt8 module U32 = FStar.UInt32 let v32us : US.t = 32sz // let coerce (l:US.t) (s:erased (elseq U8.t l)) : erased (Seq.seq U8.t) // = let s_ = reveal s in // hide s_ // let coerce_refined (l:US.t) (s:erased (Seq.seq U8.t){Seq.length (reveal s) == US.v l}) : erased (elseq U8.t l) // = let s_ = reveal s in // hide s_ (* a tiny model of HACL* hashes *) assume val alg_t : Type0 assume val digest_len (_:alg_t) : US.t assume val is_hashable_len (_:US.t) : prop let hashable_len = v:US.t{ is_hashable_len v } assume val is_signable_len (_:US.t) : prop
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "HACL.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.SizeT.t", "HACL.is_signable_len" ]
[]
false
false
false
true
true
let signable_len =
v: US.t{is_signable_len v}
false
HACL.fst
HACL.hkdf_ikm_len
val hkdf_ikm_len : Type0
let hkdf_ikm_len = v:US.t{ valid_hkdf_ikm_len v }
{ "file_name": "share/steel/examples/pulse/dice/common/HACL.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 49, "end_line": 61, "start_col": 0, "start_line": 61 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module HACL open Pulse.Lib.Pervasives module R = Pulse.Lib.Reference module A = Pulse.Lib.Array module US = FStar.SizeT module U8 = FStar.UInt8 module U32 = FStar.UInt32 let v32us : US.t = 32sz // let coerce (l:US.t) (s:erased (elseq U8.t l)) : erased (Seq.seq U8.t) // = let s_ = reveal s in // hide s_ // let coerce_refined (l:US.t) (s:erased (Seq.seq U8.t){Seq.length (reveal s) == US.v l}) : erased (elseq U8.t l) // = let s_ = reveal s in // hide s_ (* a tiny model of HACL* hashes *) assume val alg_t : Type0 assume val digest_len (_:alg_t) : US.t assume val is_hashable_len (_:US.t) : prop let hashable_len = v:US.t{ is_hashable_len v } assume val is_signable_len (_:US.t) : prop let signable_len = v:US.t{ is_signable_len v } assume val valid_hkdf_lbl_len (l:US.t) : prop let hkdf_lbl_len = v:US.t{ valid_hkdf_lbl_len v } assume val valid_hkdf_ikm_len (_:US.t) : prop
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "HACL.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.SizeT.t", "HACL.valid_hkdf_ikm_len" ]
[]
false
false
false
true
true
let hkdf_ikm_len =
v: US.t{valid_hkdf_ikm_len v}
false
HACL.fst
HACL.hkdf_lbl_len
val hkdf_lbl_len : Type0
let hkdf_lbl_len = v:US.t{ valid_hkdf_lbl_len v }
{ "file_name": "share/steel/examples/pulse/dice/common/HACL.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 49, "end_line": 56, "start_col": 0, "start_line": 56 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module HACL open Pulse.Lib.Pervasives module R = Pulse.Lib.Reference module A = Pulse.Lib.Array module US = FStar.SizeT module U8 = FStar.UInt8 module U32 = FStar.UInt32 let v32us : US.t = 32sz // let coerce (l:US.t) (s:erased (elseq U8.t l)) : erased (Seq.seq U8.t) // = let s_ = reveal s in // hide s_ // let coerce_refined (l:US.t) (s:erased (Seq.seq U8.t){Seq.length (reveal s) == US.v l}) : erased (elseq U8.t l) // = let s_ = reveal s in // hide s_ (* a tiny model of HACL* hashes *) assume val alg_t : Type0 assume val digest_len (_:alg_t) : US.t assume val is_hashable_len (_:US.t) : prop let hashable_len = v:US.t{ is_hashable_len v } assume val is_signable_len (_:US.t) : prop let signable_len = v:US.t{ is_signable_len v } assume val valid_hkdf_lbl_len (l:US.t) : prop
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "HACL.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.SizeT.t", "HACL.valid_hkdf_lbl_len" ]
[]
false
false
false
true
true
let hkdf_lbl_len =
v: US.t{valid_hkdf_lbl_len v}
false
HACL.fst
HACL.v32us
val v32us:US.t
val v32us:US.t
let v32us : US.t = 32sz
{ "file_name": "share/steel/examples/pulse/dice/common/HACL.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 23, "end_line": 25, "start_col": 0, "start_line": 25 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module HACL open Pulse.Lib.Pervasives module R = Pulse.Lib.Reference module A = Pulse.Lib.Array module US = FStar.SizeT module U8 = FStar.UInt8 module U32 = FStar.UInt32
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "HACL.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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" }
false
FStar.SizeT.t
Prims.Tot
[ "total" ]
[]
[ "FStar.SizeT.__uint_to_t" ]
[]
false
false
false
true
false
let v32us:US.t =
32sz
false
HACL.fst
HACL.hashable_len
val hashable_len : Type0
let hashable_len = v:US.t{ is_hashable_len v }
{ "file_name": "share/steel/examples/pulse/dice/common/HACL.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 46, "end_line": 46, "start_col": 0, "start_line": 46 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module HACL open Pulse.Lib.Pervasives module R = Pulse.Lib.Reference module A = Pulse.Lib.Array module US = FStar.SizeT module U8 = FStar.UInt8 module U32 = FStar.UInt32 let v32us : US.t = 32sz // let coerce (l:US.t) (s:erased (elseq U8.t l)) : erased (Seq.seq U8.t) // = let s_ = reveal s in // hide s_ // let coerce_refined (l:US.t) (s:erased (Seq.seq U8.t){Seq.length (reveal s) == US.v l}) : erased (elseq U8.t l) // = let s_ = reveal s in // hide s_ (* a tiny model of HACL* hashes *) assume val alg_t : Type0 assume val digest_len (_:alg_t) : US.t assume val is_hashable_len (_:US.t) : prop
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "HACL.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.SizeT.t", "HACL.is_hashable_len" ]
[]
false
false
false
true
true
let hashable_len =
v: US.t{is_hashable_len v}
false
Vale.AES.GCM_BE.fsti
Vale.AES.GCM_BE.set_to_one
val set_to_one (q: quad32) : quad32
val set_to_one (q: quad32) : quad32
let set_to_one (q:quad32) : quad32 = Mkfour 1 q.lo1 q.hi2 q.hi3
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM_BE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 63, "end_line": 21, "start_col": 0, "start_line": 21 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
q: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let set_to_one (q: quad32) : quad32 =
Mkfour 1 q.lo1 q.hi2 q.hi3
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.close_pattern'
val close_pattern' : p: Pulse.Syntax.Base.pattern -> x: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> Pulse.Syntax.Base.pattern
let close_pattern' (p:pattern) (x:var) (i:index) = subst_pat p [ND x i]
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 22, "end_line": 168, "start_col": 0, "start_line": 167 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () let open_pattern' (p:pattern) (v:term) (i:index) =
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
p: Pulse.Syntax.Base.pattern -> x: Pulse.Syntax.Base.var -> i: Pulse.Syntax.Base.index -> Pulse.Syntax.Base.pattern
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let close_pattern' (p: pattern) (x: var) (i: index) =
subst_pat p [ND x i]
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.close_pattern_args'
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)
let close_pattern_args' (ps:list (pattern & bool)) (x:var) (i:index) = subst_pat_args ps [ND x i]
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 172, "start_col": 0, "start_line": 171 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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) =
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let close_pattern_args' (ps: list (pattern & bool)) (x: var) (i: index) =
subst_pat_args ps [ND x i]
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_term_pairs'
val open_term_pairs' (t: list (term & term)) (v: term) (i: index) : Tot (list (term & term))
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)) = subst_term_pairs t [ DT i v ]
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 33, "end_line": 133, "start_col": 0, "start_line": 131 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let open_term_pairs' (t: list (term & term)) (v: term) (i: index) : Tot (list (term & term)) =
subst_term_pairs t [DT i v]
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_pattern_args'
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)
let open_pattern_args' (ps:list (pattern & bool)) (v:term) (i:index) = subst_pat_args ps [DT i v]
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 170, "start_col": 0, "start_line": 169 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v] let close_pattern' (p:pattern) (x:var) (i:index) =
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let open_pattern_args' (ps: list (pattern & bool)) (v: term) (i: index) =
subst_pat_args ps [DT i v]
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_pattern'
val open_pattern' : p: Pulse.Syntax.Base.pattern -> v: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> Pulse.Syntax.Base.pattern
let open_pattern' (p:pattern) (v:term) (i:index) = subst_pat p [DT i v]
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 22, "end_line": 166, "start_col": 0, "start_line": 165 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> ()
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
p: Pulse.Syntax.Base.pattern -> v: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> Pulse.Syntax.Base.pattern
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let open_pattern' (p: pattern) (v: term) (i: index) =
subst_pat p [DT i v]
false
Vale.AES.GCM_BE.fsti
Vale.AES.GCM_BE.gcm_decrypt_BE_tag
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)
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: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
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCM_BE.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 200, "start_col": 0, "start_line": 179 }
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)))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Pure
[]
[]
[ "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" ]
[]
false
false
false
false
false
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) =
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.close_term_pairs'
val close_term_pairs' (t: list (term & term)) (v: var) (i: index) : Tot (list (term & term))
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)) = subst_term_pairs t [ ND v i ]
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 33, "end_line": 871, "start_col": 0, "start_line": 869 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' t (i - 1)) (ensures ln_opt' ln' (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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let close_term_pairs' (t: list (term & term)) (v: var) (i: index) : Tot (list (term & term)) =
subst_term_pairs t [ND v i]
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.tot_typing_ln
val tot_typing_ln (#g:_) (#e:_) (#t:_) (d:tot_typing g e t) : Lemma (ln e /\ ln t)
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) = tot_or_ghost_typing_ln d
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 1028, "start_col": 0, "start_line": 1023 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' t (i - 1)) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #push-options "--query_stats --fuel 2 --ifuel 2 --z3rlimit_factor 2" 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 { expected_type; term } -> close_term_ln' expected_type x i; 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; map_opt_lemma_2 close_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 close_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> close_term_ln' name x i; close_st_term_ln' body x i; match returns_inv with | None -> () | Some (ret_ty, returns_inv) -> close_term_ln' ret_ty.binder_ty x i; close_term_ln' returns_inv x (i + 1) #pop-options 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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
d: Pulse.Typing.tot_typing g e t -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln e /\ Pulse.Syntax.Naming.ln t)
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_term_ln_opt'
val open_term_ln_opt' (t: option term) (x: term) (i: index) : Lemma (requires ln_opt' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' t i) (decreases t)
val open_term_ln_opt' (t: option term) (x: term) (i: index) : Lemma (requires ln_opt' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' t i) (decreases t)
let open_term_ln_opt' (t:option term) (x:term) (i:index) : Lemma (requires ln_opt' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 35, "end_line": 113, "start_col": 0, "start_line": 106 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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.ln' (Pulse.Syntax.Naming.open_term_opt' t x i) (i - 1)) (ensures Pulse.Syntax.Naming.ln_opt' Pulse.Syntax.Naming.ln' t i) (decreases t)
FStar.Pervasives.Lemma
[ "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.ln'", "Pulse.Syntax.Naming.open_term_opt'", "Prims.op_Subtraction", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let open_term_ln_opt' (t: option term) (x: term) (i: index) : Lemma (requires ln_opt' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' t i) (decreases t) =
match t with | None -> () | Some t -> open_term_ln' t x i
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_proof_hint_ln
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)
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) = 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 | WILD | SHOW_PROOF_STATE _ -> ()
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 163, "start_col": 0, "start_line": 147 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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", "Pulse.Syntax.Base.range", "Prims.b2t", "Pulse.Syntax.Naming.ln_proof_hint'", "Pulse.Syntax.Naming.open_proof_hint'", "Prims.op_Subtraction", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
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 = 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 | WILD | SHOW_PROOF_STATE _ -> ()
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_st_term_ln
val open_st_term_ln (e: st_term) (v: var) : Lemma (requires ln_st (open_st_term e v)) (ensures ln_st' e 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) = open_st_term_ln' e (term_of_no_name_var v) 0
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 48, "end_line": 365, "start_col": 0, "start_line": 361 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_term_ln
val open_term_ln (e: term) (v: var) : Lemma (requires ln (open_term e v)) (ensures ln' e 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) = open_term_ln' e (term_of_no_name_var v) 0
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 45, "end_line": 358, "start_col": 0, "start_line": 354 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_term_ln_pairs
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)
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) = 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
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 145, "start_col": 0, "start_line": 135 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 ]
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_term_ln_list'
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)
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) = match t with | [] -> () | hd::tl -> open_term_ln' hd x i; open_term_ln_list' tl x i
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 129, "start_col": 0, "start_line": 120 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.well_typed_terms_are_ln
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)
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: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
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 43, "end_line": 34, "start_col": 0, "start_line": 31 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
g: FStar.Stubs.Reflection.Types.env -> e: FStar.Stubs.Reflection.Types.term -> t: FStar.Stubs.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)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Stubs.Reflection.Types.env", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "FStar.Reflection.Typing.typing", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.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" ]
[]
true
false
true
false
false
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) =
RT.well_typed_terms_are_ln g e (eff, t) d
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.ln_weakening_comp
val ln_weakening_comp (c: comp) (i j: int) : Lemma (requires ln_c' c i /\ i <= j) (ensures ln_c' c j)
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) = match c with | C_Tot t -> ln_weakening t i j | C_ST s | C_STGhost 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 -> 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)
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 41, "end_line": 424, "start_col": 0, "start_line": 406 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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", "Pulse.Syntax.Base.observability", "Prims.l_and", "Prims.b2t", "Pulse.Syntax.Naming.ln_c'", "Prims.op_LessThanOrEqual", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
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 | C_STGhost 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 -> 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)
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.ln_weakening_pairs
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)
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) = match t with | [] -> () | (l, r)::tl -> ln_weakening l i j; ln_weakening r i j; ln_weakening_pairs tl i j
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 457, "start_col": 0, "start_line": 447 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.ln_weakening_list
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)
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) = match t with | [] -> () | hd::tl -> ln_weakening hd i j; ln_weakening_list tl i j
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 445, "start_col": 0, "start_line": 436 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.__brs_of
val __brs_of (t: st_term{Tm_Match? t.term}) : list branch
val __brs_of (t: st_term{Tm_Match? t.term}) : list branch
let __brs_of (t:st_term{Tm_Match? t.term}) : list branch = let Tm_Match {brs} = t.term in brs
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 118, "start_col": 0, "start_line": 116 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' t i) (decreases t) = match t with | None -> () | Some t -> open_term_ln' t x i
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
t: Pulse.Syntax.Base.st_term{Tm_Match? (Mkst_term?.term t)} -> Prims.list Pulse.Syntax.Base.branch
Prims.Tot
[ "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'" ]
[]
false
false
false
false
false
let __brs_of (t: st_term{Tm_Match? t.term}) : list branch =
let Tm_Match { brs = brs } = t.term in brs
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.ln_weakening_opt
val ln_weakening_opt (t: option term) (i j: int) : Lemma (requires ln_opt' ln' t i /\ i <= j) (ensures ln_opt' ln' t j) (decreases t)
val ln_weakening_opt (t: option term) (i j: int) : Lemma (requires ln_opt' ln' t i /\ i <= j) (ensures ln_opt' ln' t j) (decreases t)
let ln_weakening_opt (t:option term) (i j:int) : Lemma (requires ln_opt' ln' t i /\ i <= j) (ensures ln_opt' ln' t j) (decreases t) = match t with | None -> () | Some t -> ln_weakening t i j
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 34, "end_line": 433, "start_col": 0, "start_line": 426 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
t: FStar.Pervasives.Native.option Pulse.Syntax.Base.term -> i: Prims.int -> j: Prims.int -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_opt' Pulse.Syntax.Naming.ln' t i /\ i <= j) (ensures Pulse.Syntax.Naming.ln_opt' Pulse.Syntax.Naming.ln' t j) (decreases t)
FStar.Pervasives.Lemma
[ "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'", "Pulse.Syntax.Naming.ln'", "Prims.op_LessThanOrEqual", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let ln_weakening_opt (t: option term) (i j: int) : Lemma (requires ln_opt' ln' t i /\ i <= j) (ensures ln_opt' ln' t j) (decreases t) =
match t with | None -> () | Some t -> ln_weakening t i j
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_term_ln_inv_list'
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)
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) = match t with | [] -> () | hd::tl -> open_term_ln_inv' hd x i; open_term_ln_inv_list' tl x i
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 35, "end_line": 655, "start_col": 0, "start_line": 644 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_comp_ln'
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)
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) = match c with | C_Tot t -> open_term_ln' t x i | C_ST s | C_STGhost 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 -> 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)
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 36, "end_line": 104, "start_col": 0, "start_line": 84 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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", "Pulse.Syntax.Base.observability", "Prims.b2t", "Pulse.Syntax.Naming.ln_c'", "Pulse.Syntax.Naming.open_comp'", "Prims.op_Subtraction", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
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 | C_STGhost 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 -> 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)
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_term_ln'
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)
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: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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 42, "end_line": 82, "start_col": 0, "start_line": 51 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
false
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) =
match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.close_term_ln_opt'
val close_term_ln_opt' (t: option term) (x: var) (i: index) : Lemma (requires ln_opt' ln' t (i - 1)) (ensures ln_opt' ln' (close_term_opt' t x i) i) (decreases t)
val close_term_ln_opt' (t: option term) (x: var) (i: index) : Lemma (requires ln_opt' ln' t (i - 1)) (ensures ln_opt' ln' (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' ln' t (i - 1)) (ensures ln_opt' ln' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 36, "end_line": 856, "start_col": 0, "start_line": 849 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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' Pulse.Syntax.Naming.ln' t (i - 1)) (ensures Pulse.Syntax.Naming.ln_opt' Pulse.Syntax.Naming.ln' (Pulse.Syntax.Naming.close_term_opt' t x i) i) (decreases t)
FStar.Pervasives.Lemma
[ "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'", "Pulse.Syntax.Naming.ln'", "Prims.op_Subtraction", "Prims.squash", "Pulse.Syntax.Naming.close_term_opt'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let close_term_ln_opt' (t: option term) (x: var) (i: index) : Lemma (requires ln_opt' ln' t (i - 1)) (ensures ln_opt' ln' (close_term_opt' t x i) i) (decreases t) =
match t with | None -> () | Some t -> close_term_ln' t x i
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_term_ln_inv_opt'
val open_term_ln_inv_opt' (t: option term) (x: term{ln x}) (i: index) : Lemma (requires ln_opt' ln' t i) (ensures ln_opt' ln' (open_term_opt' t x i) (i - 1)) (decreases t)
val open_term_ln_inv_opt' (t: option term) (x: term{ln x}) (i: index) : Lemma (requires ln_opt' ln' t i) (ensures ln_opt' ln' (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' ln' t i) (ensures ln_opt' ln' (open_term_opt' t x i) (i - 1)) (decreases t) = match t with | None -> () | Some t -> open_term_ln_inv' t x i
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 39, "end_line": 642, "start_col": 0, "start_line": 633 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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' Pulse.Syntax.Naming.ln' t i) (ensures Pulse.Syntax.Naming.ln_opt' Pulse.Syntax.Naming.ln' (Pulse.Syntax.Naming.open_term_opt' t x i) (i - 1)) (decreases t)
FStar.Pervasives.Lemma
[ "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'", "Pulse.Syntax.Naming.ln'", "Prims.squash", "Pulse.Syntax.Naming.open_term_opt'", "Prims.op_Subtraction", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let open_term_ln_inv_opt' (t: option term) (x: term{ln x}) (i: index) : Lemma (requires ln_opt' ln' t i) (ensures ln_opt' ln' (open_term_opt' t x i) (i - 1)) (decreases t) =
match t with | None -> () | Some t -> open_term_ln_inv' t x i
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.ln_weakening_proof_hint
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)
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) = 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 | WILD | SHOW_PROOF_STATE _ -> ()
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 475, "start_col": 0, "start_line": 459 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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", "Pulse.Syntax.Base.range", "Prims.l_and", "Prims.b2t", "Pulse.Syntax.Naming.ln_proof_hint'", "Prims.op_LessThanOrEqual", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
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 = 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 | WILD | SHOW_PROOF_STATE _ -> ()
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_comp_ln_inv'
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))
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)) = match c with | C_Tot t -> open_term_ln_inv' t x i | C_ST s | C_STGhost 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 -> 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)
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 40, "end_line": 631, "start_col": 0, "start_line": 611 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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))
FStar.Pervasives.Lemma
[ "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.Base.observability", "Pulse.Syntax.Naming.ln_c'", "Prims.squash", "Pulse.Syntax.Naming.open_comp'", "Prims.op_Subtraction", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
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 | C_STGhost 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 -> 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)
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.ln_weakening
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)]
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)] = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 26, "end_line": 403, "start_col": 0, "start_line": 373 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
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)]
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j | Tm_AddInv 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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_proof_hint_ln_inv
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))
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)) = 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 | WILD | SHOW_PROOF_STATE _ -> ()
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 687, "start_col": 0, "start_line": 671 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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))
FStar.Pervasives.Lemma
[ "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.Base.range", "Pulse.Syntax.Naming.ln_proof_hint'", "Prims.squash", "Pulse.Syntax.Naming.open_proof_hint'", "Prims.op_Subtraction", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
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 = 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 | WILD | SHOW_PROOF_STATE _ -> ()
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_term_ln_inv_pairs
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)
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) = 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
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 35, "end_line": 669, "start_col": 0, "start_line": 657 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.close_comp_ln'
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)
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) = match c with | C_Tot t -> close_term_ln' t x i | C_ST s | C_STGhost 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 -> 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)
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 37, "end_line": 847, "start_col": 0, "start_line": 827 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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", "Pulse.Syntax.Base.observability", "Prims.b2t", "Pulse.Syntax.Naming.ln_c'", "Prims.op_Subtraction", "Prims.squash", "Pulse.Syntax.Naming.close_comp'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
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 | C_STGhost 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 -> 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)
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.tot_or_ghost_typing_ln
val tot_or_ghost_typing_ln (#g #e #t #eff: _) (d: typing g e eff t) : Lemma (ensures ln e /\ ln 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) = let E dt = d in well_typed_terms_are_ln _ _ _ dt; elab_ln_inverse e; elab_ln_inverse t
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 21, "end_line": 1021, "start_col": 0, "start_line": 1013 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' t (i - 1)) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #push-options "--query_stats --fuel 2 --ifuel 2 --z3rlimit_factor 2" 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 { expected_type; term } -> close_term_ln' expected_type x i; 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; map_opt_lemma_2 close_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 close_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> close_term_ln' name x i; close_st_term_ln' body x i; match returns_inv with | None -> () | Some (ret_ty, returns_inv) -> close_term_ln' ret_ty.binder_ty x i; close_term_ln' returns_inv x (i + 1) #pop-options 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) = ()
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
d: Pulse.Typing.typing g e eff t -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln e /\ Pulse.Syntax.Naming.ln t)
FStar.Pervasives.Lemma
[ "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.Stubs.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" ]
[]
false
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.close_term_ln'
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)
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) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> () | Tm_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 825, "start_col": 0, "start_line": 795 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.close_proof_hint_ln
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)
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) = 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 | WILD | SHOW_PROOF_STATE _ -> ()
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 901, "start_col": 0, "start_line": 885 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' t (i - 1)) (ensures ln_opt' ln' (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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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", "Pulse.Syntax.Base.range", "Prims.b2t", "Pulse.Syntax.Naming.ln_proof_hint'", "Prims.op_Subtraction", "Prims.squash", "Pulse.Syntax.Naming.close_proof_hint'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
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 = 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 | WILD | SHOW_PROOF_STATE _ -> ()
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.close_comp_ln
val close_comp_ln (c: comp) (v: var) : Lemma (requires ln_c c) (ensures ln_c' (close_comp 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) = close_comp_ln' c v 0
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 24, "end_line": 1003, "start_col": 0, "start_line": 999 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' t (i - 1)) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #push-options "--query_stats --fuel 2 --ifuel 2 --z3rlimit_factor 2" 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 { expected_type; term } -> close_term_ln' expected_type x i; 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; map_opt_lemma_2 close_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 close_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> close_term_ln' name x i; close_st_term_ln' body x i; match returns_inv with | None -> () | Some (ret_ty, returns_inv) -> close_term_ln' ret_ty.binder_ty x i; close_term_ln' returns_inv x (i + 1)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_term_ln_inv'
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)
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) = match e.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Unknown -> ln_weakening x (-1) (i - 1) | Tm_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 43, "end_line": 609, "start_col": 0, "start_line": 576 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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))
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i | Tm_AddInv 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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.close_term_ln_list'
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)
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) = match t with | [] -> () | hd::tl -> close_term_ln' hd x i; close_term_ln_list' tl x i
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 32, "end_line": 867, "start_col": 0, "start_line": 858 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' t (i - 1)) (ensures ln_opt' ln' (close_term_opt' t x i) i) (decreases t) = match t with | None -> () | Some t -> close_term_ln' t x i
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.close_term_ln_pairs
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)
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) = 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
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 32, "end_line": 883, "start_col": 0, "start_line": 873 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' t (i - 1)) (ensures ln_opt' ln' (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 ]
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[ "recursion" ]
false
false
true
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_pattern_args_ln
val 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)
val 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)
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)
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 56, "end_line": 213, "start_col": 0, "start_line": 190 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
pats: Prims.list (Pulse.Syntax.Base.pattern * Prims.bool) -> x: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_pattern_args' (Pulse.Typing.LN.open_pattern_args' pats x i) (i - 1)) (ensures Pulse.Syntax.Naming.ln_pattern_args' pats i) (decreases pats)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[ "open_pattern_ln", "open_pattern_args_ln" ]
[ "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.pattern", "Prims.bool", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Typing.LN.open_pattern_args_ln", "Prims.op_Addition", "Pulse.Syntax.Naming.pattern_shift_n", "Prims.unit", "Pulse.Typing.LN.open_pattern_ln", "Prims.b2t", "Pulse.Syntax.Naming.ln_pattern_args'", "Pulse.Typing.LN.open_pattern_args'", "Prims.op_Subtraction", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec 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)
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.st_comp_typing_ln
val st_comp_typing_ln (#g #st: _) (d: st_comp_typing g st) : Lemma (ensures ln_st_comp st (- 1))
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)) = 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
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 35, "end_line": 1117, "start_col": 0, "start_line": 1110 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' t (i - 1)) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #push-options "--query_stats --fuel 2 --ifuel 2 --z3rlimit_factor 2" 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 { expected_type; term } -> close_term_ln' expected_type x i; 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; map_opt_lemma_2 close_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 close_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> close_term_ln' name x i; close_st_term_ln' body x i; match returns_inv with | None -> () | Some (ret_ty, returns_inv) -> close_term_ln' ret_ty.binder_ty x i; close_term_ln' returns_inv x (i + 1) #pop-options 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 | VE_Fa g x u b t0' t1' d -> vprop_equiv_ln d; let xtm = (term_of_nvar (v_as_nv x)) in introduce ln t0 ==> ln t1 with _ . ( open_term_ln_inv' t0' xtm 0; open_term_ln t0' x; open_term_ln t1' x ); introduce ln t1 ==> ln t0 with _ . ( open_term_ln_inv' t1' xtm 0; open_term_ln t1' x; open_term_ln t0' x ) let st_equiv_ln #g #c1 #c2 (d:st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = match d with | ST_VPropEquiv _ _ _ x (E dpre) _dres _dpost eq_res eq_pre eq_post -> 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 | ST_TotEquiv g t1 t2 u t1_typing eq -> let t2_typing = Pulse.Typing.Metatheory.Base.rt_equiv_typing eq t1_typing._0 in tot_or_ghost_typing_ln (E (Ghost.reveal t2_typing)) let prop_valid_must_be_ln (g:env) (t:term) (d:prop_validity g t) : Lemma (ensures ln t) = admit() let rec st_sub_ln #g #c1 #c2 (d:st_sub g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) (decreases d) = match d with | STS_Refl _ _ -> () | STS_Trans _ _ _ _ d1 d2 -> st_sub_ln d1; st_sub_ln d2 | STS_AtomicInvs g stc is1 is2 _ _ tok -> prop_valid_must_be_ln g (tm_inames_subset is1 is2) tok; assume (ln (tm_inames_subset is1 is2) ==> ln is2) 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) = ()
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
d: Pulse.Typing.st_comp_typing g st -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln_st_comp st (- 1))
FStar.Pervasives.Lemma
[ "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" ]
[]
false
false
true
false
false
let st_comp_typing_ln (#g #st: _) (d: st_comp_typing g st) : Lemma (ensures ln_st_comp st (- 1)) =
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.open_pattern_ln
val 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)
val 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)
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)
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 56, "end_line": 213, "start_col": 0, "start_line": 190 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
p: Pulse.Syntax.Base.pattern -> x: Pulse.Syntax.Base.term -> i: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (requires Pulse.Syntax.Naming.ln_pattern' (Pulse.Typing.LN.open_pattern' p x i) (i - 1)) (ensures Pulse.Syntax.Naming.ln_pattern' p i) (decreases p)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[ "open_pattern_ln", "open_pattern_args_ln" ]
[ "Pulse.Syntax.Base.pattern", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Syntax.Base.constant", "FStar.Reflection.Typing.pp_name_t", "FStar.Reflection.Typing.sort_t", "Pulse.Typing.LN.open_term_ln'", "Pulse.Syntax.Base.fv", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.bool", "Pulse.Typing.LN.open_pattern_args_ln", "Prims.unit", "Prims.b2t", "Pulse.Syntax.Naming.ln_pattern'", "Pulse.Typing.LN.open_pattern'", "Prims.op_Subtraction", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
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
false
LowParse.Tot.Int.fst
LowParse.Tot.Int.parse_u8
val parse_u8 : LowParse.Spec.Base.tot_parser LowParse.Spec.Int.parse_u8_kind FStar.UInt8.t
let parse_u8 = tot_parse_u8
{ "file_name": "src/lowparse/LowParse.Tot.Int.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 27, "end_line": 6, "start_col": 0, "start_line": 6 }
module LowParse.Tot.Int include LowParse.Spec.Int include LowParse.Tot.Base
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
LowParse.Spec.Base.tot_parser LowParse.Spec.Int.parse_u8_kind FStar.UInt8.t
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Int.tot_parse_u8" ]
[]
false
false
false
true
false
let parse_u8 =
tot_parse_u8
false
LowParse.Tot.Int.fst
LowParse.Tot.Int.serialize_u8
val serialize_u8 : serializer parse_u8
val serialize_u8 : serializer parse_u8
let serialize_u8 = serialize_ext _ serialize_u8 _
{ "file_name": "src/lowparse/LowParse.Tot.Int.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 32, "end_line": 10, "start_col": 0, "start_line": 9 }
module LowParse.Tot.Int include LowParse.Spec.Int include LowParse.Tot.Base inline_for_extraction let parse_u8 = tot_parse_u8
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
LowParse.Tot.Base.serializer LowParse.Tot.Int.parse_u8
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let serialize_u8 =
serialize_ext _ serialize_u8 _
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.st_equiv_ln
val st_equiv_ln (#g #c1 #c2: _) (d: st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2)
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) = match d with | ST_VPropEquiv _ _ _ x (E dpre) _dres _dpost eq_res eq_pre eq_post -> 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 | ST_TotEquiv g t1 t2 u t1_typing eq -> let t2_typing = Pulse.Typing.Metatheory.Base.rt_equiv_typing eq t1_typing._0 in tot_or_ghost_typing_ln (E (Ghost.reveal t2_typing))
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 57, "end_line": 1082, "start_col": 0, "start_line": 1067 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' t (i - 1)) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #push-options "--query_stats --fuel 2 --ifuel 2 --z3rlimit_factor 2" 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 { expected_type; term } -> close_term_ln' expected_type x i; 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; map_opt_lemma_2 close_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 close_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> close_term_ln' name x i; close_st_term_ln' body x i; match returns_inv with | None -> () | Some (ret_ty, returns_inv) -> close_term_ln' ret_ty.binder_ty x i; close_term_ln' returns_inv x (i + 1) #pop-options 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 | VE_Fa g x u b t0' t1' d -> vprop_equiv_ln d; let xtm = (term_of_nvar (v_as_nv x)) in introduce ln t0 ==> ln t1 with _ . ( open_term_ln_inv' t0' xtm 0; open_term_ln t0' x; open_term_ln t1' x ); introduce ln t1 ==> ln t0 with _ . ( open_term_ln_inv' t1' xtm 0; open_term_ln t1' x; open_term_ln t0' x )
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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.Stubs.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.Base.term", "Pulse.Syntax.Base.universe", "Pulse.Typing.universe_of", "FStar.Ghost.erased", "Pulse.Typing.LN.tot_or_ghost_typing_ln", "Pulse.Typing.E", "FStar.Ghost.reveal", "FStar.Reflection.Typing.tot_typing", "Pulse.Typing.Metatheory.Base.rt_equiv_typing", "FStar.Ghost.hide", "Pulse.Typing.__proj__E__item___0", "Pulse.Syntax.Naming.ln_c", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let st_equiv_ln #g #c1 #c2 (d: st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) =
match d with | ST_VPropEquiv _ _ _ x (E dpre) _dres _dpost eq_res eq_pre eq_post -> 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 | ST_TotEquiv g t1 t2 u t1_typing eq -> let t2_typing = Pulse.Typing.Metatheory.Base.rt_equiv_typing eq t1_typing._0 in tot_or_ghost_typing_ln (E (Ghost.reveal t2_typing))
false
Hacl.Bignum.AlmostMontExponentiation.fst
Hacl.Bignum.AlmostMontExponentiation.a_spec
val a_spec : n: Hacl.Spec.Bignum.Definitions.lbignum t len {0 < Hacl.Spec.Bignum.Definitions.bn_v n} -> Type0
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)
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 38, "start_col": 0, "start_line": 37 }
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"
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
n: Hacl.Spec.Bignum.Definitions.lbignum t len {0 < Hacl.Spec.Bignum.Definitions.bn_v n} -> Type0
Prims.Tot
[ "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" ]
[]
false
false
false
false
true
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)
false
FStar.PtrdiffT.fsti
FStar.PtrdiffT.op_Greater_Hat
val op_Greater_Hat : x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
let op_Greater_Hat = gt
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 111, "start_col": 7, "start_line": 111 }
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 *)
{ "checked_file": "/", "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" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "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 } ]
{ "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" }
false
x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.gt" ]
[]
false
false
false
false
false
let op_Greater_Hat =
gt
false
FStar.PtrdiffT.fsti
FStar.PtrdiffT.op_Plus_Hat
val op_Plus_Hat : x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure FStar.PtrdiffT.t
let op_Plus_Hat = add
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 110, "start_col": 7, "start_line": 110 }
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 *)
{ "checked_file": "/", "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" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "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 } ]
{ "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" }
false
x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure FStar.PtrdiffT.t
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.add" ]
[]
false
false
false
false
false
let op_Plus_Hat =
add
false
FStar.PtrdiffT.fsti
FStar.PtrdiffT.op_Greater_Equals_Hat
val op_Greater_Equals_Hat : x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
let op_Greater_Equals_Hat = gte
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 112, "start_col": 7, "start_line": 112 }
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
{ "checked_file": "/", "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" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "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 } ]
{ "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" }
false
x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.gte" ]
[]
false
false
false
false
false
let op_Greater_Equals_Hat =
gte
false
FStar.PtrdiffT.fsti
FStar.PtrdiffT.op_Less_Hat
val op_Less_Hat : x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
let op_Less_Hat = lt
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 113, "start_col": 7, "start_line": 113 }
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
{ "checked_file": "/", "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" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "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 } ]
{ "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" }
false
x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.lt" ]
[]
false
false
false
false
false
let op_Less_Hat =
lt
false
Hacl.Bignum.AlmostMontExponentiation.fst
Hacl.Bignum.AlmostMontExponentiation.refl
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
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 = BD.bn_v a % BD.bn_v n
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 46, "start_col": 0, "start_line": 45 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.vprop_equiv_ln
val vprop_equiv_ln (#g #t0 #t1: _) (v: vprop_equiv g t0 t1) : Lemma (ensures ln t0 <==> ln t1) (decreases v)
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) = 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 | VE_Fa g x u b t0' t1' d -> vprop_equiv_ln d; let xtm = (term_of_nvar (v_as_nv x)) in introduce ln t0 ==> ln t1 with _ . ( open_term_ln_inv' t0' xtm 0; open_term_ln t0' x; open_term_ln t1' x ); introduce ln t1 ==> ln t0 with _ . ( open_term_ln_inv' t1' xtm 0; open_term_ln t1' x; open_term_ln t0' x )
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 7, "end_line": 1064, "start_col": 0, "start_line": 1030 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' t (i - 1)) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #push-options "--query_stats --fuel 2 --ifuel 2 --z3rlimit_factor 2" 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 { expected_type; term } -> close_term_ln' expected_type x i; 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; map_opt_lemma_2 close_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 close_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> close_term_ln' name x i; close_st_term_ln' body x i; match returns_inv with | None -> () | Some (ret_ty, returns_inv) -> close_term_ln' ret_ty.binder_ty x i; close_term_ln' returns_inv x (i + 1) #pop-options 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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
v: Pulse.Typing.vprop_equiv g t0 t1 -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln t0 <==> Pulse.Syntax.Naming.ln t1) (decreases v)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.vprop_equiv", "Pulse.Typing.LN.vprop_equiv_ln", "Prims.unit", "FStar.Stubs.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", "Pulse.Syntax.Base.var", "Prims.b2t", "FStar.Pervasives.Native.uu___is_None", "Pulse.Syntax.Base.typ", "Pulse.Typing.Env.lookup", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.binder", "Prims.l_not", "FStar.Set.mem", "Pulse.Syntax.Naming.freevars", "Pulse.Typing.Env.push_binding", "Pulse.Syntax.Base.ppname_default", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Syntax.Naming.open_term", "FStar.Classical.Sugar.implies_intro", "Pulse.Syntax.Naming.ln", "Prims.squash", "Pulse.Typing.LN.open_term_ln", "Pulse.Typing.LN.open_term_ln_inv'", "Pulse.Syntax.Pure.term_of_nvar", "Pulse.Syntax.Base.v_as_nv", "Prims.l_True", "Prims.l_iff", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
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 | VE_Fa g x u b t0' t1' d -> vprop_equiv_ln d; let xtm = (term_of_nvar (v_as_nv x)) in introduce ln t0 ==> ln t1 with _. (open_term_ln_inv' t0' xtm 0; open_term_ln t0' x; open_term_ln t1' x); introduce ln t1 ==> ln t0 with _. (open_term_ln_inv' t1' xtm 0; open_term_ln t1' x; open_term_ln t0' x)
false
FStar.PtrdiffT.fsti
FStar.PtrdiffT.op_Less_Equals_Hat
val op_Less_Equals_Hat : x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
let op_Less_Equals_Hat = lte
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 114, "start_col": 7, "start_line": 114 }
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
{ "checked_file": "/", "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" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "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 } ]
{ "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" }
false
x: FStar.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.lte" ]
[]
false
false
false
false
false
let op_Less_Equals_Hat =
lte
false
FStar.PtrdiffT.fsti
FStar.PtrdiffT.zero
val zero:(zero_ptrdiff: t{v zero_ptrdiff == 0})
val zero:(zero_ptrdiff: t{v zero_ptrdiff == 0})
let zero : (zero_ptrdiff: t { v zero_ptrdiff == 0 }) = mk 0s
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 7, "end_line": 48, "start_col": 0, "start_line": 47 }
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))
{ "checked_file": "/", "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" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "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 } ]
{ "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" }
false
zero_ptrdiff: FStar.PtrdiffT.t{FStar.PtrdiffT.v zero_ptrdiff == 0}
Prims.Tot
[ "total" ]
[]
[ "FStar.PtrdiffT.mk", "FStar.Int16.__int_to_t" ]
[]
false
false
false
false
false
let zero:(zero_ptrdiff: t{v zero_ptrdiff == 0}) =
mk 0s
false
FStar.PtrdiffT.fsti
FStar.PtrdiffT.mod_spec
val mod_spec (a: int{fits a}) (b: int{fits b /\ b <> 0}) : GTot (n: int{fits n})
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}) = let open FStar.Mul in let res = a - ((a/b) * b) in fits_lt res b; res
{ "file_name": "ulib/FStar.PtrdiffT.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 74, "start_col": 0, "start_line": 70 }
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 *)
{ "checked_file": "/", "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" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "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 } ]
{ "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" }
false
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})
Prims.GTot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Bignum.AlmostMontExponentiation.fst
Hacl.Bignum.AlmostMontExponentiation.linv
val linv (#t: limb_t) (#len: SN.bn_len t) (n a: BD.lbignum t len) : Type0
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:BD.lbignum t len) (a:BD.lbignum t len) : Type0 = BD.bn_v a < pow2 (bits t * len)
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 42, "start_col": 0, "start_line": 41 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> Type0
Prims.Tot
[ "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" ]
[]
false
false
false
false
true
let linv (#t: limb_t) (#len: SN.bn_len t) (n a: BD.lbignum t len) : Type0 =
BD.bn_v a < pow2 (bits t * len)
false
Pulse.Typing.LN.fst
Pulse.Typing.LN.comp_typing_ln
val comp_typing_ln (#g:_) (#c:_) (#u:_) (d:comp_typing g c u) : Lemma (ln_c c)
val comp_typing_ln (#g:_) (#c:_) (#u:_) (d:comp_typing g c u) : Lemma (ln_c c)
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 | CT_STGhost _ _ st_typing -> st_comp_typing_ln st_typing | CT_STAtomic _ _ _ _ inames_typing st_typing -> tot_or_ghost_typing_ln inames_typing; st_comp_typing_ln st_typing
{ "file_name": "lib/steel/pulse/Pulse.Typing.LN.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 1128, "start_col": 0, "start_line": 1119 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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_Inv p -> open_term_ln' p x i | Tm_Pure p -> open_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' (open_term_opt' t x i) (i - 1)) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 map_opt_lemma_2 ($f: (x:'a -> y:'b -> z:'c -> Lemma (requires 'p x y z) (ensures 'q x y z))) (x:option 'a) (y:'b) (z:'c) : Lemma (requires Some? x ==> 'p (Some?.v x) y z) (ensures Some? x ==> 'q (Some?.v x) y z) = match x with | None -> () | Some x -> f x y z #push-options "--z3rlimit 20" 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 { expected_type; term = e } -> open_term_ln' expected_type x i; 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; map_opt_lemma_2 open_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln' name x i; open_st_term_ln' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln' b.binder_ty x i; open_term_ln' r x (i + 1) // 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_Inv p -> ln_weakening p i j | Tm_Pure p -> ln_weakening p i j // | Tm_PureApp l _ r | Tm_AddInv 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 #pop-options 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 | C_STGhost 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 -> 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' ln' t i /\ i <= j) (ensures ln_opt' ln' 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 | WILD | SHOW_PROOF_STATE _ -> () 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 { expected_type; term } -> ln_weakening expected_type i j; 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; map_opt_lemma_2 ln_weakening_comp c.annotated (i + 1) (j + 1); map_opt_lemma_2 ln_weakening_comp c.elaborated (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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> ln_weakening name i j; ln_weakening_st body i j; match returns_inv with | None -> () | Some (b, r) -> ln_weakening b.binder_ty i j; ln_weakening r (i + 1) (j + 1) 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_Inv p -> open_term_ln_inv' p x i | Tm_Pure p -> open_term_ln_inv' p x i // | Tm_PureApp l _ r | Tm_AddInv 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 | C_STGhost 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 -> 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' ln' t i) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #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 { expected_type; term } -> open_term_ln_inv' expected_type x i; 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; map_opt_lemma_2 open_comp_ln_inv' c.annotated x (i + 1); map_opt_lemma_2 open_comp_ln_inv' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> open_term_ln_inv' name x i; open_term_ln_inv_st' body x i; match returns_inv with | None -> () | Some (b, r) -> open_term_ln_inv' b.binder_ty x i; open_term_ln_inv' r x (i + 1) #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_Inv p -> close_term_ln' p x i | Tm_Pure p -> close_term_ln' p x i | Tm_AddInv l r | 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 | C_STGhost 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 -> 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' ln' t (i - 1)) (ensures ln_opt' ln' (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 | WILD | SHOW_PROOF_STATE _ -> () #push-options "--query_stats --fuel 2 --ifuel 2 --z3rlimit_factor 2" 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 { expected_type; term } -> close_term_ln' expected_type x i; 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; map_opt_lemma_2 close_comp_ln' c.annotated x (i + 1); map_opt_lemma_2 close_comp_ln' c.elaborated 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_Unreachable -> () | 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) | Tm_WithInv { name; body; returns_inv } -> close_term_ln' name x i; close_st_term_ln' body x i; match returns_inv with | None -> () | Some (ret_ty, returns_inv) -> close_term_ln' ret_ty.binder_ty x i; close_term_ln' returns_inv x (i + 1) #pop-options 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 | VE_Fa g x u b t0' t1' d -> vprop_equiv_ln d; let xtm = (term_of_nvar (v_as_nv x)) in introduce ln t0 ==> ln t1 with _ . ( open_term_ln_inv' t0' xtm 0; open_term_ln t0' x; open_term_ln t1' x ); introduce ln t1 ==> ln t0 with _ . ( open_term_ln_inv' t1' xtm 0; open_term_ln t1' x; open_term_ln t0' x ) let st_equiv_ln #g #c1 #c2 (d:st_equiv g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) = match d with | ST_VPropEquiv _ _ _ x (E dpre) _dres _dpost eq_res eq_pre eq_post -> 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 | ST_TotEquiv g t1 t2 u t1_typing eq -> let t2_typing = Pulse.Typing.Metatheory.Base.rt_equiv_typing eq t1_typing._0 in tot_or_ghost_typing_ln (E (Ghost.reveal t2_typing)) let prop_valid_must_be_ln (g:env) (t:term) (d:prop_validity g t) : Lemma (ensures ln t) = admit() let rec st_sub_ln #g #c1 #c2 (d:st_sub g c1 c2) : Lemma (requires ln_c c1) (ensures ln_c c2) (decreases d) = match d with | STS_Refl _ _ -> () | STS_Trans _ _ _ _ d1 d2 -> st_sub_ln d1; st_sub_ln d2 | STS_AtomicInvs g stc is1 is2 _ _ tok -> prop_valid_must_be_ln g (tm_inames_subset is1 is2) tok; assume (ln (tm_inames_subset is1 is2) ==> ln is2) 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
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "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", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Typing.LN.fst" }
[ { "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 } ]
{ "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" }
false
d: Pulse.Typing.comp_typing g c u488 -> FStar.Pervasives.Lemma (ensures Pulse.Syntax.Naming.ln_c c)
FStar.Pervasives.Lemma
[ "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.Syntax.Base.observability", "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" ]
[]
false
false
true
false
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 | CT_STGhost _ _ st_typing -> st_comp_typing_ln st_typing | CT_STAtomic _ _ _ _ inames_typing st_typing -> tot_or_ghost_typing_ln inames_typing; st_comp_typing_ln st_typing
false
Vale.Test.X64.Vale_memcpy.fst
Vale.Test.X64.Vale_memcpy.va_codegen_success_InnerMemcpy
val va_codegen_success_InnerMemcpy : va_dummy:unit -> Tot va_pbool
val va_codegen_success_InnerMemcpy : va_dummy:unit -> Tot va_pbool
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 ())))))
{ "file_name": "obj/Vale.Test.X64.Vale_memcpy.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 88, "end_line": 36, "start_col": 0, "start_line": 29 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
va_dummy: Prims.unit -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "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" ]
[]
false
false
false
true
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 ())))))
false
Vale.Test.X64.Vale_memcpy.fst
Vale.Test.X64.Vale_memcpy.va_code_InnerMemcpy
val va_code_InnerMemcpy : va_dummy:unit -> Tot va_code
val va_code_InnerMemcpy : va_dummy:unit -> Tot va_code
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 ()))))))
{ "file_name": "obj/Vale.Test.X64.Vale_memcpy.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 25, "start_col": 0, "start_line": 18 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
va_dummy: Prims.unit -> Vale.X64.Decls.va_code
Prims.Tot
[ "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" ]
[]
false
false
false
true
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 ()))))))
false
Vale.Test.X64.Vale_memcpy.fst
Vale.Test.X64.Vale_memcpy.va_wp_InnerMemcpy
val va_wp_InnerMemcpy (dst src: buffer64) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
val va_wp_InnerMemcpy (dst src: buffer64) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
let va_wp_InnerMemcpy (dst:buffer64) (src:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) src 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRcx va_s0) dst 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 src == 2 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 dst == 2 /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rcx:nat64) (va_x_r9:nat64) (va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM /\ Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src /\ Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) ==> va_k va_sM (())))
{ "file_name": "obj/Vale.Test.X64.Vale_memcpy.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 83, "end_line": 111, "start_col": 0, "start_line": 98 }
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] 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 ()))))) [@ "opaque_to_smt" va_qattr] let va_qcode_InnerMemcpy (va_mods:va_mods_t) (dst:buffer64) (src:buffer64) : (va_quickCode unit (va_code_InnerMemcpy ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 38 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdx) 0 Secret src 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 39 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) 8 Secret src 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 40 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rRax) 0 Secret dst 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 41 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rR9) 8 Secret dst 1) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 42 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (FStar.Seq.Base.equal #(Vale.X64.Memory.base_typ_as_vale_type Vale.X64.Memory.vuint64) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_s) dst) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_s) src)) (va_QEmpty (())))))))) val va_lemma_InnerMemcpy : va_b0:va_code -> va_s0:va_state -> dst:buffer64 -> src:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_InnerMemcpy ()) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) src 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRcx va_s0) dst 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 src == 2 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 dst == 2)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src /\ Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))) [@"opaque_to_smt"] let va_lemma_InnerMemcpy va_b0 va_s0 dst src = let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_InnerMemcpy va_mods dst src in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_InnerMemcpy ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 21 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 35 column 63 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 36 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
dst: Vale.X64.Memory.buffer64 -> src: Vale.X64.Memory.buffer64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Memory.buffer64", "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.Decls.validSrcAddrs64", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRdx", "Vale.X64.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.validDstAddrs64", "Vale.X64.Machine_s.rRcx", "Prims.eq2", "Prims.int", "Vale.X64.Decls.buffer_length", "Vale.X64.Memory.vuint64", "Prims.l_Forall", "Vale.X64.InsBasic.vale_heap", "Vale.X64.Memory.nat64", "Prims.l_imp", "FStar.Seq.Base.seq", "Vale.X64.Memory.base_typ_as_vale_type", "Vale.X64.Memory.buffer_as_seq", "Vale.X64.Decls.modifies_mem", "Vale.X64.Decls.loc_buffer", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_mem_heaplet", "Vale.X64.Decls.va_upd_reg64", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rRax", "Vale.X64.Decls.va_upd_mem" ]
[]
false
false
false
true
true
let va_wp_InnerMemcpy (dst src: buffer64) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) src 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRcx va_s0) dst 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 src == 2 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 dst == 2 /\ (forall (va_x_mem: vale_heap) (va_x_rax: nat64) (va_x_rcx: nat64) (va_x_r9: nat64) (va_x_heap1: vale_heap). let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM /\ Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src /\ Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) ==> va_k va_sM (())))
false
Vale.Test.X64.Vale_memcpy.fst
Vale.Test.X64.Vale_memcpy.va_qcode_InnerMemcpy
val va_qcode_InnerMemcpy (va_mods: va_mods_t) (dst src: buffer64) : (va_quickCode unit (va_code_InnerMemcpy ()))
val va_qcode_InnerMemcpy (va_mods: va_mods_t) (dst src: buffer64) : (va_quickCode unit (va_code_InnerMemcpy ()))
let va_qcode_InnerMemcpy (va_mods:va_mods_t) (dst:buffer64) (src:buffer64) : (va_quickCode unit (va_code_InnerMemcpy ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 38 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdx) 0 Secret src 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 39 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) 8 Secret src 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 40 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rRax) 0 Secret dst 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 41 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rR9) 8 Secret dst 1) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 42 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (FStar.Seq.Base.equal #(Vale.X64.Memory.base_typ_as_vale_type Vale.X64.Memory.vuint64) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_s) dst) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_s) src)) (va_QEmpty (()))))))))
{ "file_name": "obj/Vale.Test.X64.Vale_memcpy.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 58, "start_col": 0, "start_line": 39 }
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] 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 ())))))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
va_mods: Vale.X64.QuickCode.va_mods_t -> dst: Vale.X64.Memory.buffer64 -> src: Vale.X64.Memory.buffer64 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.Test.X64.Vale_memcpy.va_code_InnerMemcpy ())
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.X64.Memory.buffer64", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "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", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.QuickCodes.va_range1", "Vale.X64.InsMem.va_quick_Load64_buffer", "Vale.X64.InsMem.va_quick_Store64_buffer", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.QuickCodes.va_qAssert", "FStar.Seq.Base.equal", "Vale.X64.Memory.base_typ_as_vale_type", "Vale.X64.Memory.vuint64", "Vale.X64.Memory.buffer_as_seq", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.QuickCodes.va_QEmpty", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.Test.X64.Vale_memcpy.va_code_InnerMemcpy" ]
[]
false
false
false
false
false
let va_qcode_InnerMemcpy (va_mods: va_mods_t) (dst src: buffer64) : (va_quickCode unit (va_code_InnerMemcpy ())) =
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 38 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdx) 0 Secret src 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 39 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) 8 Secret src 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 40 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rRax) 0 Secret dst 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 41 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rR9) 8 Secret dst 1) (fun (va_s: va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 42 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (FStar.Seq.Base.equal #(Vale.X64.Memory.base_typ_as_vale_type Vale.X64.Memory.vuint64 ) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_s) dst) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_s) src)) (va_QEmpty (()))))))))
false
Vale.Test.X64.Vale_memcpy.fst
Vale.Test.X64.Vale_memcpy.va_codegen_success_Memcpy
val va_codegen_success_Memcpy : win:bool -> Tot va_pbool
val va_codegen_success_Memcpy : win:bool -> Tot va_pbool
let va_codegen_success_Memcpy win = (va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if win then va_pbool_and (va_codegen_success_InnerMemcpy ()) (va_ttrue ()) else va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (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 rRdi) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_ttrue ()))))))) (va_pbool_and (va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
{ "file_name": "obj/Vale.Test.X64.Vale_memcpy.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 10, "end_line": 167, "start_col": 0, "start_line": 155 }
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] 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 ()))))) [@ "opaque_to_smt" va_qattr] let va_qcode_InnerMemcpy (va_mods:va_mods_t) (dst:buffer64) (src:buffer64) : (va_quickCode unit (va_code_InnerMemcpy ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 38 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdx) 0 Secret src 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 39 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) 8 Secret src 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 40 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rRax) 0 Secret dst 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 41 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rR9) 8 Secret dst 1) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 42 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (FStar.Seq.Base.equal #(Vale.X64.Memory.base_typ_as_vale_type Vale.X64.Memory.vuint64) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_s) dst) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_s) src)) (va_QEmpty (())))))))) val va_lemma_InnerMemcpy : va_b0:va_code -> va_s0:va_state -> dst:buffer64 -> src:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_InnerMemcpy ()) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) src 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRcx va_s0) dst 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 src == 2 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 dst == 2)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src /\ Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))) [@"opaque_to_smt"] let va_lemma_InnerMemcpy va_b0 va_s0 dst src = let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_InnerMemcpy va_mods dst src in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_InnerMemcpy ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 21 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 35 column 63 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 36 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_InnerMemcpy (dst:buffer64) (src:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) src 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRcx va_s0) dst 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 src == 2 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 dst == 2 /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rcx:nat64) (va_x_r9:nat64) (va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM /\ Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src /\ Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) ==> va_k va_sM (()))) val va_wpProof_InnerMemcpy : dst:buffer64 -> src:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_InnerMemcpy dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_InnerMemcpy ()) ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_InnerMemcpy dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_InnerMemcpy (va_code_InnerMemcpy ()) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))); va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_InnerMemcpy (dst:buffer64) (src:buffer64) : (va_quickCode unit (va_code_InnerMemcpy ())) = (va_QProc (va_code_InnerMemcpy ()) ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_InnerMemcpy dst src) (va_wpProof_InnerMemcpy dst src)) //-- //-- Memcpy [@ "opaque_to_smt" va_qattr] let va_code_Memcpy win = (va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if win then va_Block (va_CCons (va_code_InnerMemcpy ()) (va_CNil ())) else va_Block (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (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 rRdi) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_CNil ())))))))) (va_CCons (va_code_DestroyHeaplets ()) (va_CNil ())))))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
win: Prims.bool -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Prims.bool", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsMem.va_codegen_success_CreateHeaplets", "Vale.Test.X64.Vale_memcpy.va_codegen_success_InnerMemcpy", "Vale.X64.Decls.va_ttrue", "Vale.X64.InsMem.va_codegen_success_Mem64_lemma", "Vale.X64.InsBasic.va_codegen_success_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRax", "Vale.X64.Decls.va_opr_code_Mem64", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_reg64_reg64", "Vale.X64.Machine_s.rRsi", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Machine_s.rRcx", "Vale.X64.InsMem.va_codegen_success_Store64_buffer", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdi", "Vale.X64.Decls.va_pbool", "Vale.X64.InsMem.va_codegen_success_DestroyHeaplets" ]
[]
false
false
false
true
false
let va_codegen_success_Memcpy win =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if win then va_pbool_and (va_codegen_success_InnerMemcpy ()) (va_ttrue ()) else va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (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 rRdi) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_ttrue ()))))))) (va_pbool_and (va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
false
Hacl.Bignum.AlmostMontExponentiation.fst
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st
val bn_exp_almost_mont_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
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)))
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 214, "start_col": 0, "start_line": 197 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
Prims.Tot
[ "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" ]
[]
false
false
false
false
true
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)))
false
Vale.Test.X64.Vale_memcpy.fst
Vale.Test.X64.Vale_memcpy.va_code_Memcpy
val va_code_Memcpy : win:bool -> Tot va_code
val va_code_Memcpy : win:bool -> Tot va_code
let va_code_Memcpy win = (va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if win then va_Block (va_CCons (va_code_InnerMemcpy ()) (va_CNil ())) else va_Block (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (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 rRdi) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_CNil ())))))))) (va_CCons (va_code_DestroyHeaplets ()) (va_CNil ())))))
{ "file_name": "obj/Vale.Test.X64.Vale_memcpy.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 87, "end_line": 152, "start_col": 0, "start_line": 142 }
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] 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 ()))))) [@ "opaque_to_smt" va_qattr] let va_qcode_InnerMemcpy (va_mods:va_mods_t) (dst:buffer64) (src:buffer64) : (va_quickCode unit (va_code_InnerMemcpy ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 38 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdx) 0 Secret src 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 39 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) 8 Secret src 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 40 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rRax) 0 Secret dst 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 41 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rR9) 8 Secret dst 1) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 42 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (FStar.Seq.Base.equal #(Vale.X64.Memory.base_typ_as_vale_type Vale.X64.Memory.vuint64) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_s) dst) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_s) src)) (va_QEmpty (())))))))) val va_lemma_InnerMemcpy : va_b0:va_code -> va_s0:va_state -> dst:buffer64 -> src:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_InnerMemcpy ()) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) src 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRcx va_s0) dst 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 src == 2 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 dst == 2)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src /\ Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))) [@"opaque_to_smt"] let va_lemma_InnerMemcpy va_b0 va_s0 dst src = let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_InnerMemcpy va_mods dst src in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_InnerMemcpy ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 21 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 35 column 63 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 36 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_InnerMemcpy (dst:buffer64) (src:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) src 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRcx va_s0) dst 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 src == 2 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 dst == 2 /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rcx:nat64) (va_x_r9:nat64) (va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM /\ Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src /\ Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) ==> va_k va_sM (()))) val va_wpProof_InnerMemcpy : dst:buffer64 -> src:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_InnerMemcpy dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_InnerMemcpy ()) ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_InnerMemcpy dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_InnerMemcpy (va_code_InnerMemcpy ()) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))); va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_InnerMemcpy (dst:buffer64) (src:buffer64) : (va_quickCode unit (va_code_InnerMemcpy ())) = (va_QProc (va_code_InnerMemcpy ()) ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_InnerMemcpy dst src) (va_wpProof_InnerMemcpy dst src)) //-- //-- Memcpy
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
win: Prims.bool -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Prims.bool", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsMem.va_code_CreateHeaplets", "Vale.Test.X64.Vale_memcpy.va_code_InnerMemcpy", "Vale.X64.Decls.va_CNil", "Vale.X64.InsMem.va_code_Mem64_lemma", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRax", "Vale.X64.Decls.va_opr_code_Mem64", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_reg64_reg64", "Vale.X64.Machine_s.rRsi", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Machine_s.rRcx", "Vale.X64.InsMem.va_code_Store64_buffer", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdi", "Vale.X64.Decls.va_code", "Vale.X64.InsMem.va_code_DestroyHeaplets" ]
[]
false
false
false
true
false
let va_code_Memcpy win =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if win then va_Block (va_CCons (va_code_InnerMemcpy ()) (va_CNil ())) else va_Block (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (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 rRdi) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_CNil ())))))))) (va_CCons (va_code_DestroyHeaplets ()) (va_CNil ())))))
false
Hacl.Bignum.AlmostMontExponentiation.fst
Hacl.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid
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)
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) = { 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; }
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 1, "end_line": 69, "start_col": 0, "start_line": 57 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
false
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 }
false
Vale.Test.X64.Vale_memcpy.fst
Vale.Test.X64.Vale_memcpy.va_qcode_Memcpy
val va_qcode_Memcpy (va_mods: va_mods_t) (win: bool) (dst src: buffer64) : (va_quickCode unit (va_code_Memcpy win))
val va_qcode_Memcpy (va_mods: va_mods_t) (win: bool) (dst src: buffer64) : (va_quickCode unit (va_code_Memcpy win))
let va_qcode_Memcpy (va_mods:va_mods_t) (win:bool) (dst:buffer64) (src:buffer64) : (va_quickCode unit (va_code_Memcpy win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 67 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_CreateHeaplets ([declare_buffer64 src 0 Secret Immutable; declare_buffer64 dst 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 71 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_InnerMemcpy dst src) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 src 0 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 src 1 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRax) 0 Secret dst 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRcx) 8 Secret dst 1) (va_QEmpty (())))))))))) (fun (va_s:va_state) va_g -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 82 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (FStar.Seq.Base.equal #(Vale.X64.Memory.base_typ_as_vale_type Vale.X64.Memory.vuint64) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_s) dst) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_s) src)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 84 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_DestroyHeaplets ()) (va_QEmpty (())))))))
{ "file_name": "obj/Vale.Test.X64.Vale_memcpy.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 206, "start_col": 0, "start_line": 170 }
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] 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 ()))))) [@ "opaque_to_smt" va_qattr] let va_qcode_InnerMemcpy (va_mods:va_mods_t) (dst:buffer64) (src:buffer64) : (va_quickCode unit (va_code_InnerMemcpy ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 38 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdx) 0 Secret src 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 39 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) 8 Secret src 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 40 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rRax) 0 Secret dst 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 41 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_reg_opr64_reg64 rR9) 8 Secret dst 1) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 42 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (FStar.Seq.Base.equal #(Vale.X64.Memory.base_typ_as_vale_type Vale.X64.Memory.vuint64) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_s) dst) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_s) src)) (va_QEmpty (())))))))) val va_lemma_InnerMemcpy : va_b0:va_code -> va_s0:va_state -> dst:buffer64 -> src:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_InnerMemcpy ()) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) src 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRcx va_s0) dst 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 src == 2 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 dst == 2)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src /\ Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))) [@"opaque_to_smt"] let va_lemma_InnerMemcpy va_b0 va_s0 dst src = let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_InnerMemcpy va_mods dst src in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_InnerMemcpy ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 21 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 35 column 63 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 36 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_InnerMemcpy (dst:buffer64) (src:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) src 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRcx va_s0) dst 2 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 src == 2 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint64 dst == 2 /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rcx:nat64) (va_x_r9:nat64) (va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM /\ Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_sM) dst == Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_sM) src /\ Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint64 dst) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) ==> va_k va_sM (()))) val va_wpProof_InnerMemcpy : dst:buffer64 -> src:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_InnerMemcpy dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_InnerMemcpy ()) ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_InnerMemcpy dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_InnerMemcpy (va_code_InnerMemcpy ()) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))); va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_InnerMemcpy (dst:buffer64) (src:buffer64) : (va_quickCode unit (va_code_InnerMemcpy ())) = (va_QProc (va_code_InnerMemcpy ()) ([va_Mod_mem_heaplet 1; va_Mod_reg64 rR9; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_InnerMemcpy dst src) (va_wpProof_InnerMemcpy dst src)) //-- //-- Memcpy [@ "opaque_to_smt" va_qattr] let va_code_Memcpy win = (va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if win then va_Block (va_CCons (va_code_InnerMemcpy ()) (va_CNil ())) else va_Block (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (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 rRdi) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_CNil ())))))))) (va_CCons (va_code_DestroyHeaplets ()) (va_CNil ()))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Memcpy win = (va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if win then va_pbool_and (va_codegen_success_InnerMemcpy ()) (va_ttrue ()) else va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (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 rRdi) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_ttrue ()))))))) (va_pbool_and (va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
va_mods: Vale.X64.QuickCode.va_mods_t -> win: Prims.bool -> dst: Vale.X64.Memory.buffer64 -> src: Vale.X64.Memory.buffer64 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.Test.X64.Vale_memcpy.va_code_Memcpy win)
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.QuickCode.va_mods_t", "Prims.bool", "Vale.X64.Memory.buffer64", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsMem.va_code_CreateHeaplets", "Vale.X64.QuickCodes.if_code", "Vale.X64.QuickCodes.block", "Vale.Test.X64.Vale_memcpy.va_code_InnerMemcpy", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.InsMem.va_code_Mem64_lemma", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRax", "Vale.X64.Decls.va_opr_code_Mem64", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_reg64_reg64", "Vale.X64.Machine_s.rRsi", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Machine_s.rRcx", "Vale.X64.InsMem.va_code_Store64_buffer", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdi", "Vale.X64.InsMem.va_code_DestroyHeaplets", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.QuickCodes.va_range1", "Vale.X64.InsMem.va_quick_CreateHeaplets", "Vale.Arch.HeapImpl.buffer_info", "Vale.X64.InsMem.declare_buffer64", "Vale.Arch.HeapImpl.Immutable", "Vale.Arch.HeapImpl.Mutable", "Vale.X64.QuickCodes.va_qInlineIf", "Vale.X64.QuickCodes.va_QSeq", "Vale.Test.X64.Vale_memcpy.va_quick_InnerMemcpy", "Vale.X64.QuickCodes.va_QEmpty", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.InsMem.va_quick_Mem64_lemma", "Vale.X64.InsBasic.va_quick_Mov64", "Vale.X64.InsMem.va_quick_Store64_buffer", "Vale.X64.QuickCodes.va_qAssert", "FStar.Seq.Base.equal", "Vale.X64.Memory.base_typ_as_vale_type", "Vale.X64.Memory.vuint64", "Vale.X64.Memory.buffer_as_seq", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.InsMem.va_quick_DestroyHeaplets", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.Test.X64.Vale_memcpy.va_code_Memcpy" ]
[]
false
false
false
false
false
let va_qcode_Memcpy (va_mods: va_mods_t) (win: bool) (dst src: buffer64) : (va_quickCode unit (va_code_Memcpy win)) =
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 67 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_CreateHeaplets ([ declare_buffer64 src 0 Secret Immutable; declare_buffer64 dst 1 Secret Mutable ])) (fun (va_s: va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 71 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s: va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_InnerMemcpy dst src) (va_QEmpty (())))) (qblock va_mods (fun (va_s: va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 src 0 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 src 1 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 79 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRax) 0 Secret dst 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 80 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRcx) 8 Secret dst 1) (va_QEmpty (())))))))))) (fun (va_s: va_state) va_g -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 82 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (FStar.Seq.Base.equal #(Vale.X64.Memory.base_typ_as_vale_type Vale.X64.Memory.vuint64 ) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 1 va_s) dst) (Vale.X64.Memory.buffer_as_seq #Vale.X64.Memory.vuint64 (va_get_mem_heaplet 0 va_s) src)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 84 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/test/Vale.Test.X64.Vale_memcpy.vaf *****" (va_quick_DestroyHeaplets ()) (va_QEmpty (())))))))
false
FStar.IntegerIntervals.fst
FStar.IntegerIntervals.interval_condition
val interval_condition : x: Prims.int -> y: Prims.int -> t: Prims.int -> Prims.bool
let interval_condition (x y t: int) = (x <= t) && (t < y)
{ "file_name": "ulib/FStar.IntegerIntervals.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 33, "start_col": 0, "start_line": 33 }
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: A. Rozanov *) module FStar.IntegerIntervals (* Aliases to all kinds of integer intervals *) (* general infinite integer intervals *) type less_than (k: int) = x:int{x<k} type greater_than (k: int) = x:int{x>k} type not_less_than (x: int) = greater_than (x-1) type not_greater_than (x: int) = less_than (x+1) (* Type coercion. While supposed to be absolutely trivial, might still be invoked directly under extremely low rlimits *) let coerce_to_less_than #n (x: not_greater_than n) : less_than (n+1) = x let coerce_to_not_less_than #n (x: greater_than n) : not_less_than (n+1) = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.IntegerIntervals.fst" }
[ { "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 } ]
{ "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" }
false
x: Prims.int -> y: Prims.int -> t: Prims.int -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.bool" ]
[]
false
false
false
true
false
let interval_condition (x y t: int) =
(x <= t) && (t < y)
false
FStar.IntegerIntervals.fst
FStar.IntegerIntervals.coerce_to_less_than
val coerce_to_less_than (#n: _) (x: not_greater_than n) : less_than (n + 1)
val coerce_to_less_than (#n: _) (x: not_greater_than n) : less_than (n + 1)
let coerce_to_less_than #n (x: not_greater_than n) : less_than (n+1) = x
{ "file_name": "ulib/FStar.IntegerIntervals.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 72, "end_line": 30, "start_col": 0, "start_line": 30 }
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: A. Rozanov *) module FStar.IntegerIntervals (* Aliases to all kinds of integer intervals *) (* general infinite integer intervals *) type less_than (k: int) = x:int{x<k} type greater_than (k: int) = x:int{x>k} type not_less_than (x: int) = greater_than (x-1) type not_greater_than (x: int) = less_than (x+1) (* Type coercion. While supposed to be absolutely trivial,
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.IntegerIntervals.fst" }
[ { "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 } ]
{ "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" }
false
x: FStar.IntegerIntervals.not_greater_than n -> FStar.IntegerIntervals.less_than (n + 1)
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "FStar.IntegerIntervals.not_greater_than", "FStar.IntegerIntervals.less_than", "Prims.op_Addition" ]
[]
false
false
false
false
false
let coerce_to_less_than #n (x: not_greater_than n) : less_than (n + 1) =
x
false
FStar.IntegerIntervals.fst
FStar.IntegerIntervals.closed_interval_size
val closed_interval_size (x y: int) : nat
val closed_interval_size (x y: int) : nat
let closed_interval_size (x y: int) : nat = interval_size (ifrom_ito x y)
{ "file_name": "ulib/FStar.IntegerIntervals.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 73, "end_line": 61, "start_col": 0, "start_line": 61 }
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: A. Rozanov *) module FStar.IntegerIntervals (* Aliases to all kinds of integer intervals *) (* general infinite integer intervals *) type less_than (k: int) = x:int{x<k} type greater_than (k: int) = x:int{x>k} type not_less_than (x: int) = greater_than (x-1) type not_greater_than (x: int) = less_than (x+1) (* Type coercion. While supposed to be absolutely trivial, might still be invoked directly under extremely low rlimits *) let coerce_to_less_than #n (x: not_greater_than n) : less_than (n+1) = x let coerce_to_not_less_than #n (x: greater_than n) : not_less_than (n+1) = x let interval_condition (x y t: int) = (x <= t) && (t < y) type interval_type (x y:int) = z : Type0{ z == t:int{interval_condition x y t} } (* Default interval is half-open, which is the most frequently used case *) type interval (x y: int) : interval_type x y = t:int{interval_condition x y t} (* general finite integer intervals *) type efrom_eto (x y: int) = interval (x+1) y type efrom_ito (x y: int) = interval (x+1) (y+1) type ifrom_eto (x y: int) = interval x y type ifrom_ito (x y: int) = interval x (y+1) (* Special case for naturals under k, to use in sequences, lists, arrays, etc *) type under (k: nat) = interval 0 k (* If we define our intervals this way, then the following lemma comes for free: *) private let closed_interval_lemma (x y:int) : Lemma (interval x (y+1) == ifrom_ito x y) = () (* how many numbers fall into an interval? *) let interval_size (#x #y: int) (interval: interval_type x y) : nat = if y >= x then y-x else 0 (* when we want a zero-based index that runs over an interval, we use this *) type counter_for (#x #y:int) (interval: interval_type x y) = under (interval_size interval)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.IntegerIntervals.fst" }
[ { "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 } ]
{ "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" }
false
x: Prims.int -> y: Prims.int -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "FStar.IntegerIntervals.interval_size", "Prims.op_Addition", "FStar.IntegerIntervals.ifrom_ito", "Prims.nat" ]
[]
false
false
false
true
false
let closed_interval_size (x y: int) : nat =
interval_size (ifrom_ito x y)
false
Hacl.Bignum.AlmostMontExponentiation.fst
Hacl.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops
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)
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) = { 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; }
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 1, "end_line": 146, "start_col": 0, "start_line": 135 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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))
Prims.Tot
[ "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" ]
[]
false
false
false
false
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 }
false
Hacl.Bignum.AlmostMontExponentiation.fst
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_vartime
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
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
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 63, "end_line": 309, "start_col": 0, "start_line": 305 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t (Mkbn?.len (Mkalmost_mont?.bn k))
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Spec.Agile.HKDF.fsti
Spec.Agile.HKDF.expand_output_length_pred
val expand_output_length_pred : a: Spec.Hash.Definitions.fixed_len_alg -> len: Prims.nat -> Prims.bool
let expand_output_length_pred (a:fixed_len_alg) (len:nat) = len <= 255 * hash_length a
{ "file_name": "specs/Spec.Agile.HKDF.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 25, "start_col": 0, "start_line": 24 }
module Spec.Agile.HKDF open FStar.Mul open Spec.Hash.Definitions let lbytes (l:nat) = b:bytes {Seq.length b = l} let extract_ikm_length_pred (a:hash_alg) (ikm_length:nat) = (ikm_length + block_length a) `less_than_max_input_length` a val extract: a: fixed_len_alg -> key: bytes -> data: bytes -> Pure (lbytes (hash_length a)) (requires Spec.Agile.HMAC.keysized a (Seq.length key) /\ extract_ikm_length_pred a (Seq.length data)) (ensures fun _ -> True) let expand_info_length_pred (a:fixed_len_alg) (info_length:nat) = (hash_length a + info_length + 1 + block_length a) `less_than_max_input_length` a
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.HKDF.fsti" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.fixed_len_alg -> len: Prims.nat -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.fixed_len_alg", "Prims.nat", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Spec.Hash.Definitions.hash_length", "Prims.bool" ]
[]
false
false
false
true
false
let expand_output_length_pred (a: fixed_len_alg) (len: nat) =
len <= 255 * hash_length a
false
Hacl.Bignum.AlmostMontExponentiation.fst
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_pre
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
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
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 193, "start_col": 0, "start_line": 180 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
false
true
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))) =
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
false
Spec.Agile.HKDF.fsti
Spec.Agile.HKDF.expand_info_length_pred
val expand_info_length_pred : a: Spec.Hash.Definitions.fixed_len_alg -> info_length: Prims.nat -> Prims.bool
let expand_info_length_pred (a:fixed_len_alg) (info_length:nat) = (hash_length a + info_length + 1 + block_length a) `less_than_max_input_length` a
{ "file_name": "specs/Spec.Agile.HKDF.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 83, "end_line": 22, "start_col": 0, "start_line": 21 }
module Spec.Agile.HKDF open FStar.Mul open Spec.Hash.Definitions let lbytes (l:nat) = b:bytes {Seq.length b = l} let extract_ikm_length_pred (a:hash_alg) (ikm_length:nat) = (ikm_length + block_length a) `less_than_max_input_length` a val extract: a: fixed_len_alg -> key: bytes -> data: bytes -> Pure (lbytes (hash_length a)) (requires Spec.Agile.HMAC.keysized a (Seq.length key) /\ extract_ikm_length_pred a (Seq.length data)) (ensures fun _ -> True)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.HKDF.fsti" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.fixed_len_alg -> info_length: Prims.nat -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.fixed_len_alg", "Prims.nat", "Spec.Hash.Definitions.less_than_max_input_length", "Prims.op_Addition", "Spec.Hash.Definitions.hash_length", "Spec.Hash.Definitions.block_length", "Prims.bool" ]
[]
false
false
false
true
false
let expand_info_length_pred (a: fixed_len_alg) (info_length: nat) =
(hash_length a + info_length + 1 + block_length a) `less_than_max_input_length` a
false
FStar.IntegerIntervals.fst
FStar.IntegerIntervals.coerce_to_not_less_than
val coerce_to_not_less_than (#n: _) (x: greater_than n) : not_less_than (n + 1)
val coerce_to_not_less_than (#n: _) (x: greater_than n) : not_less_than (n + 1)
let coerce_to_not_less_than #n (x: greater_than n) : not_less_than (n+1) = x
{ "file_name": "ulib/FStar.IntegerIntervals.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 76, "end_line": 31, "start_col": 0, "start_line": 31 }
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: A. Rozanov *) module FStar.IntegerIntervals (* Aliases to all kinds of integer intervals *) (* general infinite integer intervals *) type less_than (k: int) = x:int{x<k} type greater_than (k: int) = x:int{x>k} type not_less_than (x: int) = greater_than (x-1) type not_greater_than (x: int) = less_than (x+1) (* Type coercion. While supposed to be absolutely trivial, might still be invoked directly under extremely low rlimits *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.IntegerIntervals.fst" }
[ { "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 } ]
{ "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" }
false
x: FStar.IntegerIntervals.greater_than n -> FStar.IntegerIntervals.not_less_than (n + 1)
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "FStar.IntegerIntervals.greater_than", "FStar.IntegerIntervals.not_less_than", "Prims.op_Addition" ]
[]
false
false
false
false
false
let coerce_to_not_less_than #n (x: greater_than n) : not_less_than (n + 1) =
x
false
Hacl.Bignum.AlmostMontExponentiation.fst
Hacl.Bignum.AlmostMontExponentiation.linv_ctx
val linv_ctx (#t: limb_t) (#len: SN.bn_len t) (n: BD.lbignum t len) (ctx: BD.lbignum t (len + len)) : Type0
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 = 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
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 71, "end_line": 53, "start_col": 0, "start_line": 49 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> ctx: Hacl.Spec.Bignum.Definitions.lbignum t (len + len) -> Type0
Prims.Tot
[ "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" ]
[]
false
false
false
false
true
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
false
FStar.IntegerIntervals.fst
FStar.IntegerIntervals.interval_size
val interval_size (#x #y: int) (interval: interval_type x y) : nat
val interval_size (#x #y: int) (interval: interval_type x y) : nat
let interval_size (#x #y: int) (interval: interval_type x y) : nat = if y >= x then y-x else 0
{ "file_name": "ulib/FStar.IntegerIntervals.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 55, "start_col": 0, "start_line": 54 }
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Author: A. Rozanov *) module FStar.IntegerIntervals (* Aliases to all kinds of integer intervals *) (* general infinite integer intervals *) type less_than (k: int) = x:int{x<k} type greater_than (k: int) = x:int{x>k} type not_less_than (x: int) = greater_than (x-1) type not_greater_than (x: int) = less_than (x+1) (* Type coercion. While supposed to be absolutely trivial, might still be invoked directly under extremely low rlimits *) let coerce_to_less_than #n (x: not_greater_than n) : less_than (n+1) = x let coerce_to_not_less_than #n (x: greater_than n) : not_less_than (n+1) = x let interval_condition (x y t: int) = (x <= t) && (t < y) type interval_type (x y:int) = z : Type0{ z == t:int{interval_condition x y t} } (* Default interval is half-open, which is the most frequently used case *) type interval (x y: int) : interval_type x y = t:int{interval_condition x y t} (* general finite integer intervals *) type efrom_eto (x y: int) = interval (x+1) y type efrom_ito (x y: int) = interval (x+1) (y+1) type ifrom_eto (x y: int) = interval x y type ifrom_ito (x y: int) = interval x (y+1) (* Special case for naturals under k, to use in sequences, lists, arrays, etc *) type under (k: nat) = interval 0 k (* If we define our intervals this way, then the following lemma comes for free: *) private let closed_interval_lemma (x y:int) : Lemma (interval x (y+1) == ifrom_ito x y) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.IntegerIntervals.fst" }
[ { "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 } ]
{ "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" }
false
interval: FStar.IntegerIntervals.interval_type x y -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "FStar.IntegerIntervals.interval_type", "Prims.op_GreaterThanOrEqual", "Prims.op_Subtraction", "Prims.bool", "Prims.nat" ]
[]
false
false
false
false
false
let interval_size (#x #y: int) (interval: interval_type x y) : nat =
if y >= x then y - x else 0
false
Spec.Agile.HKDF.fsti
Spec.Agile.HKDF.extract_ikm_length_pred
val extract_ikm_length_pred : a: Spec.Hash.Definitions.hash_alg -> ikm_length: Prims.nat -> Prims.bool
let extract_ikm_length_pred (a:hash_alg) (ikm_length:nat) = (ikm_length + block_length a) `less_than_max_input_length` a
{ "file_name": "specs/Spec.Agile.HKDF.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 9, "start_col": 0, "start_line": 8 }
module Spec.Agile.HKDF open FStar.Mul open Spec.Hash.Definitions let lbytes (l:nat) = b:bytes {Seq.length b = l}
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.HKDF.fsti" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.hash_alg -> ikm_length: Prims.nat -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.hash_alg", "Prims.nat", "Spec.Hash.Definitions.less_than_max_input_length", "Prims.op_Addition", "Spec.Hash.Definitions.block_length", "Prims.bool" ]
[]
false
false
false
true
false
let extract_ikm_length_pred (a: hash_alg) (ikm_length: nat) =
(ikm_length + block_length a) `less_than_max_input_length` a
false
Hacl.Bignum.AlmostMontExponentiation.fst
Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_consttime
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
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 = 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
{ "file_name": "code/bignum/Hacl.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 319, "start_col": 0, "start_line": 315 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
k: Hacl.Bignum.AlmostMontgomery.almost_mont t -> Hacl.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t (Mkbn?.len (Mkalmost_mont?.bn k))
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false