effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FStar.Pervasives.Lemma | val create8_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a ->
Lemma (let s = create8 x0 x1 x2 x3 x4 x5 x6 x7 in
s.[0] == x0 /\ s.[1] == x1 /\ s.[2] == x2 /\ s.[3] == x3 /\
s.[4] == x4 /\ s.[5] == x5 /\ s.[6] == x6 /\ s.[7] == x7)
[SMTPat (create8 #a x0 x1 x2 x3 x4 x5 x6 x7)] | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let create8_lemma #a x0 x1 x2 x3 x4 x5 x6 x7 =
Seq.elim_of_list [x0; x1; x2; x3; x4; x5; x6; x7] | val create8_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a ->
Lemma (let s = create8 x0 x1 x2 x3 x4 x5 x6 x7 in
s.[0] == x0 /\ s.[1] == x1 /\ s.[2] == x2 /\ s.[3] == x3 /\
s.[4] == x4 /\ s.[5] == x5 /\ s.[6] == x6 /\ s.[7] == x7)
[SMTPat (create8 #a x0 x1 x2 x3 x4 x5 x6 x7)]
let create8_lemma #a x0 x1 x2 x3 x4 x5 x6 x7 = | false | null | true | Seq.elim_of_list [x0; x1; x2; x3; x4; x5; x6; x7] | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"lemma"
] | [
"FStar.Seq.Properties.elim_of_list",
"Prims.Cons",
"Prims.Nil",
"Prims.unit"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc
let repeati_blocks #a #b bs inp f g init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeati_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
g nb rem last acc
let repeat_blocks #a #b #c bs inp f l init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeat_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
l rem last acc
let lemma_repeat_blocks #a #b #c bs inp f l init = ()
let repeat_blocks_multi #a #b bs inp f init =
let len = length inp in
let nb = len / bs in
repeati nb (repeat_blocks_f bs inp f nb) init
let lemma_repeat_blocks_multi #a #b bs inp f init = ()
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
let acc, o = acc in
let acc', block = f i acc in
let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in
acc', o'
let generate_blocks #t len max n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1)
=
Seq.append acc (f i)
let generate_blocks_simple #a bs max nb f =
repeat_gen nb (generate_blocks_simple_a a bs max)
(generate_blocks_simple_f #a bs max f) Seq.empty
#restart-solver
let div_interval b n i =
Math.Lemmas.lemma_div_le (n * b) i b;
Math.Lemmas.cancel_mul_div n b
let mod_interval_lt b n i j =
div_interval b n i;
div_interval b n j
let div_mul_lt b a n = ()
let mod_div_lt b i j =
mod_interval_lt b (j / b) i j
let div_mul_l a b c d =
calc (==) {
a / (c * d);
== { }
a / (d * c);
== { Math.Lemmas.division_multiplication_lemma a d c }
(a / d) / c;
== { }
(b / d) / c;
== { Math.Lemmas.division_multiplication_lemma b d c }
b / (d * c);
== { }
b / (c * d);
}
let map_blocks_multi #a bs max nb inp f =
repeat_gen nb (map_blocks_a a bs max)
(map_blocks_f #a bs max inp f) Seq.empty
let lemma_map_blocks_multi #a bs max nb inp f = ()
private
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} ->
Lemma (b - a * n == b % n)
let mod_prop n a b =
Math.Lemmas.modulo_lemma (b - a * n) n;
Math.Lemmas.lemma_mod_sub b n a
#push-options "--z3rlimit 200"
let rec index_map_blocks_multi #a bs max n inp f i =
let map_blocks_a = map_blocks_a a bs max in
let map_blocks_f = map_blocks_f #a bs max inp f in
let acc0 = Seq.empty #a in
let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in
unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1);
let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in
//assert (s1 == map_blocks_f (n-1) s);
let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in
//assert (s1 == Seq.append s s');
if i < (n-1)*bs then begin
Seq.lemma_index_app1 s s' i;
index_map_blocks_multi #a bs max (n-1) inp f i end
else begin
Seq.lemma_index_app2 s s' i;
mod_prop bs (n-1) i
end
let map_blocks #a blocksize inp f g =
let len = length inp in
let nb = len / blocksize in
let rem = len % blocksize in
let blocks = Seq.slice inp 0 (nb * blocksize) in
let last = Seq.slice inp (nb * blocksize) len in
let bs = map_blocks_multi #a blocksize nb nb blocks f in
if (rem > 0) then
Seq.append bs (g nb rem last)
else bs
let lemma_map_blocks #a blocksize inp f g = ()
let index_map_blocks #a bs inp f g i =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let blocks = Seq.slice inp 0 (nb * bs) in
if rem > 0 then
begin
let s1 = map_blocks_multi #a bs nb nb blocks f in
let last = Seq.slice inp (nb * bs) len in
calc (==) {
length last;
== { Seq.lemma_len_slice inp (nb * bs) len }
len - nb * bs;
== {mod_prop bs nb len}
len % bs;
== { }
rem;
};
let s2 = g nb rem last in
assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2));
if i < nb * bs then
begin
div_mul_lt bs i nb;
Seq.lemma_index_app1 s1 s2 i;
index_map_blocks_multi bs nb nb blocks f i
end
else
begin
Seq.lemma_index_app2 s1 s2 i;
mod_prop bs nb i
end
end
else index_map_blocks_multi #a bs nb nb blocks f i
let eq_generate_blocks0 #t len n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
assert (generate_blocks #t len n 0 a f acc0 ==
repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0
let unfold_generate_blocks #t len n a f acc0 i =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
assert (generate_blocks #t len n (i+1) a f acc0 ==
repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
unfold_repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 i
let rec index_generate_blocks #t len max n f i =
assert (0 < n);
let a_spec (i:nat{i <= max}) = unit in
let _,s = generate_blocks #t len max (n-1) a_spec f () in
let _,s' = f (n-1) () in
let _,s1 = generate_blocks #t len max n a_spec f () in
unfold_generate_blocks #t len max a_spec f () (n-1);
Seq.Properties.lemma_split s1 (n * len - len);
Seq.Properties.lemma_split (Seq.append s s') (n * len - len);
Seq.lemma_eq_intro s1 (Seq.append s s');
if i < (n-1) * len then
begin
Seq.lemma_index_app1 s s' i;
index_generate_blocks len max (n-1) f i
end
else
begin
Seq.lemma_index_app2 s s' i;
mod_prop len (n-1) i
end
#push-options "--using_facts_from '+FStar.UInt.pow2_values'"
let create2 #a x0 x1 =
let l = [x0; x1] in
assert_norm (List.Tot.length l = 2);
createL l
let create2_lemma #a x0 x1 =
Seq.elim_of_list [x0; x1]
let create4 #a x0 x1 x2 x3 =
let l = [x0; x1; x2; x3] in
assert_norm (List.Tot.length l = 4);
createL l
let create4_lemma #a x0 x1 x2 x3 =
Seq.elim_of_list [x0; x1; x2; x3]
let create8 #a x0 x1 x2 x3 x4 x5 x6 x7 =
let l = [x0; x1; x2; x3; x4; x5; x6; x7] in
assert_norm (List.Tot.length l = 8);
createL l | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val create8_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a ->
Lemma (let s = create8 x0 x1 x2 x3 x4 x5 x6 x7 in
s.[0] == x0 /\ s.[1] == x1 /\ s.[2] == x2 /\ s.[3] == x3 /\
s.[4] == x4 /\ s.[5] == x5 /\ s.[6] == x6 /\ s.[7] == x7)
[SMTPat (create8 #a x0 x1 x2 x3 x4 x5 x6 x7)] | [] | Lib.Sequence.create8_lemma | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x0: a -> x1: a -> x2: a -> x3: a -> x4: a -> x5: a -> x6: a -> x7: a
-> FStar.Pervasives.Lemma
(ensures
(let s = Lib.Sequence.create8 x0 x1 x2 x3 x4 x5 x6 x7 in
s.[ 0 ] == x0 /\ s.[ 1 ] == x1 /\ s.[ 2 ] == x2 /\ s.[ 3 ] == x3 /\ s.[ 4 ] == x4 /\
s.[ 5 ] == x5 /\ s.[ 6 ] == x6 /\ s.[ 7 ] == x7))
[SMTPat (Lib.Sequence.create8 x0 x1 x2 x3 x4 x5 x6 x7)] | {
"end_col": 51,
"end_line": 393,
"start_col": 2,
"start_line": 393
} |
FStar.Pervasives.Lemma | val create16_lemma: #a:Type
-> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a
-> x8:a -> x9:a -> x10:a -> x11:a -> x12:a -> x13:a -> x14:a -> x15:a ->
Lemma (let s = create16 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 in
s.[0] == x0 /\ s.[1] == x1 /\ s.[2] == x2 /\ s.[3] == x3 /\
s.[4] == x4 /\ s.[5] == x5 /\ s.[6] == x6 /\ s.[7] == x7 /\
s.[8] == x8 /\ s.[9] == x9 /\ s.[10] == x10 /\ s.[11] == x11 /\
s.[12] == x12 /\ s.[13] == x13 /\ s.[14] == x14 /\ s.[15] == x15)
[SMTPat (create16 #a x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15)] | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let create16_lemma #a x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 =
Seq.elim_of_list [x0; x1; x2; x3; x4; x5; x6; x7; x8; x9; x10; x11; x12; x13; x14; x15] | val create16_lemma: #a:Type
-> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a
-> x8:a -> x9:a -> x10:a -> x11:a -> x12:a -> x13:a -> x14:a -> x15:a ->
Lemma (let s = create16 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 in
s.[0] == x0 /\ s.[1] == x1 /\ s.[2] == x2 /\ s.[3] == x3 /\
s.[4] == x4 /\ s.[5] == x5 /\ s.[6] == x6 /\ s.[7] == x7 /\
s.[8] == x8 /\ s.[9] == x9 /\ s.[10] == x10 /\ s.[11] == x11 /\
s.[12] == x12 /\ s.[13] == x13 /\ s.[14] == x14 /\ s.[15] == x15)
[SMTPat (create16 #a x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15)]
let create16_lemma #a x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 = | false | null | true | Seq.elim_of_list [x0; x1; x2; x3; x4; x5; x6; x7; x8; x9; x10; x11; x12; x13; x14; x15] | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"lemma"
] | [
"FStar.Seq.Properties.elim_of_list",
"Prims.Cons",
"Prims.Nil",
"Prims.unit"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc
let repeati_blocks #a #b bs inp f g init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeati_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
g nb rem last acc
let repeat_blocks #a #b #c bs inp f l init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeat_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
l rem last acc
let lemma_repeat_blocks #a #b #c bs inp f l init = ()
let repeat_blocks_multi #a #b bs inp f init =
let len = length inp in
let nb = len / bs in
repeati nb (repeat_blocks_f bs inp f nb) init
let lemma_repeat_blocks_multi #a #b bs inp f init = ()
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
let acc, o = acc in
let acc', block = f i acc in
let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in
acc', o'
let generate_blocks #t len max n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1)
=
Seq.append acc (f i)
let generate_blocks_simple #a bs max nb f =
repeat_gen nb (generate_blocks_simple_a a bs max)
(generate_blocks_simple_f #a bs max f) Seq.empty
#restart-solver
let div_interval b n i =
Math.Lemmas.lemma_div_le (n * b) i b;
Math.Lemmas.cancel_mul_div n b
let mod_interval_lt b n i j =
div_interval b n i;
div_interval b n j
let div_mul_lt b a n = ()
let mod_div_lt b i j =
mod_interval_lt b (j / b) i j
let div_mul_l a b c d =
calc (==) {
a / (c * d);
== { }
a / (d * c);
== { Math.Lemmas.division_multiplication_lemma a d c }
(a / d) / c;
== { }
(b / d) / c;
== { Math.Lemmas.division_multiplication_lemma b d c }
b / (d * c);
== { }
b / (c * d);
}
let map_blocks_multi #a bs max nb inp f =
repeat_gen nb (map_blocks_a a bs max)
(map_blocks_f #a bs max inp f) Seq.empty
let lemma_map_blocks_multi #a bs max nb inp f = ()
private
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} ->
Lemma (b - a * n == b % n)
let mod_prop n a b =
Math.Lemmas.modulo_lemma (b - a * n) n;
Math.Lemmas.lemma_mod_sub b n a
#push-options "--z3rlimit 200"
let rec index_map_blocks_multi #a bs max n inp f i =
let map_blocks_a = map_blocks_a a bs max in
let map_blocks_f = map_blocks_f #a bs max inp f in
let acc0 = Seq.empty #a in
let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in
unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1);
let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in
//assert (s1 == map_blocks_f (n-1) s);
let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in
//assert (s1 == Seq.append s s');
if i < (n-1)*bs then begin
Seq.lemma_index_app1 s s' i;
index_map_blocks_multi #a bs max (n-1) inp f i end
else begin
Seq.lemma_index_app2 s s' i;
mod_prop bs (n-1) i
end
let map_blocks #a blocksize inp f g =
let len = length inp in
let nb = len / blocksize in
let rem = len % blocksize in
let blocks = Seq.slice inp 0 (nb * blocksize) in
let last = Seq.slice inp (nb * blocksize) len in
let bs = map_blocks_multi #a blocksize nb nb blocks f in
if (rem > 0) then
Seq.append bs (g nb rem last)
else bs
let lemma_map_blocks #a blocksize inp f g = ()
let index_map_blocks #a bs inp f g i =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let blocks = Seq.slice inp 0 (nb * bs) in
if rem > 0 then
begin
let s1 = map_blocks_multi #a bs nb nb blocks f in
let last = Seq.slice inp (nb * bs) len in
calc (==) {
length last;
== { Seq.lemma_len_slice inp (nb * bs) len }
len - nb * bs;
== {mod_prop bs nb len}
len % bs;
== { }
rem;
};
let s2 = g nb rem last in
assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2));
if i < nb * bs then
begin
div_mul_lt bs i nb;
Seq.lemma_index_app1 s1 s2 i;
index_map_blocks_multi bs nb nb blocks f i
end
else
begin
Seq.lemma_index_app2 s1 s2 i;
mod_prop bs nb i
end
end
else index_map_blocks_multi #a bs nb nb blocks f i
let eq_generate_blocks0 #t len n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
assert (generate_blocks #t len n 0 a f acc0 ==
repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0
let unfold_generate_blocks #t len n a f acc0 i =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
assert (generate_blocks #t len n (i+1) a f acc0 ==
repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
unfold_repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 i
let rec index_generate_blocks #t len max n f i =
assert (0 < n);
let a_spec (i:nat{i <= max}) = unit in
let _,s = generate_blocks #t len max (n-1) a_spec f () in
let _,s' = f (n-1) () in
let _,s1 = generate_blocks #t len max n a_spec f () in
unfold_generate_blocks #t len max a_spec f () (n-1);
Seq.Properties.lemma_split s1 (n * len - len);
Seq.Properties.lemma_split (Seq.append s s') (n * len - len);
Seq.lemma_eq_intro s1 (Seq.append s s');
if i < (n-1) * len then
begin
Seq.lemma_index_app1 s s' i;
index_generate_blocks len max (n-1) f i
end
else
begin
Seq.lemma_index_app2 s s' i;
mod_prop len (n-1) i
end
#push-options "--using_facts_from '+FStar.UInt.pow2_values'"
let create2 #a x0 x1 =
let l = [x0; x1] in
assert_norm (List.Tot.length l = 2);
createL l
let create2_lemma #a x0 x1 =
Seq.elim_of_list [x0; x1]
let create4 #a x0 x1 x2 x3 =
let l = [x0; x1; x2; x3] in
assert_norm (List.Tot.length l = 4);
createL l
let create4_lemma #a x0 x1 x2 x3 =
Seq.elim_of_list [x0; x1; x2; x3]
let create8 #a x0 x1 x2 x3 x4 x5 x6 x7 =
let l = [x0; x1; x2; x3; x4; x5; x6; x7] in
assert_norm (List.Tot.length l = 8);
createL l
let create8_lemma #a x0 x1 x2 x3 x4 x5 x6 x7 =
Seq.elim_of_list [x0; x1; x2; x3; x4; x5; x6; x7]
let create16 #a x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 =
let l = [x0; x1; x2; x3; x4; x5; x6; x7; x8; x9; x10; x11; x12; x13; x14; x15] in
assert_norm (List.Tot.length l = 16);
createL l | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val create16_lemma: #a:Type
-> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a
-> x8:a -> x9:a -> x10:a -> x11:a -> x12:a -> x13:a -> x14:a -> x15:a ->
Lemma (let s = create16 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 in
s.[0] == x0 /\ s.[1] == x1 /\ s.[2] == x2 /\ s.[3] == x3 /\
s.[4] == x4 /\ s.[5] == x5 /\ s.[6] == x6 /\ s.[7] == x7 /\
s.[8] == x8 /\ s.[9] == x9 /\ s.[10] == x10 /\ s.[11] == x11 /\
s.[12] == x12 /\ s.[13] == x13 /\ s.[14] == x14 /\ s.[15] == x15)
[SMTPat (create16 #a x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15)] | [] | Lib.Sequence.create16_lemma | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
x0: a ->
x1: a ->
x2: a ->
x3: a ->
x4: a ->
x5: a ->
x6: a ->
x7: a ->
x8: a ->
x9: a ->
x10: a ->
x11: a ->
x12: a ->
x13: a ->
x14: a ->
x15: a
-> FStar.Pervasives.Lemma
(ensures
(let s = Lib.Sequence.create16 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 in
s.[ 0 ] == x0 /\ s.[ 1 ] == x1 /\ s.[ 2 ] == x2 /\ s.[ 3 ] == x3 /\ s.[ 4 ] == x4 /\
s.[ 5 ] == x5 /\ s.[ 6 ] == x6 /\ s.[ 7 ] == x7 /\ s.[ 8 ] == x8 /\ s.[ 9 ] == x9 /\
s.[ 10 ] == x10 /\ s.[ 11 ] == x11 /\ s.[ 12 ] == x12 /\ s.[ 13 ] == x13 /\
s.[ 14 ] == x14 /\ s.[ 15 ] == x15))
[SMTPat (Lib.Sequence.create16 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15)] | {
"end_col": 89,
"end_line": 401,
"start_col": 2,
"start_line": 401
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i] | let map2_inner
(#a #b #c: Type)
(#len: size_nat)
(f: (a -> b -> Tot c))
(s1: lseq a len)
(s2: lseq b len)
(i: size_nat{i < len})
= | false | null | false | f s1.[ i ] s2.[ i ] | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Lib.Sequence.lseq",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.Sequence.op_String_Access"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map2_inner : f: (_: a -> _: b -> c) ->
s1: Lib.Sequence.lseq a len ->
s2: Lib.Sequence.lseq b len ->
i: Lib.IntTypes.size_nat{i < len}
-> c | [] | Lib.Sequence.map2_inner | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f: (_: a -> _: b -> c) ->
s1: Lib.Sequence.lseq a len ->
s2: Lib.Sequence.lseq b len ->
i: Lib.IntTypes.size_nat{i < len}
-> c | {
"end_col": 17,
"end_line": 118,
"start_col": 2,
"start_line": 118
} |
|
Prims.Tot | val map_blocks:
#a:Type0
-> blocksize:size_pos
-> inp:seq a
-> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize)
-> g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) ->
Tot (out:seq a{length out == length inp}) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map_blocks #a blocksize inp f g =
let len = length inp in
let nb = len / blocksize in
let rem = len % blocksize in
let blocks = Seq.slice inp 0 (nb * blocksize) in
let last = Seq.slice inp (nb * blocksize) len in
let bs = map_blocks_multi #a blocksize nb nb blocks f in
if (rem > 0) then
Seq.append bs (g nb rem last)
else bs | val map_blocks:
#a:Type0
-> blocksize:size_pos
-> inp:seq a
-> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize)
-> g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) ->
Tot (out:seq a{length out == length inp})
let map_blocks #a blocksize inp f g = | false | null | false | let len = length inp in
let nb = len / blocksize in
let rem = len % blocksize in
let blocks = Seq.slice inp 0 (nb * blocksize) in
let last = Seq.slice inp (nb * blocksize) len in
let bs = map_blocks_multi #a blocksize nb nb blocks f in
if (rem > 0) then Seq.append bs (g nb rem last) else bs | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_pos",
"Lib.Sequence.seq",
"Lib.Sequence.block",
"Lib.Sequence.length",
"Lib.Sequence.lseq",
"Lib.Sequence.last",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_GreaterThan",
"FStar.Seq.Base.append",
"Prims.bool",
"Prims.eq2",
"Prims.nat",
"Prims.int",
"Prims.op_Multiply",
"Lib.Sequence.map_blocks_multi",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.slice",
"FStar.Mul.op_Star",
"Prims.op_Modulus",
"Prims.op_Division"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc
let repeati_blocks #a #b bs inp f g init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeati_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
g nb rem last acc
let repeat_blocks #a #b #c bs inp f l init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeat_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
l rem last acc
let lemma_repeat_blocks #a #b #c bs inp f l init = ()
let repeat_blocks_multi #a #b bs inp f init =
let len = length inp in
let nb = len / bs in
repeati nb (repeat_blocks_f bs inp f nb) init
let lemma_repeat_blocks_multi #a #b bs inp f init = ()
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
let acc, o = acc in
let acc', block = f i acc in
let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in
acc', o'
let generate_blocks #t len max n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1)
=
Seq.append acc (f i)
let generate_blocks_simple #a bs max nb f =
repeat_gen nb (generate_blocks_simple_a a bs max)
(generate_blocks_simple_f #a bs max f) Seq.empty
#restart-solver
let div_interval b n i =
Math.Lemmas.lemma_div_le (n * b) i b;
Math.Lemmas.cancel_mul_div n b
let mod_interval_lt b n i j =
div_interval b n i;
div_interval b n j
let div_mul_lt b a n = ()
let mod_div_lt b i j =
mod_interval_lt b (j / b) i j
let div_mul_l a b c d =
calc (==) {
a / (c * d);
== { }
a / (d * c);
== { Math.Lemmas.division_multiplication_lemma a d c }
(a / d) / c;
== { }
(b / d) / c;
== { Math.Lemmas.division_multiplication_lemma b d c }
b / (d * c);
== { }
b / (c * d);
}
let map_blocks_multi #a bs max nb inp f =
repeat_gen nb (map_blocks_a a bs max)
(map_blocks_f #a bs max inp f) Seq.empty
let lemma_map_blocks_multi #a bs max nb inp f = ()
private
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} ->
Lemma (b - a * n == b % n)
let mod_prop n a b =
Math.Lemmas.modulo_lemma (b - a * n) n;
Math.Lemmas.lemma_mod_sub b n a
#push-options "--z3rlimit 200"
let rec index_map_blocks_multi #a bs max n inp f i =
let map_blocks_a = map_blocks_a a bs max in
let map_blocks_f = map_blocks_f #a bs max inp f in
let acc0 = Seq.empty #a in
let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in
unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1);
let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in
//assert (s1 == map_blocks_f (n-1) s);
let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in
//assert (s1 == Seq.append s s');
if i < (n-1)*bs then begin
Seq.lemma_index_app1 s s' i;
index_map_blocks_multi #a bs max (n-1) inp f i end
else begin
Seq.lemma_index_app2 s s' i;
mod_prop bs (n-1) i
end | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map_blocks:
#a:Type0
-> blocksize:size_pos
-> inp:seq a
-> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize)
-> g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) ->
Tot (out:seq a{length out == length inp}) | [] | Lib.Sequence.map_blocks | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
blocksize: Lib.IntTypes.size_pos ->
inp: Lib.Sequence.seq a ->
f:
(_: Lib.Sequence.block (Lib.Sequence.length inp) blocksize -> _: Lib.Sequence.lseq a blocksize
-> Lib.Sequence.lseq a blocksize) ->
g:
(
_: Lib.Sequence.last (Lib.Sequence.length inp) blocksize ->
rem: Lib.IntTypes.size_nat{rem < blocksize} ->
s: Lib.Sequence.lseq a rem
-> Lib.Sequence.lseq a rem)
-> out: Lib.Sequence.seq a {Lib.Sequence.length out == Lib.Sequence.length inp} | {
"end_col": 9,
"end_line": 298,
"start_col": 37,
"start_line": 289
} |
Prims.Tot | val create:
#a:Type
-> len:size_nat
-> init:a ->
Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat).
{:pattern (index s i)} i < len ==> index s i == init)}) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let create #a len init = Seq.create #a len init | val create:
#a:Type
-> len:size_nat
-> init:a ->
Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat).
{:pattern (index s i)} i < len ==> index s i == init)})
let create #a len init = | false | null | false | Seq.create #a len init | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"FStar.Seq.Base.create",
"Lib.Sequence.lseq",
"Prims.l_and",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.Sequence.index"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val create:
#a:Type
-> len:size_nat
-> init:a ->
Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat).
{:pattern (index s i)} i < len ==> index s i == init)}) | [] | Lib.Sequence.create | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_nat -> init: a
-> s:
Lib.Sequence.lseq a len
{ Lib.Sequence.to_seq s == FStar.Seq.Base.create len init /\
(forall (i: Prims.nat). {:pattern Lib.Sequence.index s i}
i < len ==> Lib.Sequence.index s i == init) } | {
"end_col": 47,
"end_line": 11,
"start_col": 25,
"start_line": 11
} |
Prims.Tot | val upd:
#a:Type
-> #len:size_nat
-> s:lseq a len
-> n:size_nat{n < len}
-> x:a ->
Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat).
{:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let upd #a #len s n x = Seq.upd #a s n x | val upd:
#a:Type
-> #len:size_nat
-> s:lseq a len
-> n:size_nat{n < len}
-> x:a ->
Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat).
{:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)})
let upd #a #len s n x = | false | null | false | Seq.upd #a s n x | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Lib.Sequence.lseq",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.upd",
"Prims.l_and",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.op_disEquality",
"Prims.l_or",
"FStar.Seq.Base.index"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2 | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val upd:
#a:Type
-> #len:size_nat
-> s:lseq a len
-> n:size_nat{n < len}
-> x:a ->
Tot (o:lseq a len{to_seq o == Seq.upd (to_seq s) n x /\ index o n == x /\ (forall (i:size_nat).
{:pattern (index s i)} (i < len /\ i <> n) ==> index o i == index s i)}) | [] | Lib.Sequence.upd | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Lib.Sequence.lseq a len -> n: Lib.IntTypes.size_nat{n < len} -> x: a
-> o:
Lib.Sequence.lseq a len
{ Lib.Sequence.to_seq o == FStar.Seq.Base.upd (Lib.Sequence.to_seq s) n x /\
Lib.Sequence.index o n == x /\
(forall (i: Lib.IntTypes.size_nat). {:pattern Lib.Sequence.index s i}
i < len /\ i <> n ==> Lib.Sequence.index o i == Lib.Sequence.index s i) } | {
"end_col": 40,
"end_line": 35,
"start_col": 24,
"start_line": 35
} |
FStar.Pervasives.Lemma | val index_map_blocks:
#a:Type
-> blocksize:size_pos
-> inp:seq a
-> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize)
-> g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> lseq a rem -> lseq a rem)
-> i:nat{i < length inp} ->
Lemma (
let output = map_blocks blocksize inp f g in
let j = i % blocksize in
if i < (length inp / blocksize) * blocksize
then
let block_i = get_block blocksize inp f i in
Seq.index output i == Seq.index block_i j
else
let block_i = get_last blocksize inp g i in
Seq.index output i == Seq.index block_i j
) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let index_map_blocks #a bs inp f g i =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let blocks = Seq.slice inp 0 (nb * bs) in
if rem > 0 then
begin
let s1 = map_blocks_multi #a bs nb nb blocks f in
let last = Seq.slice inp (nb * bs) len in
calc (==) {
length last;
== { Seq.lemma_len_slice inp (nb * bs) len }
len - nb * bs;
== {mod_prop bs nb len}
len % bs;
== { }
rem;
};
let s2 = g nb rem last in
assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2));
if i < nb * bs then
begin
div_mul_lt bs i nb;
Seq.lemma_index_app1 s1 s2 i;
index_map_blocks_multi bs nb nb blocks f i
end
else
begin
Seq.lemma_index_app2 s1 s2 i;
mod_prop bs nb i
end
end
else index_map_blocks_multi #a bs nb nb blocks f i | val index_map_blocks:
#a:Type
-> blocksize:size_pos
-> inp:seq a
-> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize)
-> g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> lseq a rem -> lseq a rem)
-> i:nat{i < length inp} ->
Lemma (
let output = map_blocks blocksize inp f g in
let j = i % blocksize in
if i < (length inp / blocksize) * blocksize
then
let block_i = get_block blocksize inp f i in
Seq.index output i == Seq.index block_i j
else
let block_i = get_last blocksize inp g i in
Seq.index output i == Seq.index block_i j
)
let index_map_blocks #a bs inp f g i = | false | null | true | let len = length inp in
let nb = len / bs in
let rem = len % bs in
let blocks = Seq.slice inp 0 (nb * bs) in
if rem > 0
then
let s1 = map_blocks_multi #a bs nb nb blocks f in
let last = Seq.slice inp (nb * bs) len in
calc ( == ) {
length last;
( == ) { Seq.lemma_len_slice inp (nb * bs) len }
len - nb * bs;
( == ) { mod_prop bs nb len }
len % bs;
( == ) { () }
rem;
};
let s2 = g nb rem last in
assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2));
if i < nb * bs
then
(div_mul_lt bs i nb;
Seq.lemma_index_app1 s1 s2 i;
index_map_blocks_multi bs nb nb blocks f i)
else
(Seq.lemma_index_app2 s1 s2 i;
mod_prop bs nb i)
else index_map_blocks_multi #a bs nb nb blocks f i | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_pos",
"Lib.Sequence.seq",
"Lib.Sequence.block",
"Lib.Sequence.length",
"Lib.Sequence.lseq",
"Lib.Sequence.last",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.nat",
"Prims.op_GreaterThan",
"FStar.Mul.op_Star",
"Lib.Sequence.index_map_blocks_multi",
"Prims.unit",
"FStar.Seq.Base.lemma_index_app1",
"Lib.Sequence.div_mul_lt",
"Prims.bool",
"Lib.Sequence.mod_prop",
"FStar.Seq.Base.lemma_index_app2",
"Prims._assert",
"FStar.Seq.Base.equal",
"Lib.Sequence.map_blocks",
"FStar.Seq.Base.append",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Seq.Base.lemma_len_slice",
"Prims.squash",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.slice",
"Prims.int",
"Prims.op_Multiply",
"Lib.Sequence.map_blocks_multi",
"Prims.op_Division"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc
let repeati_blocks #a #b bs inp f g init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeati_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
g nb rem last acc
let repeat_blocks #a #b #c bs inp f l init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeat_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
l rem last acc
let lemma_repeat_blocks #a #b #c bs inp f l init = ()
let repeat_blocks_multi #a #b bs inp f init =
let len = length inp in
let nb = len / bs in
repeati nb (repeat_blocks_f bs inp f nb) init
let lemma_repeat_blocks_multi #a #b bs inp f init = ()
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
let acc, o = acc in
let acc', block = f i acc in
let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in
acc', o'
let generate_blocks #t len max n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1)
=
Seq.append acc (f i)
let generate_blocks_simple #a bs max nb f =
repeat_gen nb (generate_blocks_simple_a a bs max)
(generate_blocks_simple_f #a bs max f) Seq.empty
#restart-solver
let div_interval b n i =
Math.Lemmas.lemma_div_le (n * b) i b;
Math.Lemmas.cancel_mul_div n b
let mod_interval_lt b n i j =
div_interval b n i;
div_interval b n j
let div_mul_lt b a n = ()
let mod_div_lt b i j =
mod_interval_lt b (j / b) i j
let div_mul_l a b c d =
calc (==) {
a / (c * d);
== { }
a / (d * c);
== { Math.Lemmas.division_multiplication_lemma a d c }
(a / d) / c;
== { }
(b / d) / c;
== { Math.Lemmas.division_multiplication_lemma b d c }
b / (d * c);
== { }
b / (c * d);
}
let map_blocks_multi #a bs max nb inp f =
repeat_gen nb (map_blocks_a a bs max)
(map_blocks_f #a bs max inp f) Seq.empty
let lemma_map_blocks_multi #a bs max nb inp f = ()
private
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} ->
Lemma (b - a * n == b % n)
let mod_prop n a b =
Math.Lemmas.modulo_lemma (b - a * n) n;
Math.Lemmas.lemma_mod_sub b n a
#push-options "--z3rlimit 200"
let rec index_map_blocks_multi #a bs max n inp f i =
let map_blocks_a = map_blocks_a a bs max in
let map_blocks_f = map_blocks_f #a bs max inp f in
let acc0 = Seq.empty #a in
let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in
unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1);
let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in
//assert (s1 == map_blocks_f (n-1) s);
let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in
//assert (s1 == Seq.append s s');
if i < (n-1)*bs then begin
Seq.lemma_index_app1 s s' i;
index_map_blocks_multi #a bs max (n-1) inp f i end
else begin
Seq.lemma_index_app2 s s' i;
mod_prop bs (n-1) i
end
let map_blocks #a blocksize inp f g =
let len = length inp in
let nb = len / blocksize in
let rem = len % blocksize in
let blocks = Seq.slice inp 0 (nb * blocksize) in
let last = Seq.slice inp (nb * blocksize) len in
let bs = map_blocks_multi #a blocksize nb nb blocks f in
if (rem > 0) then
Seq.append bs (g nb rem last)
else bs
let lemma_map_blocks #a blocksize inp f g = () | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val index_map_blocks:
#a:Type
-> blocksize:size_pos
-> inp:seq a
-> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize)
-> g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> lseq a rem -> lseq a rem)
-> i:nat{i < length inp} ->
Lemma (
let output = map_blocks blocksize inp f g in
let j = i % blocksize in
if i < (length inp / blocksize) * blocksize
then
let block_i = get_block blocksize inp f i in
Seq.index output i == Seq.index block_i j
else
let block_i = get_last blocksize inp g i in
Seq.index output i == Seq.index block_i j
) | [] | Lib.Sequence.index_map_blocks | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
blocksize: Lib.IntTypes.size_pos ->
inp: Lib.Sequence.seq a ->
f:
(_: Lib.Sequence.block (Lib.Sequence.length inp) blocksize -> _: Lib.Sequence.lseq a blocksize
-> Lib.Sequence.lseq a blocksize) ->
g:
(
_: Lib.Sequence.last (Lib.Sequence.length inp) blocksize ->
rem: Lib.IntTypes.size_nat{rem < blocksize} ->
_: Lib.Sequence.lseq a rem
-> Lib.Sequence.lseq a rem) ->
i: Prims.nat{i < Lib.Sequence.length inp}
-> FStar.Pervasives.Lemma
(ensures
(let output = Lib.Sequence.map_blocks blocksize inp f g in
let j = i % blocksize in
(match i < (Lib.Sequence.length inp / blocksize) * blocksize with
| true ->
let block_i = Lib.Sequence.get_block blocksize inp f i in
FStar.Seq.Base.index output i == FStar.Seq.Base.index block_i j
| _ ->
let block_i = Lib.Sequence.get_last blocksize inp g i in
FStar.Seq.Base.index output i == FStar.Seq.Base.index block_i j)
<:
Type0)) | {
"end_col": 52,
"end_line": 334,
"start_col": 38,
"start_line": 302
} |
Prims.Tot | val sub:
#a:Type
-> #len:size_nat
-> s1:lseq a len
-> start:size_nat
-> n:size_nat{start + n <= len} ->
Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\
(forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))}) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub #a #len s start n = Seq.slice #a s start (start + n) | val sub:
#a:Type
-> #len:size_nat
-> s1:lseq a len
-> start:size_nat
-> n:size_nat{start + n <= len} ->
Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\
(forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))})
let sub #a #len s start n = | false | null | false | Seq.slice #a s start (start + n) | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Lib.Sequence.lseq",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Seq.Base.slice",
"Prims.l_and",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"Prims.l_Forall",
"Prims.nat",
"Prims.op_LessThan",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.index"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0 | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub:
#a:Type
-> #len:size_nat
-> s1:lseq a len
-> start:size_nat
-> n:size_nat{start + n <= len} ->
Tot (s2:lseq a n{to_seq s2 == Seq.slice (to_seq s1) start (start + n) /\
(forall (k:nat{k < n}). {:pattern (index s2 k)} index s2 k == index s1 (start + k))}) | [] | Lib.Sequence.sub | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
s1: Lib.Sequence.lseq a len ->
start: Lib.IntTypes.size_nat ->
n: Lib.IntTypes.size_nat{start + n <= len}
-> s2:
Lib.Sequence.lseq a n
{ Lib.Sequence.to_seq s2 == FStar.Seq.Base.slice (Lib.Sequence.to_seq s1) start (start + n) /\
(forall (k: Prims.nat{k < n}). {:pattern Lib.Sequence.index s2 k}
Lib.Sequence.index s2 k == Lib.Sequence.index s1 (start + k)) } | {
"end_col": 60,
"end_line": 39,
"start_col": 28,
"start_line": 39
} |
Prims.Tot | val update_sub:
#a:Type
-> #len:size_nat
-> i:lseq a len
-> start:size_nat
-> n:size_nat{start + n <= len}
-> x:lseq a n ->
Tot (o:lseq a len{sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < len)}).
{:pattern (index o k)} index o k == index i k)}) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o | val update_sub:
#a:Type
-> #len:size_nat
-> i:lseq a len
-> start:size_nat
-> n:size_nat{start + n <= len}
-> x:lseq a n ->
Tot (o:lseq a len{sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < len)}).
{:pattern (index o k)} index o k == index i k)})
let update_sub #a #len s start n x = | false | null | false | let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Lib.Sequence.lseq",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Prims.unit",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Seq.Base.slice",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.append",
"Lib.Sequence.length",
"Prims.l_and",
"Prims.eq2",
"Lib.Sequence.sub",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_or",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n) | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_sub:
#a:Type
-> #len:size_nat
-> i:lseq a len
-> start:size_nat
-> n:size_nat{start + n <= len}
-> x:lseq a n ->
Tot (o:lseq a len{sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < len)}).
{:pattern (index o k)} index o k == index i k)}) | [] | Lib.Sequence.update_sub | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
i: Lib.Sequence.lseq a len ->
start: Lib.IntTypes.size_nat ->
n: Lib.IntTypes.size_nat{start + n <= len} ->
x: Lib.Sequence.lseq a n
-> o:
Lib.Sequence.lseq a len
{ Lib.Sequence.sub o start n == x /\
(forall (k: Prims.nat{0 <= k /\ k < start \/ start + n <= k /\ k < len}).
{:pattern Lib.Sequence.index o k}
Lib.Sequence.index o k == Lib.Sequence.index i k) } | {
"end_col": 3,
"end_line": 47,
"start_col": 36,
"start_line": 41
} |
FStar.Pervasives.Lemma | val lemma_concat2:
#a:Type0
-> len0:size_nat
-> s0:lseq a len0
-> len1:size_nat{len0 + len1 <= max_size_t}
-> s1:lseq a len1
-> s:lseq a (len0 + len1) ->
Lemma
(requires
sub s 0 len0 == s0 /\
sub s len0 len1 == s1)
(ensures s == concat s0 s1) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1) | val lemma_concat2:
#a:Type0
-> len0:size_nat
-> s0:lseq a len0
-> len1:size_nat{len0 + len1 <= max_size_t}
-> s1:lseq a len1
-> s:lseq a (len0 + len1) ->
Lemma
(requires
sub s 0 len0 == s0 /\
sub s len0 len1 == s1)
(ensures s == concat s0 s1)
let lemma_concat2 #a len0 s0 len1 s1 s = | false | null | true | Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1) | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Lib.Sequence.lseq",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.max_size_t",
"FStar.Seq.Base.lemma_eq_intro",
"Lib.Sequence.concat",
"Prims.unit",
"FStar.Seq.Properties.lemma_split"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src) | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_concat2:
#a:Type0
-> len0:size_nat
-> s0:lseq a len0
-> len1:size_nat{len0 + len1 <= max_size_t}
-> s1:lseq a len1
-> s:lseq a (len0 + len1) ->
Lemma
(requires
sub s 0 len0 == s0 /\
sub s len0 len1 == s1)
(ensures s == concat s0 s1) | [] | Lib.Sequence.lemma_concat2 | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len0: Lib.IntTypes.size_nat ->
s0: Lib.Sequence.lseq a len0 ->
len1: Lib.IntTypes.size_nat{len0 + len1 <= Lib.IntTypes.max_size_t} ->
s1: Lib.Sequence.lseq a len1 ->
s: Lib.Sequence.lseq a (len0 + len1)
-> FStar.Pervasives.Lemma
(requires Lib.Sequence.sub s 0 len0 == s0 /\ Lib.Sequence.sub s len0 len1 == s1)
(ensures s == Lib.Sequence.concat s0 s1) | {
"end_col": 37,
"end_line": 60,
"start_col": 2,
"start_line": 58
} |
FStar.Pervasives.Lemma | val lemma_update_sub:
#a:Type
-> #len:size_nat
-> dst:lseq a len
-> start:size_nat
-> n:size_nat{start + n <= len}
-> src:lseq a n
-> res:lseq a len ->
Lemma
(requires
sub res 0 start == sub dst 0 start /\
sub res start n == src /\
sub res (start + n) (len - start - n) ==
sub dst (start + n) (len - start - n))
(ensures
res == update_sub dst start n src) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src) | val lemma_update_sub:
#a:Type
-> #len:size_nat
-> dst:lseq a len
-> start:size_nat
-> n:size_nat{start + n <= len}
-> src:lseq a n
-> res:lseq a len ->
Lemma
(requires
sub res 0 start == sub dst 0 start /\
sub res start n == src /\
sub res (start + n) (len - start - n) ==
sub dst (start + n) (len - start - n))
(ensures
res == update_sub dst start n src)
let lemma_update_sub #a #len dst start n src res = | false | null | true | let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src) | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Lib.Sequence.lseq",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Seq.Base.lemma_eq_intro",
"Lib.Sequence.update_sub",
"Prims.unit",
"FStar.Seq.Properties.lemma_split",
"Lib.Sequence.sub",
"Prims.l_and",
"Prims.eq2",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_or",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_update_sub:
#a:Type
-> #len:size_nat
-> dst:lseq a len
-> start:size_nat
-> n:size_nat{start + n <= len}
-> src:lseq a n
-> res:lseq a len ->
Lemma
(requires
sub res 0 start == sub dst 0 start /\
sub res start n == src /\
sub res (start + n) (len - start - n) ==
sub dst (start + n) (len - start - n))
(ensures
res == update_sub dst start n src) | [] | Lib.Sequence.lemma_update_sub | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Lib.Sequence.lseq a len ->
start: Lib.IntTypes.size_nat ->
n: Lib.IntTypes.size_nat{start + n <= len} ->
src: Lib.Sequence.lseq a n ->
res: Lib.Sequence.lseq a len
-> FStar.Pervasives.Lemma
(requires
Lib.Sequence.sub res 0 start == Lib.Sequence.sub dst 0 start /\
Lib.Sequence.sub res start n == src /\
Lib.Sequence.sub res (start + n) (len - start - n) ==
Lib.Sequence.sub dst (start + n) (len - start - n))
(ensures res == Lib.Sequence.update_sub dst start n src) | {
"end_col": 53,
"end_line": 55,
"start_col": 50,
"start_line": 49
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i | let createi_pred
(a: Type)
(len: size_nat)
(init: (i: nat{i < len} -> a))
(k: nat{k <= len})
(s: createi_a a len init k)
= | false | null | false | forall (i: nat). {:pattern (index s i)} i < k ==> index s i == init i | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_LessThanOrEqual",
"Lib.Sequence.createi_a",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.eq2",
"Lib.Sequence.index",
"Prims.logical"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val createi_pred : a: Type0 ->
len: Lib.IntTypes.size_nat ->
init: (i: Prims.nat{i < len} -> a) ->
k: Prims.nat{k <= len} ->
s: Lib.Sequence.createi_a a len init k
-> Prims.logical | [] | Lib.Sequence.createi_pred | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Type0 ->
len: Lib.IntTypes.size_nat ->
init: (i: Prims.nat{i < len} -> a) ->
k: Prims.nat{k <= len} ->
s: Lib.Sequence.createi_a a len init k
-> Prims.logical | {
"end_col": 69,
"end_line": 75,
"start_col": 2,
"start_line": 75
} |
|
Prims.Tot | val createi: #a:Type
-> len:size_nat
-> init:(i:nat{i < len} -> a) ->
Tot (s:lseq a len{(forall (i:nat).
{:pattern (index s i)} i < len ==> index s i == init i)}) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list []) | val createi: #a:Type
-> len:size_nat
-> init:(i:nat{i < len} -> a) ->
Tot (s:lseq a len{(forall (i:nat).
{:pattern (index s i)} i < len ==> index s i == init i)})
let createi #a len init_f = | false | null | false | repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list []) | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.LoopCombinators.repeat_gen_inductive",
"Lib.Sequence.createi_a",
"Lib.Sequence.createi_pred",
"Lib.Sequence.createi_step",
"Lib.Sequence.of_list",
"Prims.Nil",
"Lib.Sequence.lseq",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.eq2",
"Lib.Sequence.index"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val createi: #a:Type
-> len:size_nat
-> init:(i:nat{i < len} -> a) ->
Tot (s:lseq a len{(forall (i:nat).
{:pattern (index s i)} i < len ==> index s i == init i)}) | [] | Lib.Sequence.createi | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_nat -> init: (i: Prims.nat{i < len} -> a)
-> s:
Lib.Sequence.lseq a len
{ forall (i: Prims.nat). {:pattern Lib.Sequence.index s i}
i < len ==> Lib.Sequence.index s i == init i } | {
"end_col": 16,
"end_line": 92,
"start_col": 2,
"start_line": 88
} |
Prims.Tot | val map:#a:Type -> #b:Type -> #len:size_nat
-> f:(a -> Tot b)
-> s1:lseq a len ->
Tot (s2:lseq b len{(forall (i:nat).
{:pattern (index s2 i)} i < len ==> index s2 i == f s1.[i])}) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s) | val map:#a:Type -> #b:Type -> #len:size_nat
-> f:(a -> Tot b)
-> s1:lseq a len ->
Tot (s2:lseq b len{(forall (i:nat).
{:pattern (index s2 i)} i < len ==> index s2 i == f s1.[i])})
let map #a #b #len f s = | false | null | false | createi #b len (map_inner #a #b #len f s) | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Lib.Sequence.lseq",
"Lib.Sequence.createi",
"Lib.Sequence.map_inner",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.Sequence.index",
"Lib.Sequence.op_String_Access"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i] | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map:#a:Type -> #b:Type -> #len:size_nat
-> f:(a -> Tot b)
-> s1:lseq a len ->
Tot (s2:lseq b len{(forall (i:nat).
{:pattern (index s2 i)} i < len ==> index s2 i == f s1.[i])}) | [] | Lib.Sequence.map | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: (_: a -> b) -> s1: Lib.Sequence.lseq a len
-> s2:
Lib.Sequence.lseq b len
{ forall (i: Prims.nat). {:pattern Lib.Sequence.index s2 i}
i < len ==> Lib.Sequence.index s2 i == f s1.[ i ] } | {
"end_col": 43,
"end_line": 110,
"start_col": 2,
"start_line": 110
} |
Prims.Tot | val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc | val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc = | false | null | false | assert ((i + 1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.Sequence.seq",
"Prims.nat",
"Prims.op_LessThan",
"Prims.op_Division",
"Lib.Sequence.length",
"Lib.Sequence.lseq",
"Prims.eq2",
"Prims.int",
"Prims.l_and",
"Prims.l_Forall",
"FStar.Seq.Base.index",
"Prims.op_Addition",
"Prims.op_Multiply",
"Lib.Sequence.seq_sub",
"FStar.Mul.op_Star",
"Prims.unit",
"Prims._assert",
"Prims.op_LessThanOrEqual"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b | [] | Lib.Sequence.repeati_blocks_f | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
blocksize: Lib.IntTypes.size_nat{blocksize > 0} ->
inp: Lib.Sequence.seq a ->
f:
(
i: Prims.nat{i < Lib.Sequence.length inp / blocksize} ->
_: Lib.Sequence.lseq a blocksize ->
_: b
-> b) ->
nb: Prims.nat{nb == Lib.Sequence.length inp / blocksize} ->
i: Prims.nat{i < nb} ->
acc: b
-> b | {
"end_col": 15,
"end_line": 171,
"start_col": 2,
"start_line": 169
} |
Prims.Tot | val map2:#a:Type -> #b:Type -> #c:Type -> #len:size_nat
-> f:(a -> b -> Tot c)
-> s1:lseq a len
-> s2:lseq b len ->
Tot (s3:lseq c len{(forall (i:nat).
{:pattern (index s3 i)} i < len ==> index s3 i == f s1.[i] s2.[i])}) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2) | val map2:#a:Type -> #b:Type -> #c:Type -> #len:size_nat
-> f:(a -> b -> Tot c)
-> s1:lseq a len
-> s2:lseq b len ->
Tot (s3:lseq c len{(forall (i:nat).
{:pattern (index s3 i)} i < len ==> index s3 i == f s1.[i] s2.[i])})
let map2 #a #b #c #len f s1 s2 = | false | null | false | createi #c len (map2_inner #a #b #c #len f s1 s2) | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Lib.Sequence.lseq",
"Lib.Sequence.createi",
"Lib.Sequence.map2_inner",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.Sequence.index",
"Lib.Sequence.op_String_Access"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i] | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map2:#a:Type -> #b:Type -> #c:Type -> #len:size_nat
-> f:(a -> b -> Tot c)
-> s1:lseq a len
-> s2:lseq b len ->
Tot (s3:lseq c len{(forall (i:nat).
{:pattern (index s3 i)} i < len ==> index s3 i == f s1.[i] s2.[i])}) | [] | Lib.Sequence.map2 | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: (_: a -> _: b -> c) -> s1: Lib.Sequence.lseq a len -> s2: Lib.Sequence.lseq b len
-> s3:
Lib.Sequence.lseq c len
{ forall (i: Prims.nat). {:pattern Lib.Sequence.index s3 i}
i < len ==> Lib.Sequence.index s3 i == f s1.[ i ] s2.[ i ] } | {
"end_col": 51,
"end_line": 121,
"start_col": 2,
"start_line": 121
} |
Prims.Tot | val generate_blocks_simple_f
(#a: Type)
(bs: size_nat{bs > 0})
(max: nat)
(f: (i: nat{i < max} -> lseq a bs))
(i: nat{i < max})
(acc: generate_blocks_simple_a a bs max i)
: generate_blocks_simple_a a bs max (i + 1) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1)
=
Seq.append acc (f i) | val generate_blocks_simple_f
(#a: Type)
(bs: size_nat{bs > 0})
(max: nat)
(f: (i: nat{i < max} -> lseq a bs))
(i: nat{i < max})
(acc: generate_blocks_simple_a a bs max i)
: generate_blocks_simple_a a bs max (i + 1)
let generate_blocks_simple_f
(#a: Type)
(bs: size_nat{bs > 0})
(max: nat)
(f: (i: nat{i < max} -> lseq a bs))
(i: nat{i < max})
(acc: generate_blocks_simple_a a bs max i)
: generate_blocks_simple_a a bs max (i + 1) = | false | null | false | Seq.append acc (f i) | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.nat",
"Prims.op_LessThan",
"Lib.Sequence.lseq",
"Lib.Sequence.generate_blocks_simple_a",
"FStar.Seq.Base.append",
"Prims.op_Addition"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc
let repeati_blocks #a #b bs inp f g init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeati_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
g nb rem last acc
let repeat_blocks #a #b #c bs inp f l init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeat_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
l rem last acc
let lemma_repeat_blocks #a #b #c bs inp f l init = ()
let repeat_blocks_multi #a #b bs inp f init =
let len = length inp in
let nb = len / bs in
repeati nb (repeat_blocks_f bs inp f nb) init
let lemma_repeat_blocks_multi #a #b bs inp f init = ()
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
let acc, o = acc in
let acc', block = f i acc in
let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in
acc', o'
let generate_blocks #t len max n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val generate_blocks_simple_f
(#a: Type)
(bs: size_nat{bs > 0})
(max: nat)
(f: (i: nat{i < max} -> lseq a bs))
(i: nat{i < max})
(acc: generate_blocks_simple_a a bs max i)
: generate_blocks_simple_a a bs max (i + 1) | [] | Lib.Sequence.generate_blocks_simple_f | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
bs: Lib.IntTypes.size_nat{bs > 0} ->
max: Prims.nat ->
f: (i: Prims.nat{i < max} -> Lib.Sequence.lseq a bs) ->
i: Prims.nat{i < max} ->
acc: Lib.Sequence.generate_blocks_simple_a a bs max i
-> Lib.Sequence.generate_blocks_simple_a a bs max (i + 1) | {
"end_col": 21,
"end_line": 220,
"start_col": 1,
"start_line": 220
} |
FStar.Pervasives.Lemma | val mod_div_lt: b:pos -> i:int -> j:int -> Lemma
(requires (j / b) * b <= i /\ i < j)
(ensures i % b < j % b) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_div_lt b i j =
mod_interval_lt b (j / b) i j | val mod_div_lt: b:pos -> i:int -> j:int -> Lemma
(requires (j / b) * b <= i /\ i < j)
(ensures i % b < j % b)
let mod_div_lt b i j = | false | null | true | mod_interval_lt b (j / b) i j | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"lemma"
] | [
"Prims.pos",
"Prims.int",
"Lib.Sequence.mod_interval_lt",
"Prims.op_Division",
"Prims.unit"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc
let repeati_blocks #a #b bs inp f g init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeati_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
g nb rem last acc
let repeat_blocks #a #b #c bs inp f l init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeat_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
l rem last acc
let lemma_repeat_blocks #a #b #c bs inp f l init = ()
let repeat_blocks_multi #a #b bs inp f init =
let len = length inp in
let nb = len / bs in
repeati nb (repeat_blocks_f bs inp f nb) init
let lemma_repeat_blocks_multi #a #b bs inp f init = ()
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
let acc, o = acc in
let acc', block = f i acc in
let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in
acc', o'
let generate_blocks #t len max n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1)
=
Seq.append acc (f i)
let generate_blocks_simple #a bs max nb f =
repeat_gen nb (generate_blocks_simple_a a bs max)
(generate_blocks_simple_f #a bs max f) Seq.empty
#restart-solver
let div_interval b n i =
Math.Lemmas.lemma_div_le (n * b) i b;
Math.Lemmas.cancel_mul_div n b
let mod_interval_lt b n i j =
div_interval b n i;
div_interval b n j
let div_mul_lt b a n = () | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_div_lt: b:pos -> i:int -> j:int -> Lemma
(requires (j / b) * b <= i /\ i < j)
(ensures i % b < j % b) | [] | Lib.Sequence.mod_div_lt | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Prims.pos -> i: Prims.int -> j: Prims.int
-> FStar.Pervasives.Lemma (requires (j / b) * b <= i /\ i < j) (ensures i % b < j % b) | {
"end_col": 31,
"end_line": 238,
"start_col": 2,
"start_line": 238
} |
FStar.Pervasives.Lemma | val create4_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a ->
Lemma (let s = create4 x0 x1 x2 x3 in
s.[0] == x0 /\ s.[1] == x1 /\ s.[2] == x2 /\ s.[3] == x3)
[SMTPat (create4 #a x0 x1 x2 x3)] | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let create4_lemma #a x0 x1 x2 x3 =
Seq.elim_of_list [x0; x1; x2; x3] | val create4_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a ->
Lemma (let s = create4 x0 x1 x2 x3 in
s.[0] == x0 /\ s.[1] == x1 /\ s.[2] == x2 /\ s.[3] == x3)
[SMTPat (create4 #a x0 x1 x2 x3)]
let create4_lemma #a x0 x1 x2 x3 = | false | null | true | Seq.elim_of_list [x0; x1; x2; x3] | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"lemma"
] | [
"FStar.Seq.Properties.elim_of_list",
"Prims.Cons",
"Prims.Nil",
"Prims.unit"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc
let repeati_blocks #a #b bs inp f g init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeati_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
g nb rem last acc
let repeat_blocks #a #b #c bs inp f l init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeat_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
l rem last acc
let lemma_repeat_blocks #a #b #c bs inp f l init = ()
let repeat_blocks_multi #a #b bs inp f init =
let len = length inp in
let nb = len / bs in
repeati nb (repeat_blocks_f bs inp f nb) init
let lemma_repeat_blocks_multi #a #b bs inp f init = ()
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
let acc, o = acc in
let acc', block = f i acc in
let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in
acc', o'
let generate_blocks #t len max n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1)
=
Seq.append acc (f i)
let generate_blocks_simple #a bs max nb f =
repeat_gen nb (generate_blocks_simple_a a bs max)
(generate_blocks_simple_f #a bs max f) Seq.empty
#restart-solver
let div_interval b n i =
Math.Lemmas.lemma_div_le (n * b) i b;
Math.Lemmas.cancel_mul_div n b
let mod_interval_lt b n i j =
div_interval b n i;
div_interval b n j
let div_mul_lt b a n = ()
let mod_div_lt b i j =
mod_interval_lt b (j / b) i j
let div_mul_l a b c d =
calc (==) {
a / (c * d);
== { }
a / (d * c);
== { Math.Lemmas.division_multiplication_lemma a d c }
(a / d) / c;
== { }
(b / d) / c;
== { Math.Lemmas.division_multiplication_lemma b d c }
b / (d * c);
== { }
b / (c * d);
}
let map_blocks_multi #a bs max nb inp f =
repeat_gen nb (map_blocks_a a bs max)
(map_blocks_f #a bs max inp f) Seq.empty
let lemma_map_blocks_multi #a bs max nb inp f = ()
private
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} ->
Lemma (b - a * n == b % n)
let mod_prop n a b =
Math.Lemmas.modulo_lemma (b - a * n) n;
Math.Lemmas.lemma_mod_sub b n a
#push-options "--z3rlimit 200"
let rec index_map_blocks_multi #a bs max n inp f i =
let map_blocks_a = map_blocks_a a bs max in
let map_blocks_f = map_blocks_f #a bs max inp f in
let acc0 = Seq.empty #a in
let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in
unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1);
let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in
//assert (s1 == map_blocks_f (n-1) s);
let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in
//assert (s1 == Seq.append s s');
if i < (n-1)*bs then begin
Seq.lemma_index_app1 s s' i;
index_map_blocks_multi #a bs max (n-1) inp f i end
else begin
Seq.lemma_index_app2 s s' i;
mod_prop bs (n-1) i
end
let map_blocks #a blocksize inp f g =
let len = length inp in
let nb = len / blocksize in
let rem = len % blocksize in
let blocks = Seq.slice inp 0 (nb * blocksize) in
let last = Seq.slice inp (nb * blocksize) len in
let bs = map_blocks_multi #a blocksize nb nb blocks f in
if (rem > 0) then
Seq.append bs (g nb rem last)
else bs
let lemma_map_blocks #a blocksize inp f g = ()
let index_map_blocks #a bs inp f g i =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let blocks = Seq.slice inp 0 (nb * bs) in
if rem > 0 then
begin
let s1 = map_blocks_multi #a bs nb nb blocks f in
let last = Seq.slice inp (nb * bs) len in
calc (==) {
length last;
== { Seq.lemma_len_slice inp (nb * bs) len }
len - nb * bs;
== {mod_prop bs nb len}
len % bs;
== { }
rem;
};
let s2 = g nb rem last in
assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2));
if i < nb * bs then
begin
div_mul_lt bs i nb;
Seq.lemma_index_app1 s1 s2 i;
index_map_blocks_multi bs nb nb blocks f i
end
else
begin
Seq.lemma_index_app2 s1 s2 i;
mod_prop bs nb i
end
end
else index_map_blocks_multi #a bs nb nb blocks f i
let eq_generate_blocks0 #t len n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
assert (generate_blocks #t len n 0 a f acc0 ==
repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0
let unfold_generate_blocks #t len n a f acc0 i =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
assert (generate_blocks #t len n (i+1) a f acc0 ==
repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
unfold_repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 i
let rec index_generate_blocks #t len max n f i =
assert (0 < n);
let a_spec (i:nat{i <= max}) = unit in
let _,s = generate_blocks #t len max (n-1) a_spec f () in
let _,s' = f (n-1) () in
let _,s1 = generate_blocks #t len max n a_spec f () in
unfold_generate_blocks #t len max a_spec f () (n-1);
Seq.Properties.lemma_split s1 (n * len - len);
Seq.Properties.lemma_split (Seq.append s s') (n * len - len);
Seq.lemma_eq_intro s1 (Seq.append s s');
if i < (n-1) * len then
begin
Seq.lemma_index_app1 s s' i;
index_generate_blocks len max (n-1) f i
end
else
begin
Seq.lemma_index_app2 s s' i;
mod_prop len (n-1) i
end
#push-options "--using_facts_from '+FStar.UInt.pow2_values'"
let create2 #a x0 x1 =
let l = [x0; x1] in
assert_norm (List.Tot.length l = 2);
createL l
let create2_lemma #a x0 x1 =
Seq.elim_of_list [x0; x1]
let create4 #a x0 x1 x2 x3 =
let l = [x0; x1; x2; x3] in
assert_norm (List.Tot.length l = 4);
createL l | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val create4_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a ->
Lemma (let s = create4 x0 x1 x2 x3 in
s.[0] == x0 /\ s.[1] == x1 /\ s.[2] == x2 /\ s.[3] == x3)
[SMTPat (create4 #a x0 x1 x2 x3)] | [] | Lib.Sequence.create4_lemma | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x0: a -> x1: a -> x2: a -> x3: a
-> FStar.Pervasives.Lemma
(ensures
(let s = Lib.Sequence.create4 x0 x1 x2 x3 in
s.[ 0 ] == x0 /\ s.[ 1 ] == x1 /\ s.[ 2 ] == x2 /\ s.[ 3 ] == x3))
[SMTPat (Lib.Sequence.create4 x0 x1 x2 x3)] | {
"end_col": 35,
"end_line": 385,
"start_col": 2,
"start_line": 385
} |
FStar.Pervasives.Lemma | val eq_generate_blocks0:
#t:Type0
-> len:size_nat
-> n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1) & s:seq t{length s == len})
-> init:a 0 ->
Lemma (generate_blocks #t len n 0 a f init ==
(init,Seq.empty)) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let eq_generate_blocks0 #t len n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
assert (generate_blocks #t len n 0 a f acc0 ==
repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 | val eq_generate_blocks0:
#t:Type0
-> len:size_nat
-> n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1) & s:seq t{length s == len})
-> init:a 0 ->
Lemma (generate_blocks #t len n 0 a f init ==
(init,Seq.empty))
let eq_generate_blocks0 #t len n a f acc0 = | false | null | true | let a0 = (acc0, (Seq.empty <: s: seq t {length s == 0 * len})) in
assert (generate_blocks #t len n 0 a f acc0 ==
repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"FStar.Pervasives.Native.tuple2",
"Prims.op_Addition",
"Lib.Sequence.seq",
"Prims.eq2",
"Lib.Sequence.length",
"Lib.LoopCombinators.eq_repeat_gen0",
"Lib.Sequence.generate_blocks_a",
"Lib.Sequence.generate_blocks_inner",
"Prims.unit",
"Prims._assert",
"Prims.int",
"FStar.Mul.op_Star",
"Lib.Sequence.generate_blocks",
"Lib.LoopCombinators.repeat_gen",
"Prims.op_Multiply",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Seq.Base.empty"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc
let repeati_blocks #a #b bs inp f g init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeati_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
g nb rem last acc
let repeat_blocks #a #b #c bs inp f l init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeat_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
l rem last acc
let lemma_repeat_blocks #a #b #c bs inp f l init = ()
let repeat_blocks_multi #a #b bs inp f init =
let len = length inp in
let nb = len / bs in
repeati nb (repeat_blocks_f bs inp f nb) init
let lemma_repeat_blocks_multi #a #b bs inp f init = ()
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
let acc, o = acc in
let acc', block = f i acc in
let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in
acc', o'
let generate_blocks #t len max n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1)
=
Seq.append acc (f i)
let generate_blocks_simple #a bs max nb f =
repeat_gen nb (generate_blocks_simple_a a bs max)
(generate_blocks_simple_f #a bs max f) Seq.empty
#restart-solver
let div_interval b n i =
Math.Lemmas.lemma_div_le (n * b) i b;
Math.Lemmas.cancel_mul_div n b
let mod_interval_lt b n i j =
div_interval b n i;
div_interval b n j
let div_mul_lt b a n = ()
let mod_div_lt b i j =
mod_interval_lt b (j / b) i j
let div_mul_l a b c d =
calc (==) {
a / (c * d);
== { }
a / (d * c);
== { Math.Lemmas.division_multiplication_lemma a d c }
(a / d) / c;
== { }
(b / d) / c;
== { Math.Lemmas.division_multiplication_lemma b d c }
b / (d * c);
== { }
b / (c * d);
}
let map_blocks_multi #a bs max nb inp f =
repeat_gen nb (map_blocks_a a bs max)
(map_blocks_f #a bs max inp f) Seq.empty
let lemma_map_blocks_multi #a bs max nb inp f = ()
private
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} ->
Lemma (b - a * n == b % n)
let mod_prop n a b =
Math.Lemmas.modulo_lemma (b - a * n) n;
Math.Lemmas.lemma_mod_sub b n a
#push-options "--z3rlimit 200"
let rec index_map_blocks_multi #a bs max n inp f i =
let map_blocks_a = map_blocks_a a bs max in
let map_blocks_f = map_blocks_f #a bs max inp f in
let acc0 = Seq.empty #a in
let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in
unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1);
let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in
//assert (s1 == map_blocks_f (n-1) s);
let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in
//assert (s1 == Seq.append s s');
if i < (n-1)*bs then begin
Seq.lemma_index_app1 s s' i;
index_map_blocks_multi #a bs max (n-1) inp f i end
else begin
Seq.lemma_index_app2 s s' i;
mod_prop bs (n-1) i
end
let map_blocks #a blocksize inp f g =
let len = length inp in
let nb = len / blocksize in
let rem = len % blocksize in
let blocks = Seq.slice inp 0 (nb * blocksize) in
let last = Seq.slice inp (nb * blocksize) len in
let bs = map_blocks_multi #a blocksize nb nb blocks f in
if (rem > 0) then
Seq.append bs (g nb rem last)
else bs
let lemma_map_blocks #a blocksize inp f g = ()
let index_map_blocks #a bs inp f g i =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let blocks = Seq.slice inp 0 (nb * bs) in
if rem > 0 then
begin
let s1 = map_blocks_multi #a bs nb nb blocks f in
let last = Seq.slice inp (nb * bs) len in
calc (==) {
length last;
== { Seq.lemma_len_slice inp (nb * bs) len }
len - nb * bs;
== {mod_prop bs nb len}
len % bs;
== { }
rem;
};
let s2 = g nb rem last in
assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2));
if i < nb * bs then
begin
div_mul_lt bs i nb;
Seq.lemma_index_app1 s1 s2 i;
index_map_blocks_multi bs nb nb blocks f i
end
else
begin
Seq.lemma_index_app2 s1 s2 i;
mod_prop bs nb i
end
end
else index_map_blocks_multi #a bs nb nb blocks f i | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val eq_generate_blocks0:
#t:Type0
-> len:size_nat
-> n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1) & s:seq t{length s == len})
-> init:a 0 ->
Lemma (generate_blocks #t len n 0 a f init ==
(init,Seq.empty)) | [] | Lib.Sequence.eq_generate_blocks0 | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat ->
n: Prims.nat ->
a: (i: Prims.nat{i <= n} -> Type) ->
f:
(i: Prims.nat{i < n} -> _: a i
-> a (i + 1) * s: Lib.Sequence.seq t {Lib.Sequence.length s == len}) ->
init: a 0
-> FStar.Pervasives.Lemma
(ensures
Lib.Sequence.generate_blocks len n 0 a f init ==
FStar.Pervasives.Native.Mktuple2 init FStar.Seq.Base.empty) | {
"end_col": 87,
"end_line": 340,
"start_col": 43,
"start_line": 336
} |
FStar.Pervasives.Lemma | val unfold_generate_blocks:
#t:Type0
-> len:size_nat
-> n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1) & s:seq t{length s == len})
-> init:a 0
-> i:nat{i < n} ->
Lemma (generate_blocks #t len n (i+1) a f init ==
(let (acc,s) = generate_blocks #t len n i a f init in
let (acc',s') = f i acc in
(acc',Seq.append s s'))) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let unfold_generate_blocks #t len n a f acc0 i =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
assert (generate_blocks #t len n (i+1) a f acc0 ==
repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
unfold_repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 i | val unfold_generate_blocks:
#t:Type0
-> len:size_nat
-> n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1) & s:seq t{length s == len})
-> init:a 0
-> i:nat{i < n} ->
Lemma (generate_blocks #t len n (i+1) a f init ==
(let (acc,s) = generate_blocks #t len n i a f init in
let (acc',s') = f i acc in
(acc',Seq.append s s')))
let unfold_generate_blocks #t len n a f acc0 i = | false | null | true | let a0 = (acc0, (Seq.empty <: s: seq t {length s == 0 * len})) in
assert (generate_blocks #t len n (i + 1) a f acc0 ==
repeat_gen (i + 1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
unfold_repeat_gen (i + 1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 i | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"FStar.Pervasives.Native.tuple2",
"Prims.op_Addition",
"Lib.Sequence.seq",
"Prims.eq2",
"Lib.Sequence.length",
"Lib.LoopCombinators.unfold_repeat_gen",
"Lib.Sequence.generate_blocks_a",
"Lib.Sequence.generate_blocks_inner",
"Prims.unit",
"Prims._assert",
"Prims.int",
"FStar.Mul.op_Star",
"Lib.Sequence.generate_blocks",
"Lib.LoopCombinators.repeat_gen",
"Prims.op_Multiply",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Seq.Base.empty"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc
let repeati_blocks #a #b bs inp f g init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeati_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
g nb rem last acc
let repeat_blocks #a #b #c bs inp f l init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeat_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
l rem last acc
let lemma_repeat_blocks #a #b #c bs inp f l init = ()
let repeat_blocks_multi #a #b bs inp f init =
let len = length inp in
let nb = len / bs in
repeati nb (repeat_blocks_f bs inp f nb) init
let lemma_repeat_blocks_multi #a #b bs inp f init = ()
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
let acc, o = acc in
let acc', block = f i acc in
let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in
acc', o'
let generate_blocks #t len max n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1)
=
Seq.append acc (f i)
let generate_blocks_simple #a bs max nb f =
repeat_gen nb (generate_blocks_simple_a a bs max)
(generate_blocks_simple_f #a bs max f) Seq.empty
#restart-solver
let div_interval b n i =
Math.Lemmas.lemma_div_le (n * b) i b;
Math.Lemmas.cancel_mul_div n b
let mod_interval_lt b n i j =
div_interval b n i;
div_interval b n j
let div_mul_lt b a n = ()
let mod_div_lt b i j =
mod_interval_lt b (j / b) i j
let div_mul_l a b c d =
calc (==) {
a / (c * d);
== { }
a / (d * c);
== { Math.Lemmas.division_multiplication_lemma a d c }
(a / d) / c;
== { }
(b / d) / c;
== { Math.Lemmas.division_multiplication_lemma b d c }
b / (d * c);
== { }
b / (c * d);
}
let map_blocks_multi #a bs max nb inp f =
repeat_gen nb (map_blocks_a a bs max)
(map_blocks_f #a bs max inp f) Seq.empty
let lemma_map_blocks_multi #a bs max nb inp f = ()
private
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} ->
Lemma (b - a * n == b % n)
let mod_prop n a b =
Math.Lemmas.modulo_lemma (b - a * n) n;
Math.Lemmas.lemma_mod_sub b n a
#push-options "--z3rlimit 200"
let rec index_map_blocks_multi #a bs max n inp f i =
let map_blocks_a = map_blocks_a a bs max in
let map_blocks_f = map_blocks_f #a bs max inp f in
let acc0 = Seq.empty #a in
let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in
unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1);
let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in
//assert (s1 == map_blocks_f (n-1) s);
let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in
//assert (s1 == Seq.append s s');
if i < (n-1)*bs then begin
Seq.lemma_index_app1 s s' i;
index_map_blocks_multi #a bs max (n-1) inp f i end
else begin
Seq.lemma_index_app2 s s' i;
mod_prop bs (n-1) i
end
let map_blocks #a blocksize inp f g =
let len = length inp in
let nb = len / blocksize in
let rem = len % blocksize in
let blocks = Seq.slice inp 0 (nb * blocksize) in
let last = Seq.slice inp (nb * blocksize) len in
let bs = map_blocks_multi #a blocksize nb nb blocks f in
if (rem > 0) then
Seq.append bs (g nb rem last)
else bs
let lemma_map_blocks #a blocksize inp f g = ()
let index_map_blocks #a bs inp f g i =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let blocks = Seq.slice inp 0 (nb * bs) in
if rem > 0 then
begin
let s1 = map_blocks_multi #a bs nb nb blocks f in
let last = Seq.slice inp (nb * bs) len in
calc (==) {
length last;
== { Seq.lemma_len_slice inp (nb * bs) len }
len - nb * bs;
== {mod_prop bs nb len}
len % bs;
== { }
rem;
};
let s2 = g nb rem last in
assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2));
if i < nb * bs then
begin
div_mul_lt bs i nb;
Seq.lemma_index_app1 s1 s2 i;
index_map_blocks_multi bs nb nb blocks f i
end
else
begin
Seq.lemma_index_app2 s1 s2 i;
mod_prop bs nb i
end
end
else index_map_blocks_multi #a bs nb nb blocks f i
let eq_generate_blocks0 #t len n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
assert (generate_blocks #t len n 0 a f acc0 ==
repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val unfold_generate_blocks:
#t:Type0
-> len:size_nat
-> n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1) & s:seq t{length s == len})
-> init:a 0
-> i:nat{i < n} ->
Lemma (generate_blocks #t len n (i+1) a f init ==
(let (acc,s) = generate_blocks #t len n i a f init in
let (acc',s') = f i acc in
(acc',Seq.append s s'))) | [] | Lib.Sequence.unfold_generate_blocks | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat ->
n: Prims.nat ->
a: (i: Prims.nat{i <= n} -> Type) ->
f:
(i: Prims.nat{i < n} -> _: a i
-> a (i + 1) * s: Lib.Sequence.seq t {Lib.Sequence.length s == len}) ->
init: a 0 ->
i: Prims.nat{i < n}
-> FStar.Pervasives.Lemma
(ensures
Lib.Sequence.generate_blocks len n (i + 1) a f init ==
(let _ = Lib.Sequence.generate_blocks len n i a f init in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ acc s = _ in
let _ = f i acc in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ acc' s' = _ in
acc', FStar.Seq.Base.append s s')
<:
a (i + 1) * s: Lib.Sequence.seq t {Lib.Sequence.length s == (i + 1) * len})
<:
a (i + 1) * s: Lib.Sequence.seq t {Lib.Sequence.length s == (i + 1) * len})) | {
"end_col": 96,
"end_line": 346,
"start_col": 48,
"start_line": 342
} |
FStar.Pervasives.Lemma | val index_generate_blocks:
#t:Type0
-> len:size_pos
-> max:nat
-> n:pos{n <= max}
-> f:(i:nat{i < max} -> unit -> unit & s:seq t{length s == len})
-> i:nat{i < n * len}
-> Lemma (Math.Lemmas.lemma_mult_le_right len n max;
div_mul_lt len i max;
let a_spec (i:nat{i <= max}) = unit in
let _,s1 = generate_blocks len max n a_spec f () in
let _,s2 = f (i / len) () in
Seq.index s1 i == Seq.index s2 (i % len)) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec index_generate_blocks #t len max n f i =
assert (0 < n);
let a_spec (i:nat{i <= max}) = unit in
let _,s = generate_blocks #t len max (n-1) a_spec f () in
let _,s' = f (n-1) () in
let _,s1 = generate_blocks #t len max n a_spec f () in
unfold_generate_blocks #t len max a_spec f () (n-1);
Seq.Properties.lemma_split s1 (n * len - len);
Seq.Properties.lemma_split (Seq.append s s') (n * len - len);
Seq.lemma_eq_intro s1 (Seq.append s s');
if i < (n-1) * len then
begin
Seq.lemma_index_app1 s s' i;
index_generate_blocks len max (n-1) f i
end
else
begin
Seq.lemma_index_app2 s s' i;
mod_prop len (n-1) i
end | val index_generate_blocks:
#t:Type0
-> len:size_pos
-> max:nat
-> n:pos{n <= max}
-> f:(i:nat{i < max} -> unit -> unit & s:seq t{length s == len})
-> i:nat{i < n * len}
-> Lemma (Math.Lemmas.lemma_mult_le_right len n max;
div_mul_lt len i max;
let a_spec (i:nat{i <= max}) = unit in
let _,s1 = generate_blocks len max n a_spec f () in
let _,s2 = f (i / len) () in
Seq.index s1 i == Seq.index s2 (i % len))
let rec index_generate_blocks #t len max n f i = | false | null | true | assert (0 < n);
let a_spec (i: nat{i <= max}) = unit in
let _, s = generate_blocks #t len max (n - 1) a_spec f () in
let _, s' = f (n - 1) () in
let _, s1 = generate_blocks #t len max n a_spec f () in
unfold_generate_blocks #t len max a_spec f () (n - 1);
Seq.Properties.lemma_split s1 (n * len - len);
Seq.Properties.lemma_split (Seq.append s s') (n * len - len);
Seq.lemma_eq_intro s1 (Seq.append s s');
if i < (n - 1) * len
then
(Seq.lemma_index_app1 s s' i;
index_generate_blocks len max (n - 1) f i)
else
(Seq.lemma_index_app2 s s' i;
mod_prop len (n - 1) i) | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_pos",
"Prims.nat",
"Prims.pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.unit",
"FStar.Pervasives.Native.tuple2",
"Lib.Sequence.seq",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Prims.l_and",
"Prims.op_GreaterThan",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.length",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"Lib.Sequence.index_generate_blocks",
"FStar.Seq.Base.lemma_index_app1",
"Prims.bool",
"Lib.Sequence.mod_prop",
"FStar.Seq.Base.lemma_index_app2",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Seq.Base.append",
"FStar.Seq.Properties.lemma_split",
"Lib.Sequence.unfold_generate_blocks",
"Prims.op_Multiply",
"Lib.Sequence.generate_blocks",
"Prims.pow2",
"Prims.eqtype",
"Prims._assert"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc
let repeati_blocks #a #b bs inp f g init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeati_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
g nb rem last acc
let repeat_blocks #a #b #c bs inp f l init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeat_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
l rem last acc
let lemma_repeat_blocks #a #b #c bs inp f l init = ()
let repeat_blocks_multi #a #b bs inp f init =
let len = length inp in
let nb = len / bs in
repeati nb (repeat_blocks_f bs inp f nb) init
let lemma_repeat_blocks_multi #a #b bs inp f init = ()
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
let acc, o = acc in
let acc', block = f i acc in
let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in
acc', o'
let generate_blocks #t len max n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1)
=
Seq.append acc (f i)
let generate_blocks_simple #a bs max nb f =
repeat_gen nb (generate_blocks_simple_a a bs max)
(generate_blocks_simple_f #a bs max f) Seq.empty
#restart-solver
let div_interval b n i =
Math.Lemmas.lemma_div_le (n * b) i b;
Math.Lemmas.cancel_mul_div n b
let mod_interval_lt b n i j =
div_interval b n i;
div_interval b n j
let div_mul_lt b a n = ()
let mod_div_lt b i j =
mod_interval_lt b (j / b) i j
let div_mul_l a b c d =
calc (==) {
a / (c * d);
== { }
a / (d * c);
== { Math.Lemmas.division_multiplication_lemma a d c }
(a / d) / c;
== { }
(b / d) / c;
== { Math.Lemmas.division_multiplication_lemma b d c }
b / (d * c);
== { }
b / (c * d);
}
let map_blocks_multi #a bs max nb inp f =
repeat_gen nb (map_blocks_a a bs max)
(map_blocks_f #a bs max inp f) Seq.empty
let lemma_map_blocks_multi #a bs max nb inp f = ()
private
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} ->
Lemma (b - a * n == b % n)
let mod_prop n a b =
Math.Lemmas.modulo_lemma (b - a * n) n;
Math.Lemmas.lemma_mod_sub b n a
#push-options "--z3rlimit 200"
let rec index_map_blocks_multi #a bs max n inp f i =
let map_blocks_a = map_blocks_a a bs max in
let map_blocks_f = map_blocks_f #a bs max inp f in
let acc0 = Seq.empty #a in
let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in
unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1);
let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in
//assert (s1 == map_blocks_f (n-1) s);
let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in
//assert (s1 == Seq.append s s');
if i < (n-1)*bs then begin
Seq.lemma_index_app1 s s' i;
index_map_blocks_multi #a bs max (n-1) inp f i end
else begin
Seq.lemma_index_app2 s s' i;
mod_prop bs (n-1) i
end
let map_blocks #a blocksize inp f g =
let len = length inp in
let nb = len / blocksize in
let rem = len % blocksize in
let blocks = Seq.slice inp 0 (nb * blocksize) in
let last = Seq.slice inp (nb * blocksize) len in
let bs = map_blocks_multi #a blocksize nb nb blocks f in
if (rem > 0) then
Seq.append bs (g nb rem last)
else bs
let lemma_map_blocks #a blocksize inp f g = ()
let index_map_blocks #a bs inp f g i =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let blocks = Seq.slice inp 0 (nb * bs) in
if rem > 0 then
begin
let s1 = map_blocks_multi #a bs nb nb blocks f in
let last = Seq.slice inp (nb * bs) len in
calc (==) {
length last;
== { Seq.lemma_len_slice inp (nb * bs) len }
len - nb * bs;
== {mod_prop bs nb len}
len % bs;
== { }
rem;
};
let s2 = g nb rem last in
assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2));
if i < nb * bs then
begin
div_mul_lt bs i nb;
Seq.lemma_index_app1 s1 s2 i;
index_map_blocks_multi bs nb nb blocks f i
end
else
begin
Seq.lemma_index_app2 s1 s2 i;
mod_prop bs nb i
end
end
else index_map_blocks_multi #a bs nb nb blocks f i
let eq_generate_blocks0 #t len n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
assert (generate_blocks #t len n 0 a f acc0 ==
repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0
let unfold_generate_blocks #t len n a f acc0 i =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
assert (generate_blocks #t len n (i+1) a f acc0 ==
repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0);
unfold_repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 i | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val index_generate_blocks:
#t:Type0
-> len:size_pos
-> max:nat
-> n:pos{n <= max}
-> f:(i:nat{i < max} -> unit -> unit & s:seq t{length s == len})
-> i:nat{i < n * len}
-> Lemma (Math.Lemmas.lemma_mult_le_right len n max;
div_mul_lt len i max;
let a_spec (i:nat{i <= max}) = unit in
let _,s1 = generate_blocks len max n a_spec f () in
let _,s2 = f (i / len) () in
Seq.index s1 i == Seq.index s2 (i % len)) | [
"recursion"
] | Lib.Sequence.index_generate_blocks | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_pos ->
max: Prims.nat ->
n: Prims.pos{n <= max} ->
f:
(i: Prims.nat{i < max} -> _: Prims.unit
-> Prims.unit * s: Lib.Sequence.seq t {Lib.Sequence.length s == len}) ->
i: Prims.nat{i < n * len}
-> FStar.Pervasives.Lemma
(ensures
([@@ FStar.Pervasives.inline_let ]let _ = FStar.Math.Lemmas.lemma_mult_le_right len n max in
[@@ FStar.Pervasives.inline_let ]let _ = Lib.Sequence.div_mul_lt len i max in
let a_spec i = Prims.unit in
let _ = Lib.Sequence.generate_blocks len max n a_spec f () in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ _ s1 = _ in
let _ = f (i / len) () in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ _ s2 = _ in
FStar.Seq.Base.index s1 i == FStar.Seq.Base.index s2 (i % len))
<:
Type0)
<:
Type0)) | {
"end_col": 7,
"end_line": 367,
"start_col": 2,
"start_line": 349
} |
FStar.Pervasives.Lemma | val index_map_blocks_multi:
#a:Type0
-> bs:size_pos
-> max:pos
-> n:pos{n <= max}
-> inp:seq a{length inp == max * bs}
-> f:(i:nat{i < max} -> lseq a bs -> lseq a bs)
-> i:nat{i < n * bs}
-> Lemma (
div_mul_lt bs i n;
let j = i / bs in
let block: lseq a bs = Seq.slice inp (j * bs) ((j + 1) * bs) in
Seq.index (map_blocks_multi bs max n inp f) i == Seq.index (f j block) (i % bs)) | [
{
"abbrev": false,
"full_module": "Lib.LoopCombinators",
"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": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec index_map_blocks_multi #a bs max n inp f i =
let map_blocks_a = map_blocks_a a bs max in
let map_blocks_f = map_blocks_f #a bs max inp f in
let acc0 = Seq.empty #a in
let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in
unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1);
let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in
//assert (s1 == map_blocks_f (n-1) s);
let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in
//assert (s1 == Seq.append s s');
if i < (n-1)*bs then begin
Seq.lemma_index_app1 s s' i;
index_map_blocks_multi #a bs max (n-1) inp f i end
else begin
Seq.lemma_index_app2 s s' i;
mod_prop bs (n-1) i
end | val index_map_blocks_multi:
#a:Type0
-> bs:size_pos
-> max:pos
-> n:pos{n <= max}
-> inp:seq a{length inp == max * bs}
-> f:(i:nat{i < max} -> lseq a bs -> lseq a bs)
-> i:nat{i < n * bs}
-> Lemma (
div_mul_lt bs i n;
let j = i / bs in
let block: lseq a bs = Seq.slice inp (j * bs) ((j + 1) * bs) in
Seq.index (map_blocks_multi bs max n inp f) i == Seq.index (f j block) (i % bs))
let rec index_map_blocks_multi #a bs max n inp f i = | false | null | true | let map_blocks_a = map_blocks_a a bs max in
let map_blocks_f = map_blocks_f #a bs max inp f in
let acc0 = Seq.empty #a in
let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in
unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n - 1);
let s = repeat_gen (n - 1) map_blocks_a map_blocks_f acc0 in
let s' = f (n - 1) (Seq.slice inp ((n - 1) * bs) (n * bs)) in
if i < (n - 1) * bs
then
(Seq.lemma_index_app1 s s' i;
index_map_blocks_multi #a bs max (n - 1) inp f i)
else
(Seq.lemma_index_app2 s s' i;
mod_prop bs (n - 1) i) | {
"checked_file": "Lib.Sequence.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.Properties.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.Sequence.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_pos",
"Prims.pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.Sequence.seq",
"Prims.eq2",
"Prims.int",
"Lib.Sequence.length",
"FStar.Mul.op_Star",
"Prims.nat",
"Prims.op_LessThan",
"Lib.Sequence.lseq",
"Prims.op_Subtraction",
"Lib.Sequence.index_map_blocks_multi",
"Prims.unit",
"FStar.Seq.Base.lemma_index_app1",
"Prims.bool",
"Lib.Sequence.mod_prop",
"FStar.Seq.Base.lemma_index_app2",
"FStar.Seq.Base.slice",
"Lib.LoopCombinators.repeat_gen",
"Lib.LoopCombinators.unfold_repeat_gen",
"FStar.Seq.Base.seq",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"FStar.Seq.Base.empty",
"Lib.Sequence.map_blocks_a",
"Prims.op_Addition",
"Lib.Sequence.map_blocks_f"
] | [] | module Lib.Sequence
open FStar.Mul
open Lib.IntTypes
open Lib.LoopCombinators
#set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
let index #a #len s n = Seq.index s n
let create #a len init = Seq.create #a len init
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
let to_list #a s = Seq.seq_to_list s
let of_list #a l = Seq.seq_of_list #a l
let of_list_index #a l i =
Seq.lemma_seq_of_list_index #a l i
let equal #a #len s1 s2 =
forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
let eq_intro #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
let eq_elim #a #len s1 s2 =
assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
index s1 i == index s2 i);
Seq.lemma_eq_elim #a s1 s2
let upd #a #len s n x = Seq.upd #a s n x
let member #a #len x l = Seq.count x l > 0
let sub #a #len s start n = Seq.slice #a s start (start + n)
let update_sub #a #len s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
let lemma_update_sub #a #len dst start n src res =
let res1 = update_sub dst start n src in
Seq.lemma_split (sub res 0 (start + n)) start;
Seq.lemma_split (sub res1 0 (start + n)) start;
Seq.lemma_split res (start + n);
Seq.lemma_split res1 (start + n);
Seq.lemma_eq_intro res (update_sub dst start n src)
let lemma_concat2 #a len0 s0 len1 s1 s =
Seq.Properties.lemma_split s len0;
Seq.Properties.lemma_split (concat s0 s1) len0;
Seq.lemma_eq_intro s (concat s0 s1)
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
let s' = concat (concat s0 s1) s2 in
Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0;
Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0;
Seq.Properties.lemma_split s (len0 + len1);
Seq.Properties.lemma_split s' (len0 + len1);
Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) =
lseq a k
let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len})
(s:createi_a a len init k) =
forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len})
(si:createi_a a len init i)
: r:createi_a a len init (i + 1)
{createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
=
assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j));
Seq.snoc si (init i)
#push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'"
let createi #a len init_f =
repeat_gen_inductive len
(createi_a a len init_f)
(createi_pred a len init_f)
(createi_step a len init_f)
(of_list [])
#pop-options
inline_for_extraction
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) =
f i s.[i]
let mapi #a #b #len f s =
createi #b len (mapi_inner #a #b #len f s)
inline_for_extraction
let map_inner (#a:Type) (#b:Type) (#len:size_nat)
(f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) =
f s.[i]
let map #a #b #len f s =
createi #b len (map_inner #a #b #len f s)
let map2i #a #b #c #len f s1 s2 =
createi #c len (fun i -> f i s1.[i] s2.[i])
inline_for_extraction
let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat)
(f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) =
f s1.[i] s2.[i]
let map2 #a #b #c #len f s1 s2 =
createi #c len (map2_inner #a #b #c #len f s1 s2)
let for_all #a #len f x = Seq.for_all f x
let for_all2 #a #b #len f x y =
let r = map2 (fun xi yi -> f xi yi) x y in
Seq.for_all (fun bi -> bi = true) r
(** Selecting a subset of an unbounded Sequence *)
val seq_sub:
#a:Type
-> s1:seq a
-> start:nat
-> n:nat{start + n <= length s1}
-> s2:seq a{length s2 == n /\
(forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
let seq_sub #a s start n =
Seq.slice #a s start (start + n)
(** Updating a subset of an unbounded Sequence with another Sequence *)
val seq_update_sub:
#a:Type
-> i:seq a
-> start:nat
-> n:nat{start + n <= length i}
-> x:seq a{length x == n}
-> o:seq a{length o == length i /\ seq_sub o start n == x /\
(forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
{:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
let seq_update_sub #a s start n x =
let o =
Seq.append
(Seq.append (Seq.slice s 0 start) x)
(Seq.slice s (start + n) (length s)) in
Seq.lemma_eq_intro (Seq.slice o start (start + n)) x;
o
val repeati_blocks_f:
#a:Type0
-> #b:Type0
-> blocksize:size_nat{blocksize > 0}
-> inp:seq a
-> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b)
-> nb:nat{nb == length inp / blocksize}
-> i:nat{i < nb}
-> acc:b
-> b
let repeati_blocks_f #a #b bs inp f nb i acc =
assert ((i+1) * bs <= nb * bs);
let block = seq_sub inp (i * bs) bs in
f i block acc
let repeati_blocks #a #b bs inp f g init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeati_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
g nb rem last acc
let repeat_blocks #a #b #c bs inp f l init =
let len = length inp in
let nb = len / bs in
let rem = len % bs in
let acc = repeati nb (repeat_blocks_f bs inp f nb) init in
let last = seq_sub inp (nb * bs) rem in
l rem last acc
let lemma_repeat_blocks #a #b #c bs inp f l init = ()
let repeat_blocks_multi #a #b bs inp f init =
let len = length inp in
let nb = len / bs in
repeati nb (repeat_blocks_f bs inp f nb) init
let lemma_repeat_blocks_multi #a #b bs inp f init = ()
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
let acc, o = acc in
let acc', block = f i acc in
let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in
acc', o'
let generate_blocks #t len max n a f acc0 =
let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in
repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_f
(#a:Type)
(bs:size_nat{bs > 0})
(max:nat)
(f:(i:nat{i < max} -> lseq a bs))
(i:nat{i < max})
(acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1)
=
Seq.append acc (f i)
let generate_blocks_simple #a bs max nb f =
repeat_gen nb (generate_blocks_simple_a a bs max)
(generate_blocks_simple_f #a bs max f) Seq.empty
#restart-solver
let div_interval b n i =
Math.Lemmas.lemma_div_le (n * b) i b;
Math.Lemmas.cancel_mul_div n b
let mod_interval_lt b n i j =
div_interval b n i;
div_interval b n j
let div_mul_lt b a n = ()
let mod_div_lt b i j =
mod_interval_lt b (j / b) i j
let div_mul_l a b c d =
calc (==) {
a / (c * d);
== { }
a / (d * c);
== { Math.Lemmas.division_multiplication_lemma a d c }
(a / d) / c;
== { }
(b / d) / c;
== { Math.Lemmas.division_multiplication_lemma b d c }
b / (d * c);
== { }
b / (c * d);
}
let map_blocks_multi #a bs max nb inp f =
repeat_gen nb (map_blocks_a a bs max)
(map_blocks_f #a bs max inp f) Seq.empty
let lemma_map_blocks_multi #a bs max nb inp f = ()
private
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} ->
Lemma (b - a * n == b % n)
let mod_prop n a b =
Math.Lemmas.modulo_lemma (b - a * n) n;
Math.Lemmas.lemma_mod_sub b n a
#push-options "--z3rlimit 200" | false | false | Lib.Sequence.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val index_map_blocks_multi:
#a:Type0
-> bs:size_pos
-> max:pos
-> n:pos{n <= max}
-> inp:seq a{length inp == max * bs}
-> f:(i:nat{i < max} -> lseq a bs -> lseq a bs)
-> i:nat{i < n * bs}
-> Lemma (
div_mul_lt bs i n;
let j = i / bs in
let block: lseq a bs = Seq.slice inp (j * bs) ((j + 1) * bs) in
Seq.index (map_blocks_multi bs max n inp f) i == Seq.index (f j block) (i % bs)) | [
"recursion"
] | Lib.Sequence.index_map_blocks_multi | {
"file_name": "lib/Lib.Sequence.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
bs: Lib.IntTypes.size_pos ->
max: Prims.pos ->
n: Prims.pos{n <= max} ->
inp: Lib.Sequence.seq a {Lib.Sequence.length inp == max * bs} ->
f: (i: Prims.nat{i < max} -> _: Lib.Sequence.lseq a bs -> Lib.Sequence.lseq a bs) ->
i: Prims.nat{i < n * bs}
-> FStar.Pervasives.Lemma
(ensures
([@@ FStar.Pervasives.inline_let ]let _ = Lib.Sequence.div_mul_lt bs i n in
let j = i / bs in
let block = FStar.Seq.Base.slice inp (j * bs) ((j + 1) * bs) in
FStar.Seq.Base.index (Lib.Sequence.map_blocks_multi bs max n inp f) i ==
FStar.Seq.Base.index (f j block) (i % bs))) | {
"end_col": 5,
"end_line": 287,
"start_col": 52,
"start_line": 271
} |
Prims.Tot | val size32_u8:size32 serialize_u8 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let size32_u8: size32 serialize_u8 =
assert_norm (size32_constant_precond serialize_u8 1ul);
size32_constant serialize_u8 1ul () | val size32_u8:size32 serialize_u8
let size32_u8:size32 serialize_u8 = | false | null | false | assert_norm (size32_constant_precond serialize_u8 1ul);
size32_constant serialize_u8 1ul () | {
"checked_file": "LowParse.SLow.Int.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.SLow.Base.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Int.fsti"
} | [
"total"
] | [
"LowParse.SLow.Base.size32_constant",
"LowParse.Spec.Int.parse_u8_kind",
"FStar.UInt8.t",
"LowParse.Spec.Int.parse_u8",
"LowParse.Spec.Int.serialize_u8",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"LowParse.SLow.Base.size32_constant_precond"
] | [] | module LowParse.SLow.Int
include LowParse.Spec.Int
include LowParse.SLow.Base
inline_for_extraction
val parse32_u8: parser32 parse_u8
inline_for_extraction
val serialize32_u8 : serializer32 serialize_u8
inline_for_extraction
val parse32_u16: parser32 parse_u16
inline_for_extraction
val serialize32_u16 : serializer32 serialize_u16
inline_for_extraction
val parse32_u32: parser32 parse_u32
inline_for_extraction
val serialize32_u32 : serializer32 serialize_u32
inline_for_extraction
val parse32_u64: parser32 parse_u64
inline_for_extraction
val serialize32_u64 : serializer32 serialize_u64
// the `assert_norm`s are for the .fst, interleaving semantics again
inline_for_extraction | false | true | LowParse.SLow.Int.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val size32_u8:size32 serialize_u8 | [] | LowParse.SLow.Int.size32_u8 | {
"file_name": "src/lowparse/LowParse.SLow.Int.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.SLow.Base.size32 LowParse.Spec.Int.serialize_u8 | {
"end_col": 37,
"end_line": 34,
"start_col": 2,
"start_line": 33
} |
Prims.Tot | val size32_u64:size32 serialize_u64 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let size32_u64: size32 serialize_u64 =
assert_norm (size32_constant_precond serialize_u64 8ul);
size32_constant serialize_u64 8ul () | val size32_u64:size32 serialize_u64
let size32_u64:size32 serialize_u64 = | false | null | false | assert_norm (size32_constant_precond serialize_u64 8ul);
size32_constant serialize_u64 8ul () | {
"checked_file": "LowParse.SLow.Int.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.SLow.Base.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Int.fsti"
} | [
"total"
] | [
"LowParse.SLow.Base.size32_constant",
"LowParse.Spec.Int.parse_u64_kind",
"FStar.UInt64.t",
"LowParse.Spec.Int.parse_u64",
"LowParse.Spec.Int.serialize_u64",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"LowParse.SLow.Base.size32_constant_precond"
] | [] | module LowParse.SLow.Int
include LowParse.Spec.Int
include LowParse.SLow.Base
inline_for_extraction
val parse32_u8: parser32 parse_u8
inline_for_extraction
val serialize32_u8 : serializer32 serialize_u8
inline_for_extraction
val parse32_u16: parser32 parse_u16
inline_for_extraction
val serialize32_u16 : serializer32 serialize_u16
inline_for_extraction
val parse32_u32: parser32 parse_u32
inline_for_extraction
val serialize32_u32 : serializer32 serialize_u32
inline_for_extraction
val parse32_u64: parser32 parse_u64
inline_for_extraction
val serialize32_u64 : serializer32 serialize_u64
// the `assert_norm`s are for the .fst, interleaving semantics again
inline_for_extraction
let size32_u8: size32 serialize_u8 =
assert_norm (size32_constant_precond serialize_u8 1ul);
size32_constant serialize_u8 1ul ()
inline_for_extraction
let size32_u16: size32 serialize_u16 =
assert_norm (size32_constant_precond serialize_u16 2ul);
size32_constant serialize_u16 2ul ()
inline_for_extraction
let size32_u32: size32 serialize_u32 =
assert_norm (size32_constant_precond serialize_u32 4ul);
size32_constant serialize_u32 4ul ()
inline_for_extraction | false | true | LowParse.SLow.Int.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val size32_u64:size32 serialize_u64 | [] | LowParse.SLow.Int.size32_u64 | {
"file_name": "src/lowparse/LowParse.SLow.Int.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.SLow.Base.size32 LowParse.Spec.Int.serialize_u64 | {
"end_col": 38,
"end_line": 49,
"start_col": 2,
"start_line": 48
} |
Prims.Tot | val size32_u16:size32 serialize_u16 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let size32_u16: size32 serialize_u16 =
assert_norm (size32_constant_precond serialize_u16 2ul);
size32_constant serialize_u16 2ul () | val size32_u16:size32 serialize_u16
let size32_u16:size32 serialize_u16 = | false | null | false | assert_norm (size32_constant_precond serialize_u16 2ul);
size32_constant serialize_u16 2ul () | {
"checked_file": "LowParse.SLow.Int.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.SLow.Base.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Int.fsti"
} | [
"total"
] | [
"LowParse.SLow.Base.size32_constant",
"LowParse.Spec.Int.parse_u16_kind",
"FStar.UInt16.t",
"LowParse.Spec.Int.parse_u16",
"LowParse.Spec.Int.serialize_u16",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"LowParse.SLow.Base.size32_constant_precond"
] | [] | module LowParse.SLow.Int
include LowParse.Spec.Int
include LowParse.SLow.Base
inline_for_extraction
val parse32_u8: parser32 parse_u8
inline_for_extraction
val serialize32_u8 : serializer32 serialize_u8
inline_for_extraction
val parse32_u16: parser32 parse_u16
inline_for_extraction
val serialize32_u16 : serializer32 serialize_u16
inline_for_extraction
val parse32_u32: parser32 parse_u32
inline_for_extraction
val serialize32_u32 : serializer32 serialize_u32
inline_for_extraction
val parse32_u64: parser32 parse_u64
inline_for_extraction
val serialize32_u64 : serializer32 serialize_u64
// the `assert_norm`s are for the .fst, interleaving semantics again
inline_for_extraction
let size32_u8: size32 serialize_u8 =
assert_norm (size32_constant_precond serialize_u8 1ul);
size32_constant serialize_u8 1ul ()
inline_for_extraction | false | true | LowParse.SLow.Int.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val size32_u16:size32 serialize_u16 | [] | LowParse.SLow.Int.size32_u16 | {
"file_name": "src/lowparse/LowParse.SLow.Int.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.SLow.Base.size32 LowParse.Spec.Int.serialize_u16 | {
"end_col": 38,
"end_line": 39,
"start_col": 2,
"start_line": 38
} |
Prims.Tot | val size32_u32:size32 serialize_u32 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let size32_u32: size32 serialize_u32 =
assert_norm (size32_constant_precond serialize_u32 4ul);
size32_constant serialize_u32 4ul () | val size32_u32:size32 serialize_u32
let size32_u32:size32 serialize_u32 = | false | null | false | assert_norm (size32_constant_precond serialize_u32 4ul);
size32_constant serialize_u32 4ul () | {
"checked_file": "LowParse.SLow.Int.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.SLow.Base.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Int.fsti"
} | [
"total"
] | [
"LowParse.SLow.Base.size32_constant",
"LowParse.Spec.Int.parse_u32_kind",
"FStar.UInt32.t",
"LowParse.Spec.Int.parse_u32",
"LowParse.Spec.Int.serialize_u32",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"LowParse.SLow.Base.size32_constant_precond"
] | [] | module LowParse.SLow.Int
include LowParse.Spec.Int
include LowParse.SLow.Base
inline_for_extraction
val parse32_u8: parser32 parse_u8
inline_for_extraction
val serialize32_u8 : serializer32 serialize_u8
inline_for_extraction
val parse32_u16: parser32 parse_u16
inline_for_extraction
val serialize32_u16 : serializer32 serialize_u16
inline_for_extraction
val parse32_u32: parser32 parse_u32
inline_for_extraction
val serialize32_u32 : serializer32 serialize_u32
inline_for_extraction
val parse32_u64: parser32 parse_u64
inline_for_extraction
val serialize32_u64 : serializer32 serialize_u64
// the `assert_norm`s are for the .fst, interleaving semantics again
inline_for_extraction
let size32_u8: size32 serialize_u8 =
assert_norm (size32_constant_precond serialize_u8 1ul);
size32_constant serialize_u8 1ul ()
inline_for_extraction
let size32_u16: size32 serialize_u16 =
assert_norm (size32_constant_precond serialize_u16 2ul);
size32_constant serialize_u16 2ul ()
inline_for_extraction | false | true | LowParse.SLow.Int.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val size32_u32:size32 serialize_u32 | [] | LowParse.SLow.Int.size32_u32 | {
"file_name": "src/lowparse/LowParse.SLow.Int.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.SLow.Base.size32 LowParse.Spec.Int.serialize_u32 | {
"end_col": 38,
"end_line": 44,
"start_col": 2,
"start_line": 43
} |
FStar.HyperStack.ST.Stack | val make_order: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.order) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_order n =
// 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551
[@inline_let] let n0 = u64 0xf3b9cac2fc632551 in
[@inline_let] let n1 = u64 0xbce6faada7179e84 in
[@inline_let] let n2 = u64 0xffffffffffffffff in
[@inline_let] let n3 = u64 0xffffffff00000000 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.order);
bn_make_u64_4 n n0 n1 n2 n3 | val make_order: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.order)
let make_order n = | true | null | false | [@@ inline_let ]let n0 = u64 0xf3b9cac2fc632551 in
[@@ inline_let ]let n1 = u64 0xbce6faada7179e84 in
[@@ inline_let ]let n2 = u64 0xffffffffffffffff in
[@@ inline_let ]let n3 = u64 0xffffffff00000000 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.order);
bn_make_u64_4 n n0 n1 n2 n3 | {
"checked_file": "Hacl.Impl.P256.Constants.fst.checked",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Constants.fst"
} | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Bignum.bn_make_u64_4",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Prims.pow2",
"Spec.P256.PointOps.order",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Lib.IntTypes.range",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.P256.Constants
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val make_prime: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.prime)
[@CInline]
let make_prime n =
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
[@inline_let] let n0 = u64 0xffffffffffffffff in
[@inline_let] let n1 = u64 0xffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xffffffff00000001 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.prime);
bn_make_u64_4 n n0 n1 n2 n3
val make_order: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.order)
[@CInline]
let make_order n = | false | false | Hacl.Impl.P256.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_order: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.order) | [] | Hacl.Impl.P256.Constants.make_order | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 29,
"end_line": 47,
"start_col": 2,
"start_line": 42
} |
FStar.HyperStack.ST.Stack | val make_prime: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.prime) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_prime n =
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
[@inline_let] let n0 = u64 0xffffffffffffffff in
[@inline_let] let n1 = u64 0xffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xffffffff00000001 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.prime);
bn_make_u64_4 n n0 n1 n2 n3 | val make_prime: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.prime)
let make_prime n = | true | null | false | [@@ inline_let ]let n0 = u64 0xffffffffffffffff in
[@@ inline_let ]let n1 = u64 0xffffffff in
[@@ inline_let ]let n2 = u64 0x0 in
[@@ inline_let ]let n3 = u64 0xffffffff00000001 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.prime);
bn_make_u64_4 n n0 n1 n2 n3 | {
"checked_file": "Hacl.Impl.P256.Constants.fst.checked",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Constants.fst"
} | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Bignum.bn_make_u64_4",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Prims.pow2",
"Spec.P256.PointOps.prime",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Lib.IntTypes.range",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.P256.Constants
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val make_prime: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.prime)
[@CInline]
let make_prime n = | false | false | Hacl.Impl.P256.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_prime: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.prime) | [] | Hacl.Impl.P256.Constants.make_prime | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 29,
"end_line": 31,
"start_col": 2,
"start_line": 26
} |
FStar.HyperStack.ST.Stack | val make_fmont_R2: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == SM.fmont_R * SM.fmont_R % S.prime) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_fmont_R2 n =
// 0x4fffffffdfffffffffffffffefffffffbffffffff0000000000000003
[@inline_let] let n0 = u64 0x3 in
[@inline_let] let n1 = u64 0xfffffffbffffffff in
[@inline_let] let n2 = u64 0xfffffffffffffffe in
[@inline_let] let n3 = u64 0x4fffffffd in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 ==
SM.fmont_R * SM.fmont_R % S.prime);
bn_make_u64_4 n n0 n1 n2 n3 | val make_fmont_R2: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == SM.fmont_R * SM.fmont_R % S.prime)
let make_fmont_R2 n = | true | null | false | [@@ inline_let ]let n0 = u64 0x3 in
[@@ inline_let ]let n1 = u64 0xfffffffbffffffff in
[@@ inline_let ]let n2 = u64 0xfffffffffffffffe in
[@@ inline_let ]let n3 = u64 0x4fffffffd in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 ==
SM.fmont_R * SM.fmont_R % S.prime);
bn_make_u64_4 n n0 n1 n2 n3 | {
"checked_file": "Hacl.Impl.P256.Constants.fst.checked",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Constants.fst"
} | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Bignum.bn_make_u64_4",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.op_Modulus",
"Hacl.Spec.P256.Montgomery.fmont_R",
"Spec.P256.PointOps.prime",
"Lib.IntTypes.int_t",
"Lib.IntTypes.range",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.P256.Constants
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val make_prime: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.prime)
[@CInline]
let make_prime n =
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
[@inline_let] let n0 = u64 0xffffffffffffffff in
[@inline_let] let n1 = u64 0xffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xffffffff00000001 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.prime);
bn_make_u64_4 n n0 n1 n2 n3
val make_order: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.order)
[@CInline]
let make_order n =
// 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551
[@inline_let] let n0 = u64 0xf3b9cac2fc632551 in
[@inline_let] let n1 = u64 0xbce6faada7179e84 in
[@inline_let] let n2 = u64 0xffffffffffffffff in
[@inline_let] let n3 = u64 0xffffffff00000000 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.order);
bn_make_u64_4 n n0 n1 n2 n3
val make_a_coeff: a:felem -> Stack unit
(requires fun h -> live h a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_nat h1 a < S.prime /\
SM.from_mont (as_nat h1 a) == S.a_coeff)
[@CInline]
let make_a_coeff a =
// a_coeff = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc
// a_coeff_mont = 0xfffffffc00000004000000000000000000000003fffffffffffffffffffffffc
[@inline_let] let n0 = u64 0xfffffffffffffffc in
[@inline_let] let n1 = u64 0x3ffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xfffffffc00000004 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.a_coeff == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.a_coeff;
bn_make_u64_4 a n0 n1 n2 n3
val make_b_coeff: b:felem -> Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_nat h1 b < S.prime /\
SM.from_mont (as_nat h1 b) == S.b_coeff)
[@CInline]
let make_b_coeff b =
// b_coeff = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b
// b_coeff_mont = 0xdc30061d04874834e5a220abf7212ed6acf005cd78843090d89cdf6229c4bddf
[@inline_let] let n0 = u64 0xd89cdf6229c4bddf in
[@inline_let] let n1 = u64 0xacf005cd78843090 in
[@inline_let] let n2 = u64 0xe5a220abf7212ed6 in
[@inline_let] let n3 = u64 0xdc30061d04874834 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.b_coeff == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.b_coeff;
bn_make_u64_4 b n0 n1 n2 n3
val make_g_x: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n < S.prime /\
SM.from_mont (as_nat h1 n) == S.g_x)
[@CInline]
let make_g_x n =
// g_x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296
// mont_g_x = 0x18905f76a53755c679fb732b7762251075ba95fc5fedb60179e730d418a9143c
[@inline_let] let n0 = u64 0x79e730d418a9143c in
[@inline_let] let n1 = u64 0x75ba95fc5fedb601 in
[@inline_let] let n2 = u64 0x79fb732b77622510 in
[@inline_let] let n3 = u64 0x18905f76a53755c6 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.g_x == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.g_x;
bn_make_u64_4 n n0 n1 n2 n3
val make_g_y: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n < S.prime /\
SM.from_mont (as_nat h1 n) == S.g_y)
[@CInline]
let make_g_y n =
// g_y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5
// mont_g_x = 0x8571ff1825885d85d2e88688dd21f3258b4ab8e4ba19e45cddf25357ce95560a
[@inline_let] let n0 = u64 0xddf25357ce95560a in
[@inline_let] let n1 = u64 0x8b4ab8e4ba19e45c in
[@inline_let] let n2 = u64 0xd2e88688dd21f325 in
[@inline_let] let n3 = u64 0x8571ff1825885d85 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.g_y == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.g_y;
bn_make_u64_4 n n0 n1 n2 n3
val make_fmont_R2: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == SM.fmont_R * SM.fmont_R % S.prime)
[@CInline]
let make_fmont_R2 n = | false | false | Hacl.Impl.P256.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_fmont_R2: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == SM.fmont_R * SM.fmont_R % S.prime) | [] | Hacl.Impl.P256.Constants.make_fmont_R2 | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 29,
"end_line": 144,
"start_col": 2,
"start_line": 138
} |
FStar.HyperStack.ST.Stack | val make_g_y: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n < S.prime /\
SM.from_mont (as_nat h1 n) == S.g_y) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_g_y n =
// g_y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5
// mont_g_x = 0x8571ff1825885d85d2e88688dd21f3258b4ab8e4ba19e45cddf25357ce95560a
[@inline_let] let n0 = u64 0xddf25357ce95560a in
[@inline_let] let n1 = u64 0x8b4ab8e4ba19e45c in
[@inline_let] let n2 = u64 0xd2e88688dd21f325 in
[@inline_let] let n3 = u64 0x8571ff1825885d85 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.g_y == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.g_y;
bn_make_u64_4 n n0 n1 n2 n3 | val make_g_y: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n < S.prime /\
SM.from_mont (as_nat h1 n) == S.g_y)
let make_g_y n = | true | null | false | [@@ inline_let ]let n0 = u64 0xddf25357ce95560a in
[@@ inline_let ]let n1 = u64 0x8b4ab8e4ba19e45c in
[@@ inline_let ]let n2 = u64 0xd2e88688dd21f325 in
[@@ inline_let ]let n3 = u64 0x8571ff1825885d85 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.g_y == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.g_y;
bn_make_u64_4 n n0 n1 n2 n3 | {
"checked_file": "Hacl.Impl.P256.Constants.fst.checked",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Constants.fst"
} | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Bignum.bn_make_u64_4",
"Prims.unit",
"Hacl.Spec.P256.Montgomery.lemma_to_from_mont_id",
"Spec.P256.PointOps.g_y",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.P256.Montgomery.to_mont",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.P256.PointOps.prime",
"Lib.IntTypes.int_t",
"Lib.IntTypes.range",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.P256.Constants
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val make_prime: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.prime)
[@CInline]
let make_prime n =
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
[@inline_let] let n0 = u64 0xffffffffffffffff in
[@inline_let] let n1 = u64 0xffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xffffffff00000001 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.prime);
bn_make_u64_4 n n0 n1 n2 n3
val make_order: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.order)
[@CInline]
let make_order n =
// 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551
[@inline_let] let n0 = u64 0xf3b9cac2fc632551 in
[@inline_let] let n1 = u64 0xbce6faada7179e84 in
[@inline_let] let n2 = u64 0xffffffffffffffff in
[@inline_let] let n3 = u64 0xffffffff00000000 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.order);
bn_make_u64_4 n n0 n1 n2 n3
val make_a_coeff: a:felem -> Stack unit
(requires fun h -> live h a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_nat h1 a < S.prime /\
SM.from_mont (as_nat h1 a) == S.a_coeff)
[@CInline]
let make_a_coeff a =
// a_coeff = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc
// a_coeff_mont = 0xfffffffc00000004000000000000000000000003fffffffffffffffffffffffc
[@inline_let] let n0 = u64 0xfffffffffffffffc in
[@inline_let] let n1 = u64 0x3ffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xfffffffc00000004 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.a_coeff == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.a_coeff;
bn_make_u64_4 a n0 n1 n2 n3
val make_b_coeff: b:felem -> Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_nat h1 b < S.prime /\
SM.from_mont (as_nat h1 b) == S.b_coeff)
[@CInline]
let make_b_coeff b =
// b_coeff = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b
// b_coeff_mont = 0xdc30061d04874834e5a220abf7212ed6acf005cd78843090d89cdf6229c4bddf
[@inline_let] let n0 = u64 0xd89cdf6229c4bddf in
[@inline_let] let n1 = u64 0xacf005cd78843090 in
[@inline_let] let n2 = u64 0xe5a220abf7212ed6 in
[@inline_let] let n3 = u64 0xdc30061d04874834 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.b_coeff == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.b_coeff;
bn_make_u64_4 b n0 n1 n2 n3
val make_g_x: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n < S.prime /\
SM.from_mont (as_nat h1 n) == S.g_x)
[@CInline]
let make_g_x n =
// g_x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296
// mont_g_x = 0x18905f76a53755c679fb732b7762251075ba95fc5fedb60179e730d418a9143c
[@inline_let] let n0 = u64 0x79e730d418a9143c in
[@inline_let] let n1 = u64 0x75ba95fc5fedb601 in
[@inline_let] let n2 = u64 0x79fb732b77622510 in
[@inline_let] let n3 = u64 0x18905f76a53755c6 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.g_x == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.g_x;
bn_make_u64_4 n n0 n1 n2 n3
val make_g_y: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n < S.prime /\
SM.from_mont (as_nat h1 n) == S.g_y)
[@CInline]
let make_g_y n =
// g_y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 | false | false | Hacl.Impl.P256.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_g_y: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n < S.prime /\
SM.from_mont (as_nat h1 n) == S.g_y) | [] | Hacl.Impl.P256.Constants.make_g_y | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 29,
"end_line": 127,
"start_col": 2,
"start_line": 120
} |
FStar.HyperStack.ST.Stack | val make_b_coeff: b:felem -> Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_nat h1 b < S.prime /\
SM.from_mont (as_nat h1 b) == S.b_coeff) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_b_coeff b =
// b_coeff = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b
// b_coeff_mont = 0xdc30061d04874834e5a220abf7212ed6acf005cd78843090d89cdf6229c4bddf
[@inline_let] let n0 = u64 0xd89cdf6229c4bddf in
[@inline_let] let n1 = u64 0xacf005cd78843090 in
[@inline_let] let n2 = u64 0xe5a220abf7212ed6 in
[@inline_let] let n3 = u64 0xdc30061d04874834 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.b_coeff == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.b_coeff;
bn_make_u64_4 b n0 n1 n2 n3 | val make_b_coeff: b:felem -> Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_nat h1 b < S.prime /\
SM.from_mont (as_nat h1 b) == S.b_coeff)
let make_b_coeff b = | true | null | false | [@@ inline_let ]let n0 = u64 0xd89cdf6229c4bddf in
[@@ inline_let ]let n1 = u64 0xacf005cd78843090 in
[@@ inline_let ]let n2 = u64 0xe5a220abf7212ed6 in
[@@ inline_let ]let n3 = u64 0xdc30061d04874834 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.b_coeff == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.b_coeff;
bn_make_u64_4 b n0 n1 n2 n3 | {
"checked_file": "Hacl.Impl.P256.Constants.fst.checked",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Constants.fst"
} | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Bignum.bn_make_u64_4",
"Prims.unit",
"Hacl.Spec.P256.Montgomery.lemma_to_from_mont_id",
"Spec.P256.PointOps.b_coeff",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.P256.Montgomery.to_mont",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.P256.PointOps.prime",
"Lib.IntTypes.int_t",
"Lib.IntTypes.range",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.P256.Constants
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val make_prime: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.prime)
[@CInline]
let make_prime n =
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
[@inline_let] let n0 = u64 0xffffffffffffffff in
[@inline_let] let n1 = u64 0xffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xffffffff00000001 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.prime);
bn_make_u64_4 n n0 n1 n2 n3
val make_order: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.order)
[@CInline]
let make_order n =
// 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551
[@inline_let] let n0 = u64 0xf3b9cac2fc632551 in
[@inline_let] let n1 = u64 0xbce6faada7179e84 in
[@inline_let] let n2 = u64 0xffffffffffffffff in
[@inline_let] let n3 = u64 0xffffffff00000000 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.order);
bn_make_u64_4 n n0 n1 n2 n3
val make_a_coeff: a:felem -> Stack unit
(requires fun h -> live h a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_nat h1 a < S.prime /\
SM.from_mont (as_nat h1 a) == S.a_coeff)
[@CInline]
let make_a_coeff a =
// a_coeff = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc
// a_coeff_mont = 0xfffffffc00000004000000000000000000000003fffffffffffffffffffffffc
[@inline_let] let n0 = u64 0xfffffffffffffffc in
[@inline_let] let n1 = u64 0x3ffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xfffffffc00000004 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.a_coeff == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.a_coeff;
bn_make_u64_4 a n0 n1 n2 n3
val make_b_coeff: b:felem -> Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_nat h1 b < S.prime /\
SM.from_mont (as_nat h1 b) == S.b_coeff)
[@CInline]
let make_b_coeff b =
// b_coeff = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b | false | false | Hacl.Impl.P256.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_b_coeff: b:felem -> Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_nat h1 b < S.prime /\
SM.from_mont (as_nat h1 b) == S.b_coeff) | [] | Hacl.Impl.P256.Constants.make_b_coeff | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 29,
"end_line": 87,
"start_col": 2,
"start_line": 80
} |
FStar.HyperStack.ST.Stack | val make_g_x: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n < S.prime /\
SM.from_mont (as_nat h1 n) == S.g_x) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_g_x n =
// g_x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296
// mont_g_x = 0x18905f76a53755c679fb732b7762251075ba95fc5fedb60179e730d418a9143c
[@inline_let] let n0 = u64 0x79e730d418a9143c in
[@inline_let] let n1 = u64 0x75ba95fc5fedb601 in
[@inline_let] let n2 = u64 0x79fb732b77622510 in
[@inline_let] let n3 = u64 0x18905f76a53755c6 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.g_x == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.g_x;
bn_make_u64_4 n n0 n1 n2 n3 | val make_g_x: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n < S.prime /\
SM.from_mont (as_nat h1 n) == S.g_x)
let make_g_x n = | true | null | false | [@@ inline_let ]let n0 = u64 0x79e730d418a9143c in
[@@ inline_let ]let n1 = u64 0x75ba95fc5fedb601 in
[@@ inline_let ]let n2 = u64 0x79fb732b77622510 in
[@@ inline_let ]let n3 = u64 0x18905f76a53755c6 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.g_x == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.g_x;
bn_make_u64_4 n n0 n1 n2 n3 | {
"checked_file": "Hacl.Impl.P256.Constants.fst.checked",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Constants.fst"
} | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Bignum.bn_make_u64_4",
"Prims.unit",
"Hacl.Spec.P256.Montgomery.lemma_to_from_mont_id",
"Spec.P256.PointOps.g_x",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.P256.Montgomery.to_mont",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.P256.PointOps.prime",
"Lib.IntTypes.int_t",
"Lib.IntTypes.range",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.P256.Constants
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val make_prime: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.prime)
[@CInline]
let make_prime n =
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
[@inline_let] let n0 = u64 0xffffffffffffffff in
[@inline_let] let n1 = u64 0xffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xffffffff00000001 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.prime);
bn_make_u64_4 n n0 n1 n2 n3
val make_order: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.order)
[@CInline]
let make_order n =
// 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551
[@inline_let] let n0 = u64 0xf3b9cac2fc632551 in
[@inline_let] let n1 = u64 0xbce6faada7179e84 in
[@inline_let] let n2 = u64 0xffffffffffffffff in
[@inline_let] let n3 = u64 0xffffffff00000000 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.order);
bn_make_u64_4 n n0 n1 n2 n3
val make_a_coeff: a:felem -> Stack unit
(requires fun h -> live h a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_nat h1 a < S.prime /\
SM.from_mont (as_nat h1 a) == S.a_coeff)
[@CInline]
let make_a_coeff a =
// a_coeff = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc
// a_coeff_mont = 0xfffffffc00000004000000000000000000000003fffffffffffffffffffffffc
[@inline_let] let n0 = u64 0xfffffffffffffffc in
[@inline_let] let n1 = u64 0x3ffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xfffffffc00000004 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.a_coeff == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.a_coeff;
bn_make_u64_4 a n0 n1 n2 n3
val make_b_coeff: b:felem -> Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_nat h1 b < S.prime /\
SM.from_mont (as_nat h1 b) == S.b_coeff)
[@CInline]
let make_b_coeff b =
// b_coeff = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b
// b_coeff_mont = 0xdc30061d04874834e5a220abf7212ed6acf005cd78843090d89cdf6229c4bddf
[@inline_let] let n0 = u64 0xd89cdf6229c4bddf in
[@inline_let] let n1 = u64 0xacf005cd78843090 in
[@inline_let] let n2 = u64 0xe5a220abf7212ed6 in
[@inline_let] let n3 = u64 0xdc30061d04874834 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.b_coeff == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.b_coeff;
bn_make_u64_4 b n0 n1 n2 n3
val make_g_x: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n < S.prime /\
SM.from_mont (as_nat h1 n) == S.g_x)
[@CInline]
let make_g_x n =
// g_x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 | false | false | Hacl.Impl.P256.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_g_x: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n < S.prime /\
SM.from_mont (as_nat h1 n) == S.g_x) | [] | Hacl.Impl.P256.Constants.make_g_x | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 29,
"end_line": 107,
"start_col": 2,
"start_line": 100
} |
FStar.HyperStack.ST.Stack | val make_a_coeff: a:felem -> Stack unit
(requires fun h -> live h a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_nat h1 a < S.prime /\
SM.from_mont (as_nat h1 a) == S.a_coeff) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_a_coeff a =
// a_coeff = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc
// a_coeff_mont = 0xfffffffc00000004000000000000000000000003fffffffffffffffffffffffc
[@inline_let] let n0 = u64 0xfffffffffffffffc in
[@inline_let] let n1 = u64 0x3ffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xfffffffc00000004 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.a_coeff == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.a_coeff;
bn_make_u64_4 a n0 n1 n2 n3 | val make_a_coeff: a:felem -> Stack unit
(requires fun h -> live h a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_nat h1 a < S.prime /\
SM.from_mont (as_nat h1 a) == S.a_coeff)
let make_a_coeff a = | true | null | false | [@@ inline_let ]let n0 = u64 0xfffffffffffffffc in
[@@ inline_let ]let n1 = u64 0x3ffffffff in
[@@ inline_let ]let n2 = u64 0x0 in
[@@ inline_let ]let n3 = u64 0xfffffffc00000004 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 < S.prime);
assert_norm (SM.to_mont S.a_coeff == v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192);
SM.lemma_to_from_mont_id S.a_coeff;
bn_make_u64_4 a n0 n1 n2 n3 | {
"checked_file": "Hacl.Impl.P256.Constants.fst.checked",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.P256.Constants.fst"
} | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Bignum.bn_make_u64_4",
"Prims.unit",
"Hacl.Spec.P256.Montgomery.lemma_to_from_mont_id",
"Spec.P256.PointOps.a_coeff",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.P256.Montgomery.to_mont",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.P256.PointOps.prime",
"Lib.IntTypes.int_t",
"Lib.IntTypes.range",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.P256.Constants
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val make_prime: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.prime)
[@CInline]
let make_prime n =
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
[@inline_let] let n0 = u64 0xffffffffffffffff in
[@inline_let] let n1 = u64 0xffffffff in
[@inline_let] let n2 = u64 0x0 in
[@inline_let] let n3 = u64 0xffffffff00000001 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.prime);
bn_make_u64_4 n n0 n1 n2 n3
val make_order: n:felem -> Stack unit
(requires fun h -> live h n)
(ensures fun h0 _ h1 -> modifies (loc n) h0 h1 /\
as_nat h1 n == S.order)
[@CInline]
let make_order n =
// 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551
[@inline_let] let n0 = u64 0xf3b9cac2fc632551 in
[@inline_let] let n1 = u64 0xbce6faada7179e84 in
[@inline_let] let n2 = u64 0xffffffffffffffff in
[@inline_let] let n3 = u64 0xffffffff00000000 in
assert_norm (v n0 + v n1 * pow2 64 + v n2 * pow2 128 + v n3 * pow2 192 = S.order);
bn_make_u64_4 n n0 n1 n2 n3
val make_a_coeff: a:felem -> Stack unit
(requires fun h -> live h a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_nat h1 a < S.prime /\
SM.from_mont (as_nat h1 a) == S.a_coeff)
[@CInline]
let make_a_coeff a =
// a_coeff = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc | false | false | Hacl.Impl.P256.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_a_coeff: a:felem -> Stack unit
(requires fun h -> live h a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_nat h1 a < S.prime /\
SM.from_mont (as_nat h1 a) == S.a_coeff) | [] | Hacl.Impl.P256.Constants.make_a_coeff | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 29,
"end_line": 67,
"start_col": 2,
"start_line": 60
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let supported_alg = S.supported_alg | let supported_alg = | false | null | false | S.supported_alg | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"Spec.HMAC_DRBG.supported_alg"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" | false | true | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val supported_alg : Type0 | [] | Hacl.HMAC_DRBG.supported_alg | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 35,
"end_line": 57,
"start_col": 20,
"start_line": 57
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let disjoint_st (#a:supported_alg) (st:state a) (b:buffer uint8) =
B.loc_disjoint (footprint st) (B.loc_buffer b) | let disjoint_st (#a: supported_alg) (st: state a) (b: buffer uint8) = | false | null | false | B.loc_disjoint (footprint st) (B.loc_buffer b) | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"Hacl.HMAC_DRBG.supported_alg",
"Hacl.HMAC_DRBG.state",
"Lib.Buffer.buffer",
"Lib.IntTypes.uint8",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Hacl.HMAC_DRBG.footprint",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Buffer.trivial_preorder"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let supported_alg = S.supported_alg
let reseed_interval: n:size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval)
let max_output_length: n:size_t{v n == S.max_output_length} =
assert_norm (S.max_output_length < pow2 32);
normalize_term (mk_int S.max_output_length)
let max_length: n:size_t{v n == S.max_length} =
assert_norm (S.max_length < pow2 32);
normalize_term (mk_int S.max_length)
let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} =
assert_norm (S.max_personalization_string_length < pow2 32);
normalize_term (mk_int S.max_personalization_string_length)
let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} =
assert_norm (S.max_additional_input_length < pow2 32);
normalize_term (mk_int S.max_additional_input_length)
[@@ Comment "Return the minimal entropy input length of the desired hash function.
@param a Hash algorithm to use."]
let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} =
assert_norm (S.min_length a < pow2 32);
match a with
| SHA1 -> normalize_term (mk_int (S.min_length SHA1))
| SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256))
val state: supported_alg -> Type0
inline_for_extraction noextract
val freeable: #a:supported_alg -> st:state a -> Type0
val footprint: #a:supported_alg -> st:state a -> GTot B.loc
inline_for_extraction noextract
val invariant: #a:supported_alg -> st:state a -> h:HS.mem -> Type0
inline_for_extraction noextract | false | false | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val disjoint_st : st: Hacl.HMAC_DRBG.state a -> b: Lib.Buffer.buffer Lib.IntTypes.uint8 -> Type0 | [] | Hacl.HMAC_DRBG.disjoint_st | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | st: Hacl.HMAC_DRBG.state a -> b: Lib.Buffer.buffer Lib.IntTypes.uint8 -> Type0 | {
"end_col": 48,
"end_line": 100,
"start_col": 2,
"start_line": 100
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let free_st (a: supported_alg) =
s:state a -> ST unit
(requires fun h0 ->
freeable s /\
invariant s h0)
(ensures fun h0 _ h1 ->
B.(modifies (footprint s) h0 h1)) | let free_st (a: supported_alg) = | false | null | false | s: state a
-> ST unit
(requires fun h0 -> freeable s /\ invariant s h0)
(ensures fun h0 _ h1 -> let open B in modifies (footprint s) h0 h1) | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"Hacl.HMAC_DRBG.supported_alg",
"Hacl.HMAC_DRBG.state",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Hacl.HMAC_DRBG.freeable",
"Hacl.HMAC_DRBG.invariant",
"LowStar.Monotonic.Buffer.modifies",
"Hacl.HMAC_DRBG.footprint"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let supported_alg = S.supported_alg
let reseed_interval: n:size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval)
let max_output_length: n:size_t{v n == S.max_output_length} =
assert_norm (S.max_output_length < pow2 32);
normalize_term (mk_int S.max_output_length)
let max_length: n:size_t{v n == S.max_length} =
assert_norm (S.max_length < pow2 32);
normalize_term (mk_int S.max_length)
let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} =
assert_norm (S.max_personalization_string_length < pow2 32);
normalize_term (mk_int S.max_personalization_string_length)
let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} =
assert_norm (S.max_additional_input_length < pow2 32);
normalize_term (mk_int S.max_additional_input_length)
[@@ Comment "Return the minimal entropy input length of the desired hash function.
@param a Hash algorithm to use."]
let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} =
assert_norm (S.min_length a < pow2 32);
match a with
| SHA1 -> normalize_term (mk_int (S.min_length SHA1))
| SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256))
val state: supported_alg -> Type0
inline_for_extraction noextract
val freeable: #a:supported_alg -> st:state a -> Type0
val footprint: #a:supported_alg -> st:state a -> GTot B.loc
inline_for_extraction noextract
val invariant: #a:supported_alg -> st:state a -> h:HS.mem -> Type0
inline_for_extraction noextract
let disjoint_st (#a:supported_alg) (st:state a) (b:buffer uint8) =
B.loc_disjoint (footprint st) (B.loc_buffer b)
val repr: #a:supported_alg -> st:state a -> h:HS.mem -> GTot (S.state a)
inline_for_extraction noextract
val alloca: a:supported_alg -> StackInline (state a)
(requires fun _ -> True)
(ensures fun h0 st h1 ->
B.modifies B.loc_none h0 h1 /\
B.fresh_loc (footprint st) h0 h1 /\
B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint st)) /\
invariant st h1)
[@@ Comment "Create a DRBG state.
@param a Hash algorithm to use. The possible instantiations are ...
* `Spec_Hash_Definitions_SHA2_256`,
* `Spec_Hash_Definitions_SHA2_384`,
* `Spec_Hash_Definitions_SHA2_512`, and
* `Spec_Hash_Definitions_SHA1`."]
inline_for_extraction
val create_in: a:supported_alg -> r:HS.rid -> ST (state a)
(requires fun _ -> is_eternal_region r)
(ensures fun h0 st h1 ->
B.modifies B.loc_none h0 h1 /\
B.fresh_loc (footprint st) h0 h1 /\
B.(loc_includes (loc_region_only true r)) (footprint st) /\
invariant st h1 /\
freeable st)
inline_for_extraction noextract
let instantiate_st (a:supported_alg) =
st:state a
-> entropy_input_len:size_t
-> entropy_input:lbuffer uint8 entropy_input_len
-> nonce_len:size_t
-> nonce:lbuffer uint8 nonce_len
-> personalization_string_len:size_t
-> personalization_string:lbuffer uint8 personalization_string_len
-> Stack unit
(requires fun h0 ->
live h0 entropy_input /\ live h0 nonce /\ live h0 personalization_string /\
invariant st h0 /\
S.min_length a <= v entropy_input_len /\ v entropy_input_len <= v max_length /\
S.min_length a / 2 <= v nonce_len /\ v nonce_len <= v max_length /\
v personalization_string_len <= S.max_personalization_string_length)
(ensures fun h0 _ h1 ->
S.hmac_input_bound a;
invariant st h1 /\
B.modifies (footprint st) h0 h1 /\
repr st h1 ==
S.instantiate
(as_seq h0 entropy_input)
(as_seq h0 nonce)
(as_seq h0 personalization_string))
inline_for_extraction noextract
val mk_instantiate: #a:supported_alg -> hmac:HMAC.compute_st a -> instantiate_st a
[@@ Comment "Instantiate the DRBG.
@param a Hash algorithm to use. (Value must match the value used in `Hacl_HMAC_DRBG_create_in`.)
@param st Pointer to DRBG state.
@param entropy_input_len Length of entropy input.
@param entropy_input Pointer to `entropy_input_len` bytes of memory where entropy input is read from.
@param nonce_len Length of nonce.
@param nonce Pointer to `nonce_len` bytes of memory where nonce is read from.
@param personalization_string_len length of personalization string.
@param personalization_string Pointer to `personalization_string_len` bytes of memory where personalization string is read from."]
val instantiate: a:supported_alg -> instantiate_st a
inline_for_extraction noextract
let reseed_st (a:supported_alg) =
st:state a
-> entropy_input_len:size_t
-> entropy_input:lbuffer uint8 entropy_input_len
-> additional_input_len:size_t
-> additional_input:lbuffer uint8 additional_input_len
-> Stack unit
(requires fun h0 ->
invariant st h0 /\ live h0 entropy_input /\ live h0 additional_input /\
disjoint_st st entropy_input /\ disjoint_st st additional_input /\
S.min_length a <= v entropy_input_len /\ v entropy_input_len <= v max_length /\
v additional_input_len <= S.max_additional_input_length)
(ensures fun h0 _ h1 ->
S.hmac_input_bound a;
invariant st h1 /\
B.modifies (footprint st) h0 h1 /\
repr st h1 ==
S.reseed
(repr st h0)
(as_seq h0 entropy_input)
(as_seq h0 additional_input))
inline_for_extraction noextract
val mk_reseed: #a:supported_alg -> hmac:HMAC.compute_st a -> reseed_st a
[@@ Comment "Reseed the DRBG.
@param a Hash algorithm to use. (Value must match the value used in `Hacl_HMAC_DRBG_create_in`.)
@param st Pointer to DRBG state.
@param entropy_input_len Length of entropy input.
@param entropy_input Pointer to `entropy_input_len` bytes of memory where entropy input is read from.
@param additional_input_input_len Length of additional input.
@param additional_input_input Pointer to `additional_input_input_len` bytes of memory where additional input is read from."]
val reseed: a:supported_alg -> reseed_st a
inline_for_extraction noextract
let generate_st (a:supported_alg) =
output:buffer uint8
-> st:state a
-> n:size_t
-> additional_input_len:size_t
-> additional_input:lbuffer uint8 additional_input_len
-> Stack bool
(requires fun h0 ->
live h0 output /\ invariant st h0 /\ live h0 additional_input /\
disjoint_st st output /\ disjoint_st st additional_input /\
disjoint output additional_input /\
v n = length output /\
v n <= S.max_output_length /\
v additional_input_len <= S.max_additional_input_length)
(ensures fun h0 b h1 ->
S.hmac_input_bound a;
match S.generate (repr st h0) (v n) (as_seq h0 additional_input) with
| None -> b = false /\ invariant st h1 /\ modifies0 h0 h1
| Some (out, st_) ->
b = true /\
invariant st h1 /\
B.modifies (loc output |+| footprint st) h0 h1 /\
repr st h1 == st_ /\
as_seq #MUT #_ #n h1 output == out)
inline_for_extraction noextract
val mk_generate: #a:supported_alg -> HMAC.compute_st a -> generate_st a
[@@ Comment "Generate output.
@param a Hash algorithm to use. (Value must match the value used in `create_in`.)
@param output Pointer to `n` bytes of memory where random output is written to.
@param st Pointer to DRBG state.
@param n Length of desired output.
@param additional_input_input_len Length of additional input.
@param additional_input_input Pointer to `additional_input_input_len` bytes of memory where additional input is read from."]
val generate: a:supported_alg -> generate_st a
inline_for_extraction noextract | false | true | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val free_st : a: Hacl.HMAC_DRBG.supported_alg -> Type0 | [] | Hacl.HMAC_DRBG.free_st | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.HMAC_DRBG.supported_alg -> Type0 | {
"end_col": 37,
"end_line": 253,
"start_col": 2,
"start_line": 248
} |
|
Prims.Tot | val max_length:n: size_t{v n == S.max_length} | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let max_length: n:size_t{v n == S.max_length} =
assert_norm (S.max_length < pow2 32);
normalize_term (mk_int S.max_length) | val max_length:n: size_t{v n == S.max_length}
let max_length:n: size_t{v n == S.max_length} = | false | null | false | assert_norm (S.max_length < pow2 32);
normalize_term (mk_int S.max_length) | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Spec.HMAC_DRBG.max_length",
"Lib.IntTypes.mk_int",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_LessThan",
"Prims.pow2"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let supported_alg = S.supported_alg
let reseed_interval: n:size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval)
let max_output_length: n:size_t{v n == S.max_output_length} =
assert_norm (S.max_output_length < pow2 32);
normalize_term (mk_int S.max_output_length) | false | false | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val max_length:n: size_t{v n == S.max_length} | [] | Hacl.HMAC_DRBG.max_length | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n:
Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v n == Spec.HMAC_DRBG.max_length} | {
"end_col": 38,
"end_line": 69,
"start_col": 2,
"start_line": 68
} |
Prims.Tot | val reseed_interval:n: size_t{v n == S.reseed_interval} | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let reseed_interval: n:size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval) | val reseed_interval:n: size_t{v n == S.reseed_interval}
let reseed_interval:n: size_t{v n == S.reseed_interval} = | false | null | false | assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval) | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Spec.HMAC_DRBG.reseed_interval",
"Lib.IntTypes.mk_int",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_LessThan",
"Prims.pow2"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let supported_alg = S.supported_alg | false | false | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val reseed_interval:n: size_t{v n == S.reseed_interval} | [] | Hacl.HMAC_DRBG.reseed_interval | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n:
Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{Lib.IntTypes.v n == Spec.HMAC_DRBG.reseed_interval} | {
"end_col": 43,
"end_line": 61,
"start_col": 2,
"start_line": 60
} |
Prims.Tot | val max_additional_input_length:n: size_t{v n == S.max_additional_input_length} | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} =
assert_norm (S.max_additional_input_length < pow2 32);
normalize_term (mk_int S.max_additional_input_length) | val max_additional_input_length:n: size_t{v n == S.max_additional_input_length}
let max_additional_input_length:n: size_t{v n == S.max_additional_input_length} = | false | null | false | assert_norm (S.max_additional_input_length < pow2 32);
normalize_term (mk_int S.max_additional_input_length) | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Spec.HMAC_DRBG.max_additional_input_length",
"Lib.IntTypes.mk_int",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_LessThan",
"Prims.pow2"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let supported_alg = S.supported_alg
let reseed_interval: n:size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval)
let max_output_length: n:size_t{v n == S.max_output_length} =
assert_norm (S.max_output_length < pow2 32);
normalize_term (mk_int S.max_output_length)
let max_length: n:size_t{v n == S.max_length} =
assert_norm (S.max_length < pow2 32);
normalize_term (mk_int S.max_length)
let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} =
assert_norm (S.max_personalization_string_length < pow2 32);
normalize_term (mk_int S.max_personalization_string_length) | false | false | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val max_additional_input_length:n: size_t{v n == S.max_additional_input_length} | [] | Hacl.HMAC_DRBG.max_additional_input_length | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n:
Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{Lib.IntTypes.v n == Spec.HMAC_DRBG.max_additional_input_length} | {
"end_col": 55,
"end_line": 77,
"start_col": 2,
"start_line": 76
} |
Prims.Tot | val max_personalization_string_length:n: size_t{v n == S.max_personalization_string_length} | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} =
assert_norm (S.max_personalization_string_length < pow2 32);
normalize_term (mk_int S.max_personalization_string_length) | val max_personalization_string_length:n: size_t{v n == S.max_personalization_string_length}
let max_personalization_string_length:n: size_t{v n == S.max_personalization_string_length} = | false | null | false | assert_norm (S.max_personalization_string_length < pow2 32);
normalize_term (mk_int S.max_personalization_string_length) | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Spec.HMAC_DRBG.max_personalization_string_length",
"Lib.IntTypes.mk_int",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_LessThan",
"Prims.pow2"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let supported_alg = S.supported_alg
let reseed_interval: n:size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval)
let max_output_length: n:size_t{v n == S.max_output_length} =
assert_norm (S.max_output_length < pow2 32);
normalize_term (mk_int S.max_output_length)
let max_length: n:size_t{v n == S.max_length} =
assert_norm (S.max_length < pow2 32);
normalize_term (mk_int S.max_length) | false | false | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val max_personalization_string_length:n: size_t{v n == S.max_personalization_string_length} | [] | Hacl.HMAC_DRBG.max_personalization_string_length | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n:
Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{Lib.IntTypes.v n == Spec.HMAC_DRBG.max_personalization_string_length} | {
"end_col": 61,
"end_line": 73,
"start_col": 2,
"start_line": 72
} |
Prims.Tot | val max_output_length:n: size_t{v n == S.max_output_length} | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let max_output_length: n:size_t{v n == S.max_output_length} =
assert_norm (S.max_output_length < pow2 32);
normalize_term (mk_int S.max_output_length) | val max_output_length:n: size_t{v n == S.max_output_length}
let max_output_length:n: size_t{v n == S.max_output_length} = | false | null | false | assert_norm (S.max_output_length < pow2 32);
normalize_term (mk_int S.max_output_length) | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Spec.HMAC_DRBG.max_output_length",
"Lib.IntTypes.mk_int",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_LessThan",
"Prims.pow2"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let supported_alg = S.supported_alg
let reseed_interval: n:size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval) | false | false | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val max_output_length:n: size_t{v n == S.max_output_length} | [] | Hacl.HMAC_DRBG.max_output_length | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n:
Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{Lib.IntTypes.v n == Spec.HMAC_DRBG.max_output_length} | {
"end_col": 45,
"end_line": 65,
"start_col": 2,
"start_line": 64
} |
Prims.Tot | val min_length (a: supported_alg) : n: size_t{v n == S.min_length a} | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} =
assert_norm (S.min_length a < pow2 32);
match a with
| SHA1 -> normalize_term (mk_int (S.min_length SHA1))
| SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) | val min_length (a: supported_alg) : n: size_t{v n == S.min_length a}
let min_length (a: supported_alg) : n: size_t{v n == S.min_length a} = | false | null | false | assert_norm (S.min_length a < pow2 32);
match a with
| SHA1 -> normalize_term (mk_int (S.min_length SHA1))
| SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"Hacl.HMAC_DRBG.supported_alg",
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.size_t",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Spec.HMAC_DRBG.min_length",
"Lib.IntTypes.mk_int",
"Spec.Hash.Definitions.SHA1",
"Spec.Hash.Definitions.SHA2_256",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let supported_alg = S.supported_alg
let reseed_interval: n:size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval)
let max_output_length: n:size_t{v n == S.max_output_length} =
assert_norm (S.max_output_length < pow2 32);
normalize_term (mk_int S.max_output_length)
let max_length: n:size_t{v n == S.max_length} =
assert_norm (S.max_length < pow2 32);
normalize_term (mk_int S.max_length)
let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} =
assert_norm (S.max_personalization_string_length < pow2 32);
normalize_term (mk_int S.max_personalization_string_length)
let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} =
assert_norm (S.max_additional_input_length < pow2 32);
normalize_term (mk_int S.max_additional_input_length)
[@@ Comment "Return the minimal entropy input length of the desired hash function.
@param a Hash algorithm to use."] | false | false | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val min_length (a: supported_alg) : n: size_t{v n == S.min_length a} | [] | Hacl.HMAC_DRBG.min_length | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.HMAC_DRBG.supported_alg
-> n: Lib.IntTypes.size_t{Lib.IntTypes.v n == Spec.HMAC_DRBG.min_length a} | {
"end_col": 85,
"end_line": 86,
"start_col": 2,
"start_line": 83
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let reseed_st (a:supported_alg) =
st:state a
-> entropy_input_len:size_t
-> entropy_input:lbuffer uint8 entropy_input_len
-> additional_input_len:size_t
-> additional_input:lbuffer uint8 additional_input_len
-> Stack unit
(requires fun h0 ->
invariant st h0 /\ live h0 entropy_input /\ live h0 additional_input /\
disjoint_st st entropy_input /\ disjoint_st st additional_input /\
S.min_length a <= v entropy_input_len /\ v entropy_input_len <= v max_length /\
v additional_input_len <= S.max_additional_input_length)
(ensures fun h0 _ h1 ->
S.hmac_input_bound a;
invariant st h1 /\
B.modifies (footprint st) h0 h1 /\
repr st h1 ==
S.reseed
(repr st h0)
(as_seq h0 entropy_input)
(as_seq h0 additional_input)) | let reseed_st (a: supported_alg) = | false | null | false |
st: state a ->
entropy_input_len: size_t ->
entropy_input: lbuffer uint8 entropy_input_len ->
additional_input_len: size_t ->
additional_input: lbuffer uint8 additional_input_len
-> Stack unit
(requires
fun h0 ->
invariant st h0 /\ live h0 entropy_input /\ live h0 additional_input /\
disjoint_st st entropy_input /\ disjoint_st st additional_input /\
S.min_length a <= v entropy_input_len /\ v entropy_input_len <= v max_length /\
v additional_input_len <= S.max_additional_input_length)
(ensures
fun h0 _ h1 ->
S.hmac_input_bound a;
invariant st h1 /\ B.modifies (footprint st) h0 h1 /\
repr st h1 == S.reseed (repr st h0) (as_seq h0 entropy_input) (as_seq h0 additional_input)
) | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"Hacl.HMAC_DRBG.supported_alg",
"Hacl.HMAC_DRBG.state",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Hacl.HMAC_DRBG.invariant",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.HMAC_DRBG.disjoint_st",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.HMAC_DRBG.min_length",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.HMAC_DRBG.max_length",
"Spec.HMAC_DRBG.max_additional_input_length",
"LowStar.Monotonic.Buffer.modifies",
"Hacl.HMAC_DRBG.footprint",
"Prims.eq2",
"Spec.HMAC_DRBG.state",
"Hacl.HMAC_DRBG.repr",
"Spec.HMAC_DRBG.reseed",
"Lib.Buffer.as_seq",
"Spec.HMAC_DRBG.hmac_input_bound"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let supported_alg = S.supported_alg
let reseed_interval: n:size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval)
let max_output_length: n:size_t{v n == S.max_output_length} =
assert_norm (S.max_output_length < pow2 32);
normalize_term (mk_int S.max_output_length)
let max_length: n:size_t{v n == S.max_length} =
assert_norm (S.max_length < pow2 32);
normalize_term (mk_int S.max_length)
let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} =
assert_norm (S.max_personalization_string_length < pow2 32);
normalize_term (mk_int S.max_personalization_string_length)
let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} =
assert_norm (S.max_additional_input_length < pow2 32);
normalize_term (mk_int S.max_additional_input_length)
[@@ Comment "Return the minimal entropy input length of the desired hash function.
@param a Hash algorithm to use."]
let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} =
assert_norm (S.min_length a < pow2 32);
match a with
| SHA1 -> normalize_term (mk_int (S.min_length SHA1))
| SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256))
val state: supported_alg -> Type0
inline_for_extraction noextract
val freeable: #a:supported_alg -> st:state a -> Type0
val footprint: #a:supported_alg -> st:state a -> GTot B.loc
inline_for_extraction noextract
val invariant: #a:supported_alg -> st:state a -> h:HS.mem -> Type0
inline_for_extraction noextract
let disjoint_st (#a:supported_alg) (st:state a) (b:buffer uint8) =
B.loc_disjoint (footprint st) (B.loc_buffer b)
val repr: #a:supported_alg -> st:state a -> h:HS.mem -> GTot (S.state a)
inline_for_extraction noextract
val alloca: a:supported_alg -> StackInline (state a)
(requires fun _ -> True)
(ensures fun h0 st h1 ->
B.modifies B.loc_none h0 h1 /\
B.fresh_loc (footprint st) h0 h1 /\
B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint st)) /\
invariant st h1)
[@@ Comment "Create a DRBG state.
@param a Hash algorithm to use. The possible instantiations are ...
* `Spec_Hash_Definitions_SHA2_256`,
* `Spec_Hash_Definitions_SHA2_384`,
* `Spec_Hash_Definitions_SHA2_512`, and
* `Spec_Hash_Definitions_SHA1`."]
inline_for_extraction
val create_in: a:supported_alg -> r:HS.rid -> ST (state a)
(requires fun _ -> is_eternal_region r)
(ensures fun h0 st h1 ->
B.modifies B.loc_none h0 h1 /\
B.fresh_loc (footprint st) h0 h1 /\
B.(loc_includes (loc_region_only true r)) (footprint st) /\
invariant st h1 /\
freeable st)
inline_for_extraction noextract
let instantiate_st (a:supported_alg) =
st:state a
-> entropy_input_len:size_t
-> entropy_input:lbuffer uint8 entropy_input_len
-> nonce_len:size_t
-> nonce:lbuffer uint8 nonce_len
-> personalization_string_len:size_t
-> personalization_string:lbuffer uint8 personalization_string_len
-> Stack unit
(requires fun h0 ->
live h0 entropy_input /\ live h0 nonce /\ live h0 personalization_string /\
invariant st h0 /\
S.min_length a <= v entropy_input_len /\ v entropy_input_len <= v max_length /\
S.min_length a / 2 <= v nonce_len /\ v nonce_len <= v max_length /\
v personalization_string_len <= S.max_personalization_string_length)
(ensures fun h0 _ h1 ->
S.hmac_input_bound a;
invariant st h1 /\
B.modifies (footprint st) h0 h1 /\
repr st h1 ==
S.instantiate
(as_seq h0 entropy_input)
(as_seq h0 nonce)
(as_seq h0 personalization_string))
inline_for_extraction noextract
val mk_instantiate: #a:supported_alg -> hmac:HMAC.compute_st a -> instantiate_st a
[@@ Comment "Instantiate the DRBG.
@param a Hash algorithm to use. (Value must match the value used in `Hacl_HMAC_DRBG_create_in`.)
@param st Pointer to DRBG state.
@param entropy_input_len Length of entropy input.
@param entropy_input Pointer to `entropy_input_len` bytes of memory where entropy input is read from.
@param nonce_len Length of nonce.
@param nonce Pointer to `nonce_len` bytes of memory where nonce is read from.
@param personalization_string_len length of personalization string.
@param personalization_string Pointer to `personalization_string_len` bytes of memory where personalization string is read from."]
val instantiate: a:supported_alg -> instantiate_st a
inline_for_extraction noextract | false | true | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val reseed_st : a: Hacl.HMAC_DRBG.supported_alg -> Type0 | [] | Hacl.HMAC_DRBG.reseed_st | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.HMAC_DRBG.supported_alg -> Type0 | {
"end_col": 35,
"end_line": 192,
"start_col": 4,
"start_line": 173
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let instantiate_st (a:supported_alg) =
st:state a
-> entropy_input_len:size_t
-> entropy_input:lbuffer uint8 entropy_input_len
-> nonce_len:size_t
-> nonce:lbuffer uint8 nonce_len
-> personalization_string_len:size_t
-> personalization_string:lbuffer uint8 personalization_string_len
-> Stack unit
(requires fun h0 ->
live h0 entropy_input /\ live h0 nonce /\ live h0 personalization_string /\
invariant st h0 /\
S.min_length a <= v entropy_input_len /\ v entropy_input_len <= v max_length /\
S.min_length a / 2 <= v nonce_len /\ v nonce_len <= v max_length /\
v personalization_string_len <= S.max_personalization_string_length)
(ensures fun h0 _ h1 ->
S.hmac_input_bound a;
invariant st h1 /\
B.modifies (footprint st) h0 h1 /\
repr st h1 ==
S.instantiate
(as_seq h0 entropy_input)
(as_seq h0 nonce)
(as_seq h0 personalization_string)) | let instantiate_st (a: supported_alg) = | false | null | false |
st: state a ->
entropy_input_len: size_t ->
entropy_input: lbuffer uint8 entropy_input_len ->
nonce_len: size_t ->
nonce: lbuffer uint8 nonce_len ->
personalization_string_len: size_t ->
personalization_string: lbuffer uint8 personalization_string_len
-> Stack unit
(requires
fun h0 ->
live h0 entropy_input /\ live h0 nonce /\ live h0 personalization_string /\
invariant st h0 /\ S.min_length a <= v entropy_input_len /\
v entropy_input_len <= v max_length /\ S.min_length a / 2 <= v nonce_len /\
v nonce_len <= v max_length /\
v personalization_string_len <= S.max_personalization_string_length)
(ensures
fun h0 _ h1 ->
S.hmac_input_bound a;
invariant st h1 /\ B.modifies (footprint st) h0 h1 /\
repr st h1 ==
S.instantiate (as_seq h0 entropy_input)
(as_seq h0 nonce)
(as_seq h0 personalization_string)) | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"Hacl.HMAC_DRBG.supported_alg",
"Hacl.HMAC_DRBG.state",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.HMAC_DRBG.invariant",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.HMAC_DRBG.min_length",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.HMAC_DRBG.max_length",
"Prims.op_Division",
"Spec.HMAC_DRBG.max_personalization_string_length",
"LowStar.Monotonic.Buffer.modifies",
"Hacl.HMAC_DRBG.footprint",
"Prims.eq2",
"Spec.HMAC_DRBG.state",
"Hacl.HMAC_DRBG.repr",
"Spec.HMAC_DRBG.instantiate",
"Lib.Buffer.as_seq",
"Spec.HMAC_DRBG.hmac_input_bound"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let supported_alg = S.supported_alg
let reseed_interval: n:size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval)
let max_output_length: n:size_t{v n == S.max_output_length} =
assert_norm (S.max_output_length < pow2 32);
normalize_term (mk_int S.max_output_length)
let max_length: n:size_t{v n == S.max_length} =
assert_norm (S.max_length < pow2 32);
normalize_term (mk_int S.max_length)
let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} =
assert_norm (S.max_personalization_string_length < pow2 32);
normalize_term (mk_int S.max_personalization_string_length)
let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} =
assert_norm (S.max_additional_input_length < pow2 32);
normalize_term (mk_int S.max_additional_input_length)
[@@ Comment "Return the minimal entropy input length of the desired hash function.
@param a Hash algorithm to use."]
let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} =
assert_norm (S.min_length a < pow2 32);
match a with
| SHA1 -> normalize_term (mk_int (S.min_length SHA1))
| SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256))
val state: supported_alg -> Type0
inline_for_extraction noextract
val freeable: #a:supported_alg -> st:state a -> Type0
val footprint: #a:supported_alg -> st:state a -> GTot B.loc
inline_for_extraction noextract
val invariant: #a:supported_alg -> st:state a -> h:HS.mem -> Type0
inline_for_extraction noextract
let disjoint_st (#a:supported_alg) (st:state a) (b:buffer uint8) =
B.loc_disjoint (footprint st) (B.loc_buffer b)
val repr: #a:supported_alg -> st:state a -> h:HS.mem -> GTot (S.state a)
inline_for_extraction noextract
val alloca: a:supported_alg -> StackInline (state a)
(requires fun _ -> True)
(ensures fun h0 st h1 ->
B.modifies B.loc_none h0 h1 /\
B.fresh_loc (footprint st) h0 h1 /\
B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint st)) /\
invariant st h1)
[@@ Comment "Create a DRBG state.
@param a Hash algorithm to use. The possible instantiations are ...
* `Spec_Hash_Definitions_SHA2_256`,
* `Spec_Hash_Definitions_SHA2_384`,
* `Spec_Hash_Definitions_SHA2_512`, and
* `Spec_Hash_Definitions_SHA1`."]
inline_for_extraction
val create_in: a:supported_alg -> r:HS.rid -> ST (state a)
(requires fun _ -> is_eternal_region r)
(ensures fun h0 st h1 ->
B.modifies B.loc_none h0 h1 /\
B.fresh_loc (footprint st) h0 h1 /\
B.(loc_includes (loc_region_only true r)) (footprint st) /\
invariant st h1 /\
freeable st)
inline_for_extraction noextract | false | true | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val instantiate_st : a: Hacl.HMAC_DRBG.supported_alg -> Type0 | [] | Hacl.HMAC_DRBG.instantiate_st | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.HMAC_DRBG.supported_alg -> Type0 | {
"end_col": 41,
"end_line": 154,
"start_col": 4,
"start_line": 132
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.HMAC_DRBG",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.HMAC",
"short_module": "HMAC"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let generate_st (a:supported_alg) =
output:buffer uint8
-> st:state a
-> n:size_t
-> additional_input_len:size_t
-> additional_input:lbuffer uint8 additional_input_len
-> Stack bool
(requires fun h0 ->
live h0 output /\ invariant st h0 /\ live h0 additional_input /\
disjoint_st st output /\ disjoint_st st additional_input /\
disjoint output additional_input /\
v n = length output /\
v n <= S.max_output_length /\
v additional_input_len <= S.max_additional_input_length)
(ensures fun h0 b h1 ->
S.hmac_input_bound a;
match S.generate (repr st h0) (v n) (as_seq h0 additional_input) with
| None -> b = false /\ invariant st h1 /\ modifies0 h0 h1
| Some (out, st_) ->
b = true /\
invariant st h1 /\
B.modifies (loc output |+| footprint st) h0 h1 /\
repr st h1 == st_ /\
as_seq #MUT #_ #n h1 output == out) | let generate_st (a: supported_alg) = | false | null | false |
output: buffer uint8 ->
st: state a ->
n: size_t ->
additional_input_len: size_t ->
additional_input: lbuffer uint8 additional_input_len
-> Stack bool
(requires
fun h0 ->
live h0 output /\ invariant st h0 /\ live h0 additional_input /\ disjoint_st st output /\
disjoint_st st additional_input /\ disjoint output additional_input /\ v n = length output /\
v n <= S.max_output_length /\ v additional_input_len <= S.max_additional_input_length)
(ensures
fun h0 b h1 ->
S.hmac_input_bound a;
match S.generate (repr st h0) (v n) (as_seq h0 additional_input) with
| None -> b = false /\ invariant st h1 /\ modifies0 h0 h1
| Some (out, st_) ->
b = true /\ invariant st h1 /\ B.modifies (loc output |+| footprint st) h0 h1 /\
repr st h1 == st_ /\ as_seq #MUT #_ #n h1 output == out) | {
"checked_file": "Hacl.HMAC_DRBG.fsti.checked",
"dependencies": [
"Spec.HMAC_DRBG.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.HMAC.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.HMAC_DRBG.fsti"
} | [
"total"
] | [
"Hacl.HMAC_DRBG.supported_alg",
"Lib.Buffer.buffer",
"Lib.IntTypes.uint8",
"Hacl.HMAC_DRBG.state",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Prims.bool",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.HMAC_DRBG.invariant",
"Hacl.HMAC_DRBG.disjoint_st",
"Lib.Buffer.disjoint",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Lib.Buffer.length",
"Prims.op_LessThanOrEqual",
"Spec.HMAC_DRBG.max_output_length",
"Spec.HMAC_DRBG.max_additional_input_length",
"Spec.HMAC_DRBG.generate",
"Hacl.HMAC_DRBG.repr",
"Lib.Buffer.as_seq",
"Lib.Buffer.modifies0",
"Spec.Agile.HMAC.lbytes",
"Spec.HMAC_DRBG.state",
"LowStar.Monotonic.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Hacl.HMAC_DRBG.footprint",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.nat",
"FStar.Seq.Base.length",
"Prims.unit",
"Spec.HMAC_DRBG.hmac_input_bound"
] | [] | module Hacl.HMAC_DRBG
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Lib.IntTypes
open Lib.Buffer
module HS = FStar.HyperStack
module B = LowStar.Buffer
module LSeq = Lib.Sequence
module HMAC = Hacl.HMAC
module S = Spec.HMAC_DRBG
/// HMAC-DRBG
///
/// See 10.1.2 and B.2 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
/// This module implements the hash-algorithm-agile algorithms
/// - HMAC_DRBG_Update (not exposed by the interface)
/// - HMAC_DRBG_Instantiate_algorithm
/// - HMAC_DRBG_Reseed_algorithm
/// - HMAC_DRBG_Generate_algorithm
///
/// This is not linked to an appropriate Get_entropy_input function,
/// so these algorithms should be combined to get entropy from Get_entropy_input
/// for instantiation, reseeding, and optional prediction resistance.
///
/// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 hash algorithms
///
/// - Supports reseeding
///
/// - Supports optional personalization_string for instantiation
///
/// - Supports optional additional_input for reseeding and generation
///
/// - The internal state is (Key,V,reseed_counter)
///
/// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
///
/// - The minimum entropy for instantiation is 3/2 * security_strength.
/// - entropy_input must have at least security_strength bits.
/// - nonce must have at least 1/2 security_strength bits.
/// - entropy_input and nonce can have at most max_length = 2^16 bits.
///
/// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request.
///
/// - The reseed_interval is 2^10
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
unfold
let supported_alg = S.supported_alg
let reseed_interval: n:size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32);
normalize_term (mk_int S.reseed_interval)
let max_output_length: n:size_t{v n == S.max_output_length} =
assert_norm (S.max_output_length < pow2 32);
normalize_term (mk_int S.max_output_length)
let max_length: n:size_t{v n == S.max_length} =
assert_norm (S.max_length < pow2 32);
normalize_term (mk_int S.max_length)
let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} =
assert_norm (S.max_personalization_string_length < pow2 32);
normalize_term (mk_int S.max_personalization_string_length)
let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} =
assert_norm (S.max_additional_input_length < pow2 32);
normalize_term (mk_int S.max_additional_input_length)
[@@ Comment "Return the minimal entropy input length of the desired hash function.
@param a Hash algorithm to use."]
let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} =
assert_norm (S.min_length a < pow2 32);
match a with
| SHA1 -> normalize_term (mk_int (S.min_length SHA1))
| SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256))
val state: supported_alg -> Type0
inline_for_extraction noextract
val freeable: #a:supported_alg -> st:state a -> Type0
val footprint: #a:supported_alg -> st:state a -> GTot B.loc
inline_for_extraction noextract
val invariant: #a:supported_alg -> st:state a -> h:HS.mem -> Type0
inline_for_extraction noextract
let disjoint_st (#a:supported_alg) (st:state a) (b:buffer uint8) =
B.loc_disjoint (footprint st) (B.loc_buffer b)
val repr: #a:supported_alg -> st:state a -> h:HS.mem -> GTot (S.state a)
inline_for_extraction noextract
val alloca: a:supported_alg -> StackInline (state a)
(requires fun _ -> True)
(ensures fun h0 st h1 ->
B.modifies B.loc_none h0 h1 /\
B.fresh_loc (footprint st) h0 h1 /\
B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint st)) /\
invariant st h1)
[@@ Comment "Create a DRBG state.
@param a Hash algorithm to use. The possible instantiations are ...
* `Spec_Hash_Definitions_SHA2_256`,
* `Spec_Hash_Definitions_SHA2_384`,
* `Spec_Hash_Definitions_SHA2_512`, and
* `Spec_Hash_Definitions_SHA1`."]
inline_for_extraction
val create_in: a:supported_alg -> r:HS.rid -> ST (state a)
(requires fun _ -> is_eternal_region r)
(ensures fun h0 st h1 ->
B.modifies B.loc_none h0 h1 /\
B.fresh_loc (footprint st) h0 h1 /\
B.(loc_includes (loc_region_only true r)) (footprint st) /\
invariant st h1 /\
freeable st)
inline_for_extraction noextract
let instantiate_st (a:supported_alg) =
st:state a
-> entropy_input_len:size_t
-> entropy_input:lbuffer uint8 entropy_input_len
-> nonce_len:size_t
-> nonce:lbuffer uint8 nonce_len
-> personalization_string_len:size_t
-> personalization_string:lbuffer uint8 personalization_string_len
-> Stack unit
(requires fun h0 ->
live h0 entropy_input /\ live h0 nonce /\ live h0 personalization_string /\
invariant st h0 /\
S.min_length a <= v entropy_input_len /\ v entropy_input_len <= v max_length /\
S.min_length a / 2 <= v nonce_len /\ v nonce_len <= v max_length /\
v personalization_string_len <= S.max_personalization_string_length)
(ensures fun h0 _ h1 ->
S.hmac_input_bound a;
invariant st h1 /\
B.modifies (footprint st) h0 h1 /\
repr st h1 ==
S.instantiate
(as_seq h0 entropy_input)
(as_seq h0 nonce)
(as_seq h0 personalization_string))
inline_for_extraction noextract
val mk_instantiate: #a:supported_alg -> hmac:HMAC.compute_st a -> instantiate_st a
[@@ Comment "Instantiate the DRBG.
@param a Hash algorithm to use. (Value must match the value used in `Hacl_HMAC_DRBG_create_in`.)
@param st Pointer to DRBG state.
@param entropy_input_len Length of entropy input.
@param entropy_input Pointer to `entropy_input_len` bytes of memory where entropy input is read from.
@param nonce_len Length of nonce.
@param nonce Pointer to `nonce_len` bytes of memory where nonce is read from.
@param personalization_string_len length of personalization string.
@param personalization_string Pointer to `personalization_string_len` bytes of memory where personalization string is read from."]
val instantiate: a:supported_alg -> instantiate_st a
inline_for_extraction noextract
let reseed_st (a:supported_alg) =
st:state a
-> entropy_input_len:size_t
-> entropy_input:lbuffer uint8 entropy_input_len
-> additional_input_len:size_t
-> additional_input:lbuffer uint8 additional_input_len
-> Stack unit
(requires fun h0 ->
invariant st h0 /\ live h0 entropy_input /\ live h0 additional_input /\
disjoint_st st entropy_input /\ disjoint_st st additional_input /\
S.min_length a <= v entropy_input_len /\ v entropy_input_len <= v max_length /\
v additional_input_len <= S.max_additional_input_length)
(ensures fun h0 _ h1 ->
S.hmac_input_bound a;
invariant st h1 /\
B.modifies (footprint st) h0 h1 /\
repr st h1 ==
S.reseed
(repr st h0)
(as_seq h0 entropy_input)
(as_seq h0 additional_input))
inline_for_extraction noextract
val mk_reseed: #a:supported_alg -> hmac:HMAC.compute_st a -> reseed_st a
[@@ Comment "Reseed the DRBG.
@param a Hash algorithm to use. (Value must match the value used in `Hacl_HMAC_DRBG_create_in`.)
@param st Pointer to DRBG state.
@param entropy_input_len Length of entropy input.
@param entropy_input Pointer to `entropy_input_len` bytes of memory where entropy input is read from.
@param additional_input_input_len Length of additional input.
@param additional_input_input Pointer to `additional_input_input_len` bytes of memory where additional input is read from."]
val reseed: a:supported_alg -> reseed_st a
inline_for_extraction noextract | false | true | Hacl.HMAC_DRBG.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val generate_st : a: Hacl.HMAC_DRBG.supported_alg -> Type0 | [] | Hacl.HMAC_DRBG.generate_st | {
"file_name": "code/drbg/Hacl.HMAC_DRBG.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.HMAC_DRBG.supported_alg -> Type0 | {
"end_col": 41,
"end_line": 231,
"start_col": 4,
"start_line": 209
} |
|
FStar.Tactics.Effect.Tac | val open_term (b: R.binder) (t: term) : Tac (binder & term) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t) | val open_term (b: R.binder) (t: term) : Tac (binder & term)
let open_term (b: R.binder) (t: term) : Tac (binder & term) = | true | null | false | let bndr:binder = open_binder b in
(bndr, open_term_with b bndr t) | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.term",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.binder",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.open_term_with",
"FStar.Tactics.NamedView.open_binder"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t' | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_term (b: R.binder) (t: term) : Tac (binder & term) | [] | FStar.Tactics.NamedView.open_term | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Reflection.Types.binder -> t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac (FStar.Tactics.NamedView.binder * FStar.Tactics.NamedView.term) | {
"end_col": 33,
"end_line": 114,
"start_col": 63,
"start_line": 112
} |
Prims.Tot | val inspect_universe (u:universe) : Tot named_universe_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v | val inspect_universe (u:universe) : Tot named_universe_view
let inspect_universe (u: universe) : named_universe_view = | false | null | false | let v = R.inspect_universe u in
open_universe_view v | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.universe",
"FStar.Tactics.NamedView.open_universe_view",
"FStar.Reflection.V2.Data.universe_view",
"Prims.precedes",
"FStar.Reflection.Types.universe",
"FStar.Reflection.V2.Builtins.inspect_universe",
"FStar.Tactics.NamedView.named_universe_view"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inspect_universe (u:universe) : Tot named_universe_view | [] | FStar.Tactics.NamedView.inspect_universe | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | u184: FStar.Tactics.NamedView.universe -> FStar.Tactics.NamedView.named_universe_view | {
"end_col": 22,
"end_line": 45,
"start_col": 57,
"start_line": 43
} |
FStar.Tactics.Effect.Tac | val open_binder (b: R.binder) : Tac binder | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
} | val open_binder (b: R.binder) : Tac binder
let open_binder (b: R.binder) : Tac binder = | true | null | false | let n = fresh () in
let bv = inspect_binder b in
{ uniq = n; sort = bv.sort; ppname = bv.ppname; qual = bv.qual; attrs = bv.attrs } | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.Mkbinder",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__ppname",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__sort",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__qual",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__attrs",
"FStar.Reflection.V2.Data.binder_view",
"Prims.precedes",
"FStar.Reflection.V2.Builtins.inspect_binder",
"FStar.Tactics.NamedView.binder",
"Prims.nat",
"FStar.Tactics.V2.Builtins.fresh"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
} | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_binder (b: R.binder) : Tac binder | [] | FStar.Tactics.NamedView.open_binder | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Reflection.Types.binder -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.binder | {
"end_col": 3,
"end_line": 89,
"start_col": 45,
"start_line": 80
} |
Prims.Tot | val pack_universe (uv:named_universe_view) : Tot universe | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv | val pack_universe (uv:named_universe_view) : Tot universe
let pack_universe (uv: named_universe_view) : universe = | false | null | false | let uv = close_universe_view uv in
R.pack_universe uv | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.named_universe_view",
"FStar.Reflection.V2.Builtins.pack_universe",
"FStar.Reflection.V2.Data.universe_view",
"FStar.Tactics.NamedView.close_universe_view",
"FStar.Tactics.NamedView.universe"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pack_universe (uv:named_universe_view) : Tot universe | [] | FStar.Tactics.NamedView.pack_universe | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | uv: FStar.Tactics.NamedView.named_universe_view -> FStar.Tactics.NamedView.universe | {
"end_col": 20,
"end_line": 59,
"start_col": 55,
"start_line": 57
} |
FStar.Tactics.Effect.Tac | val open_comp (b: R.binder) (t: comp) : Tac (binder & comp) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t') | val open_comp (b: R.binder) (t: comp) : Tac (binder & comp)
let open_comp (b: R.binder) (t: comp) : Tac (binder & comp) = | true | null | false | let n = fresh () in
let bv:binder_view = inspect_binder b in
let nv:R.namedv = pack_namedv ({ uniq = n; sort = seal bv.sort; ppname = bv.ppname }) in
let t' = subst_comp [DB 0 nv] t in
let bndr:binder =
{ uniq = n; sort = bv.sort; ppname = bv.ppname; qual = bv.qual; attrs = bv.attrs }
in
(bndr, t') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.comp",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.Mkbinder",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__ppname",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__sort",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__qual",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__attrs",
"FStar.Tactics.NamedView.subst_comp",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.DB",
"Prims.Nil",
"FStar.Reflection.Types.namedv",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Sealed.seal",
"FStar.Reflection.Types.typ",
"FStar.Reflection.V2.Data.binder_view",
"FStar.Reflection.V2.Builtins.inspect_binder",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"FStar.Tactics.V2.Builtins.fresh"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c)) | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_comp (b: R.binder) (t: comp) : Tac (binder & comp) | [] | FStar.Tactics.NamedView.open_comp | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Reflection.Types.binder -> t: FStar.Tactics.NamedView.comp
-> FStar.Tactics.Effect.Tac (FStar.Tactics.NamedView.binder * FStar.Tactics.NamedView.comp) | {
"end_col": 12,
"end_line": 138,
"start_col": 63,
"start_line": 120
} |
FStar.Tactics.Effect.Tac | val open_term_n_with (bs: list R.binder) (nbs: list binder) (t: term) : Tac term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch | val open_term_n_with (bs: list R.binder) (nbs: list binder) (t: term) : Tac term
let rec open_term_n_with (bs: list R.binder) (nbs: list binder) (t: term) : Tac term = | true | null | false | match bs, nbs with
| [], [] -> t
| b :: bs, nb :: nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.term",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.open_term_with",
"FStar.Tactics.NamedView.open_term_n_with",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.Effect.raise",
"FStar.Tactics.NamedView.LengthMismatch"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_term_n_with (bs: list R.binder) (nbs: list binder) (t: term) : Tac term | [
"recursion"
] | FStar.Tactics.NamedView.open_term_n_with | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
bs: Prims.list FStar.Reflection.Types.binder ->
nbs: Prims.list FStar.Tactics.NamedView.binder ->
t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.term | {
"end_col": 29,
"end_line": 258,
"start_col": 2,
"start_line": 252
} |
Prims.Tot | val subst_comp (s: subst_t) (c: comp) : comp | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c)) | val subst_comp (s: subst_t) (c: comp) : comp
let subst_comp (s: subst_t) (c: comp) : comp = | false | null | false | inspect_comp (R.subst_comp s (pack_comp c)) | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Tactics.NamedView.comp",
"FStar.Reflection.V2.Builtins.inspect_comp",
"FStar.Reflection.V2.Builtins.subst_comp",
"FStar.Reflection.V2.Builtins.pack_comp"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t) | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val subst_comp (s: subst_t) (c: comp) : comp | [] | FStar.Tactics.NamedView.subst_comp | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Stubs.Syntax.Syntax.subst_t -> c: FStar.Tactics.NamedView.comp
-> FStar.Tactics.NamedView.comp | {
"end_col": 45,
"end_line": 117,
"start_col": 2,
"start_line": 117
} |
FStar.Tactics.Effect.Tac | val open_comp_with (b: R.binder) (nb: binder) (c: comp) : Tac comp | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t' | val open_comp_with (b: R.binder) (nb: binder) (c: comp) : Tac comp
let open_comp_with (b: R.binder) (nb: binder) (c: comp) : Tac comp = | true | null | false | let nv:R.namedv = pack_namedv ({ uniq = nb.uniq; sort = seal nb.sort; ppname = nb.ppname }) in
let t' = subst_comp [DB 0 nv] c in
t' | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.comp",
"FStar.Tactics.NamedView.subst_comp",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.DB",
"Prims.Nil",
"FStar.Reflection.Types.namedv",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__uniq",
"FStar.Sealed.seal",
"FStar.Reflection.Types.typ",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__sort",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__ppname"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t') | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_comp_with (b: R.binder) (nb: binder) (c: comp) : Tac comp | [] | FStar.Tactics.NamedView.open_comp_with | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
b: FStar.Reflection.Types.binder ->
nb: FStar.Tactics.NamedView.binder ->
c: FStar.Tactics.NamedView.comp
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.comp | {
"end_col": 4,
"end_line": 149,
"start_col": 71,
"start_line": 141
} |
FStar.Tactics.Effect.Tac | val inspect (t:term) : Tac named_term_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv | val inspect (t:term) : Tac named_term_view
let inspect (t: term) : Tac named_term_view = | true | null | false | let t = compress t in
let tv = inspect_ln t in
open_view tv | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.open_view",
"FStar.Tactics.NamedView.named_term_view",
"FStar.Reflection.V2.Data.term_view",
"Prims.precedes",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.inspect_ln",
"FStar.Tactics.V2.Builtins.compress"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inspect (t:term) : Tac named_term_view | [] | FStar.Tactics.NamedView.inspect | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.named_term_view | {
"end_col": 14,
"end_line": 513,
"start_col": 44,
"start_line": 510
} |
Prims.Tot | val close_binder (b: binder) : R.binder | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
} | val close_binder (b: binder) : R.binder
let close_binder (b: binder) : R.binder = | false | null | false | pack_binder ({ sort = b.sort; qual = b.qual; ppname = b.ppname; attrs = b.attrs }) | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.binder",
"FStar.Reflection.V2.Builtins.pack_binder",
"FStar.Reflection.V2.Data.Mkbinder_view",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__sort",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__qual",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__attrs",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__ppname",
"FStar.Reflection.Types.binder"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_binder (b: binder) : R.binder | [] | FStar.Tactics.NamedView.close_binder | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Tactics.NamedView.binder -> FStar.Reflection.Types.binder | {
"end_col": 3,
"end_line": 98,
"start_col": 2,
"start_line": 93
} |
Prims.Tot | val r_subst_binder_sort (s: subst_t) (b: R.binder) : R.binder | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v | val r_subst_binder_sort (s: subst_t) (b: R.binder) : R.binder
let r_subst_binder_sort (s: subst_t) (b: R.binder) : R.binder = | false | null | false | let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Reflection.Types.binder",
"FStar.Reflection.V2.Builtins.pack_binder",
"FStar.Reflection.V2.Data.binder_view",
"FStar.Reflection.V2.Data.Mkbinder_view",
"FStar.Reflection.V2.Builtins.subst_term",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__sort",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__qual",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__attrs",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__ppname",
"Prims.precedes",
"FStar.Reflection.V2.Builtins.inspect_binder"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t') | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val r_subst_binder_sort (s: subst_t) (b: R.binder) : R.binder | [] | FStar.Tactics.NamedView.r_subst_binder_sort | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Stubs.Syntax.Syntax.subst_t -> b: FStar.Reflection.Types.binder
-> FStar.Reflection.Types.binder | {
"end_col": 15,
"end_line": 229,
"start_col": 65,
"start_line": 226
} |
FStar.Tactics.Effect.Tac | val open_term_n (bs: list R.binder) (t: term) : Tac (list binder & term) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t | val open_term_n (bs: list R.binder) (t: term) : Tac (list binder & term)
let open_term_n (bs: list R.binder) (t: term) : Tac (list binder & term) = | true | null | false | let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.binder",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Pervasives.Native.Mktuple2",
"FStar.List.Tot.Base.rev",
"FStar.Reflection.V2.Builtins.subst_term",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.__open_term_n_aux",
"Prims.Nil",
"FStar.Stubs.Syntax.Syntax.subst_elt"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s) | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_term_n (bs: list R.binder) (t: term) : Tac (list binder & term) | [] | FStar.Tactics.NamedView.open_term_n | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Reflection.Types.binder -> t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac
(Prims.list FStar.Tactics.NamedView.binder * FStar.Tactics.NamedView.term) | {
"end_col": 34,
"end_line": 248,
"start_col": 76,
"start_line": 246
} |
FStar.Tactics.Effect.Tac | val open_branch (b: R.branch) : Tac branch | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t') | val open_branch (b: R.branch) : Tac branch
let open_branch (b: R.branch) : Tac branch = | true | null | false | let pat, t = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.V2.Data.branch",
"FStar.Reflection.V2.Data.pattern",
"FStar.Reflection.Types.term",
"FStar.Tactics.NamedView.pattern",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.term",
"FStar.Reflection.V2.Builtins.subst_term",
"FStar.Tactics.NamedView.branch",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.open_pat",
"Prims.Nil",
"FStar.Stubs.Syntax.Syntax.subst_elt"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_branch (b: R.branch) : Tac branch | [] | FStar.Tactics.NamedView.open_branch | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Reflection.V2.Data.branch -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.branch | {
"end_col": 11,
"end_line": 331,
"start_col": 45,
"start_line": 327
} |
Prims.Tot | val __binding_to_binder (bnd: binding) (b: R.binder) : binder | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
} | val __binding_to_binder (bnd: binding) (b: R.binder) : binder
let __binding_to_binder (bnd: binding) (b: R.binder) : binder = | false | null | false | {
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs
} | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.binding",
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.Mkbinder",
"FStar.Reflection.V2.Data.__proj__Mkbinding__item__uniq",
"FStar.Reflection.V2.Data.__proj__Mkbinding__item__ppname",
"FStar.Reflection.V2.Data.__proj__Mkbinding__item__sort",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__qual",
"FStar.Reflection.V2.Builtins.inspect_binder",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__attrs",
"FStar.Tactics.NamedView.binder"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder = | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val __binding_to_binder (bnd: binding) (b: R.binder) : binder | [] | FStar.Tactics.NamedView.__binding_to_binder | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bnd: FStar.Tactics.NamedView.binding -> b: FStar.Reflection.Types.binder
-> FStar.Tactics.NamedView.binder | {
"end_col": 40,
"end_line": 68,
"start_col": 6,
"start_line": 64
} |
FStar.Tactics.Effect.Tac | val open_term_with (b: R.binder) (nb: binder) (t: term) : Tac term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t' | val open_term_with (b: R.binder) (nb: binder) (t: term) : Tac term
let open_term_with (b: R.binder) (nb: binder) (t: term) : Tac term = | true | null | false | let nv:R.namedv = pack_namedv ({ uniq = nb.uniq; sort = seal nb.sort; ppname = nb.ppname }) in
let t' = subst_term [DB 0 nv] t in
t' | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.term",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.subst_term",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.DB",
"Prims.Nil",
"FStar.Reflection.Types.namedv",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__uniq",
"FStar.Sealed.seal",
"FStar.Reflection.Types.typ",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__sort",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__ppname"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
} | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_term_with (b: R.binder) (nb: binder) (t: term) : Tac term | [] | FStar.Tactics.NamedView.open_term_with | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
b: FStar.Reflection.Types.binder ->
nb: FStar.Tactics.NamedView.binder ->
t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.term | {
"end_col": 4,
"end_line": 109,
"start_col": 71,
"start_line": 101
} |
Prims.Tot | val close_comp (b: binder) (t: comp) : R.binder & comp | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t') | val close_comp (b: binder) (t: comp) : R.binder & comp
let close_comp (b: binder) (t: comp) : R.binder & comp = | false | null | false | let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder ({ sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs }) in
(b, t') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.comp",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.Types.binder",
"FStar.Reflection.V2.Builtins.pack_binder",
"FStar.Reflection.V2.Data.Mkbinder_view",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__sort",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__qual",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__attrs",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__ppname",
"FStar.Tactics.NamedView.subst_comp",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.NM",
"Prims.Nil",
"FStar.Reflection.Types.namedv",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t') | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_comp (b: binder) (t: comp) : R.binder & comp | [] | FStar.Tactics.NamedView.close_comp | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Tactics.NamedView.binder -> t: FStar.Tactics.NamedView.comp
-> FStar.Reflection.Types.binder * FStar.Tactics.NamedView.comp | {
"end_col": 9,
"end_line": 206,
"start_col": 54,
"start_line": 202
} |
Prims.Tot | val close_term (b:binder) (t:term) : Tot (R.binder & term) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t') | val close_term (b:binder) (t:term) : Tot (R.binder & term)
let close_term (b: binder) (t: term) : R.binder & term = | false | null | false | let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder ({ sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs }) in
(b, t') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.term",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.Types.binder",
"FStar.Reflection.V2.Builtins.pack_binder",
"FStar.Reflection.V2.Data.Mkbinder_view",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__sort",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__qual",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__attrs",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__ppname",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.subst_term",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.NM",
"Prims.Nil",
"FStar.Reflection.Types.namedv",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t') | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_term (b:binder) (t:term) : Tot (R.binder & term) | [] | FStar.Tactics.NamedView.close_term | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Tactics.NamedView.binder -> t: FStar.Tactics.NamedView.term
-> FStar.Reflection.Types.binder * FStar.Tactics.NamedView.term | {
"end_col": 9,
"end_line": 200,
"start_col": 54,
"start_line": 196
} |
Prims.Tot | val pack (tv:named_term_view) : Tot term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv | val pack (tv:named_term_view) : Tot term
let pack (tv: named_term_view) : Tot term = | false | null | false | let tv = close_view tv in
pack_ln tv | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.named_term_view",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.term_view",
"FStar.Tactics.NamedView.close_view",
"FStar.Tactics.NamedView.term"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pack (tv:named_term_view) : Tot term | [] | FStar.Tactics.NamedView.pack | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | tv: FStar.Tactics.NamedView.named_term_view -> FStar.Tactics.NamedView.term | {
"end_col": 12,
"end_line": 518,
"start_col": 42,
"start_line": 516
} |
Prims.Tot | val r_binder_to_namedv (b: binder) : R.namedv | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
} | val r_binder_to_namedv (b: binder) : R.namedv
let r_binder_to_namedv (b: binder) : R.namedv = | false | null | false | pack_namedv ({ uniq = b.uniq; sort = seal b.sort; ppname = b.ppname }) | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.binder",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__uniq",
"FStar.Sealed.seal",
"FStar.Reflection.Types.typ",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__sort",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__ppname",
"FStar.Reflection.Types.namedv"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val r_binder_to_namedv (b: binder) : R.namedv | [] | FStar.Tactics.NamedView.r_binder_to_namedv | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Tactics.NamedView.binder -> FStar.Reflection.Types.namedv | {
"end_col": 3,
"end_line": 77,
"start_col": 2,
"start_line": 73
} |
Prims.Tot | val close_univ_s (us: list univ_name) : list R.univ_name & subst_t | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s | val close_univ_s (us: list univ_name) : list R.univ_name & subst_t
let close_univ_s (us: list univ_name) : list R.univ_name & subst_t = | false | null | false | let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n - i - 1)) us in
us, s | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"Prims.list",
"FStar.Tactics.NamedView.univ_name",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.Types.univ_name",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.List.Tot.Base.mapi",
"FStar.Reflection.Types.ident",
"Prims.int",
"FStar.Stubs.Syntax.Syntax.UD",
"Prims.op_Subtraction",
"FStar.List.Tot.Base.map",
"FStar.Reflection.V2.Data.ident_view",
"FStar.Reflection.V2.Builtins.pack_ident",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_univ_s (us: list univ_name) : list R.univ_name & subst_t | [] | FStar.Tactics.NamedView.close_univ_s | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | us: Prims.list FStar.Tactics.NamedView.univ_name
-> Prims.list FStar.Reflection.Types.univ_name * FStar.Stubs.Syntax.Syntax.subst_t | {
"end_col": 7,
"end_line": 531,
"start_col": 69,
"start_line": 527
} |
Prims.Tot | val subst_r_binders (s: subst_t) (bs: list R.binder) : list R.binder | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs | val subst_r_binders (s: subst_t) (bs: list R.binder) : list R.binder
let subst_r_binders (s: subst_t) (bs: list R.binder) : list R.binder = | false | null | false | List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Stubs.Syntax.Syntax.subst_t",
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.List.Tot.Base.mapi",
"Prims.int",
"FStar.Tactics.NamedView.r_subst_binder_sort",
"FStar.Reflection.V2.Derived.shift_subst"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val subst_r_binders (s: subst_t) (bs: list R.binder) : list R.binder | [] | FStar.Tactics.NamedView.subst_r_binders | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Stubs.Syntax.Syntax.subst_t -> bs: Prims.list FStar.Reflection.Types.binder
-> Prims.list FStar.Reflection.Types.binder | {
"end_col": 71,
"end_line": 551,
"start_col": 2,
"start_line": 551
} |
FStar.Tactics.Effect.Tac | val open_lb (lb: R.letbinding) : Tac letbinding | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def } | val open_lb (lb: R.letbinding) : Tac letbinding
let open_lb (lb: R.letbinding) : Tac letbinding = | true | null | false | let { lb_fv = lb_fv ; lb_us = lb_us ; lb_typ = lb_typ ; lb_def = lb_def } = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv = lb_fv; lb_us = lb_us; lb_typ = lb_typ; lb_def = lb_def } | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.Types.letbinding",
"FStar.Reflection.Types.fv",
"Prims.list",
"FStar.Reflection.Types.univ_name",
"FStar.Reflection.Types.typ",
"FStar.Reflection.Types.term",
"FStar.Tactics.NamedView.univ_name",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Tactics.NamedView.Mkletbinding",
"FStar.Reflection.V2.Builtins.subst_term",
"FStar.Tactics.NamedView.letbinding",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.open_univ_s",
"FStar.Reflection.V2.Data.lb_view",
"Prims.precedes",
"FStar.Reflection.V2.Builtins.inspect_lb"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_lb (lb: R.letbinding) : Tac letbinding | [] | FStar.Tactics.NamedView.open_lb | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | lb: FStar.Reflection.Types.letbinding -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.letbinding | {
"end_col": 34,
"end_line": 539,
"start_col": 50,
"start_line": 534
} |
Prims.Tot | val subst_binder_sort (s: subst_t) (b: binder) : binder | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort } | val subst_binder_sort (s: subst_t) (b: binder) : binder
let subst_binder_sort (s: subst_t) (b: binder) : binder = | false | null | false | { b with sort = subst_term s b.sort } | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.Mkbinder",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__uniq",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__ppname",
"FStar.Reflection.V2.Builtins.subst_term",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__sort",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__qual",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__attrs"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val subst_binder_sort (s: subst_t) (b: binder) : binder | [] | FStar.Tactics.NamedView.subst_binder_sort | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Stubs.Syntax.Syntax.subst_t -> b: FStar.Tactics.NamedView.binder
-> FStar.Tactics.NamedView.binder | {
"end_col": 37,
"end_line": 232,
"start_col": 4,
"start_line": 232
} |
FStar.Tactics.Effect.Tac | val open_univ_s (us: list R.univ_name) : Tac (list univ_name & subst_t) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s | val open_univ_s (us: list R.univ_name) : Tac (list univ_name & subst_t)
let open_univ_s (us: list R.univ_name) : Tac (list univ_name & subst_t) = | true | null | false | let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n - 1 - i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"Prims.list",
"FStar.Reflection.Types.univ_name",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.univ_name",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.Util.map",
"FStar.Reflection.Types.ident",
"FStar.Reflection.V2.Data.ident_view",
"FStar.Reflection.V2.Builtins.inspect_ident",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Tactics.Util.mapi",
"Prims.nat",
"FStar.Stubs.Syntax.Syntax.UN",
"Prims.op_Subtraction",
"FStar.Reflection.V2.Builtins.pack_universe",
"FStar.Reflection.V2.Data.Uv_Name",
"FStar.List.Tot.Base.length"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_univ_s (us: list R.univ_name) : Tac (list univ_name & subst_t) | [] | FStar.Tactics.NamedView.open_univ_s | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | us: Prims.list FStar.Reflection.Types.univ_name
-> FStar.Tactics.Effect.Tac
(Prims.list FStar.Tactics.NamedView.univ_name * FStar.Stubs.Syntax.Syntax.subst_t) | {
"end_col": 43,
"end_line": 524,
"start_col": 74,
"start_line": 521
} |
Prims.Tot | val close_lb (lb: letbinding) : R.letbinding | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def } | val close_lb (lb: letbinding) : R.letbinding
let close_lb (lb: letbinding) : R.letbinding = | false | null | false | let { lb_fv = lb_fv ; lb_us = lb_us ; lb_typ = lb_typ ; lb_def = lb_def } = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb ({ lb_fv = lb_fv; lb_us = lb_us; lb_typ = lb_typ; lb_def = lb_def }) | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.letbinding",
"FStar.Reflection.Types.fv",
"Prims.list",
"FStar.Tactics.NamedView.univ_name",
"FStar.Reflection.Types.typ",
"FStar.Tactics.NamedView.term",
"FStar.Reflection.Types.univ_name",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Reflection.V2.Builtins.pack_lb",
"FStar.Reflection.V2.Data.Mklb_view",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.subst_term",
"FStar.Reflection.Types.letbinding",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.close_univ_s"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def } | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_lb (lb: letbinding) : R.letbinding | [] | FStar.Tactics.NamedView.close_lb | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | lb: FStar.Tactics.NamedView.letbinding -> FStar.Reflection.Types.letbinding | {
"end_col": 42,
"end_line": 547,
"start_col": 47,
"start_line": 542
} |
FStar.Tactics.Effect.Tac | val tcc (e:env) (t:term) : Tac comp | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tcc (e:env) (t:term) : Tac comp =
let c : R.comp = V2.Builtins.tcc e t in
R.inspect_comp c | val tcc (e:env) (t:term) : Tac comp
let tcc (e: env) (t: term) : Tac comp = | true | null | false | let c:R.comp = V2.Builtins.tcc e t in
R.inspect_comp c | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.Types.env",
"FStar.Tactics.NamedView.term",
"FStar.Reflection.V2.Builtins.inspect_comp",
"FStar.Tactics.NamedView.comp",
"FStar.Reflection.Types.comp",
"FStar.Tactics.V2.Builtins.tcc"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk
private
let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t')
private
let close_sigelt_view (sv : named_sigelt_view{~(Unk? sv)}) : Tac (sv:sigelt_view{~(RD.Unk? sv)}) =
match sv with
| Sg_Let { isrec; lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive {nm; univs; params; typ; ctors} ->
let nparams = List.Tot.length params in
(* Abstract constructors by the parameters. This
is the inverse of the open_n_binders_from_arrow above. *)
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
(* Close parameters in themselves and typ *)
let params, typ = close_term_n params typ in
(* close univs *)
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val {nm; univs; typ} ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ
[@@plugin]
let inspect_sigelt (s : sigelt) : Tac named_sigelt_view =
let sv = R.inspect_sigelt s in
(* dump ("sv orig = " ^ term_to_string (quote sv)); *)
open_sigelt_view sv
[@@plugin]
let pack_sigelt (sv:named_sigelt_view{~(Unk? sv)}) : Tac sigelt =
let sv = close_sigelt_view sv in
R.pack_sigelt sv | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tcc (e:env) (t:term) : Tac comp | [] | FStar.Tactics.NamedView.tcc | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | e: FStar.Reflection.Types.env -> t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.comp | {
"end_col": 18,
"end_line": 660,
"start_col": 37,
"start_line": 658
} |
FStar.Tactics.Effect.Tac | val comp_to_string (c:comp) : Tac string | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let comp_to_string (c:comp) : Tac string = V2.Builtins.comp_to_string (R.pack_comp c) | val comp_to_string (c:comp) : Tac string
let comp_to_string (c: comp) : Tac string = | true | null | false | V2.Builtins.comp_to_string (R.pack_comp c) | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Tactics.NamedView.comp",
"FStar.Tactics.V2.Builtins.comp_to_string",
"FStar.Reflection.V2.Builtins.pack_comp",
"Prims.string"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk
private
let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t')
private
let close_sigelt_view (sv : named_sigelt_view{~(Unk? sv)}) : Tac (sv:sigelt_view{~(RD.Unk? sv)}) =
match sv with
| Sg_Let { isrec; lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive {nm; univs; params; typ; ctors} ->
let nparams = List.Tot.length params in
(* Abstract constructors by the parameters. This
is the inverse of the open_n_binders_from_arrow above. *)
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
(* Close parameters in themselves and typ *)
let params, typ = close_term_n params typ in
(* close univs *)
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val {nm; univs; typ} ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ
[@@plugin]
let inspect_sigelt (s : sigelt) : Tac named_sigelt_view =
let sv = R.inspect_sigelt s in
(* dump ("sv orig = " ^ term_to_string (quote sv)); *)
open_sigelt_view sv
[@@plugin]
let pack_sigelt (sv:named_sigelt_view{~(Unk? sv)}) : Tac sigelt =
let sv = close_sigelt_view sv in
R.pack_sigelt sv
let tcc (e:env) (t:term) : Tac comp =
let c : R.comp = V2.Builtins.tcc e t in
R.inspect_comp c | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val comp_to_string (c:comp) : Tac string | [] | FStar.Tactics.NamedView.comp_to_string | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | c: FStar.Tactics.NamedView.comp -> FStar.Tactics.Effect.Tac Prims.string | {
"end_col": 85,
"end_line": 662,
"start_col": 43,
"start_line": 662
} |
Prims.Tot | val close_branch (b: branch) : Tot R.branch | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t') | val close_branch (b: branch) : Tot R.branch
let close_branch (b: branch) : Tot R.branch = | false | null | false | let pat, t = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.branch",
"FStar.Tactics.NamedView.pattern",
"FStar.Tactics.NamedView.term",
"FStar.Reflection.V2.Data.pattern",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.subst_term",
"FStar.Reflection.V2.Data.branch",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.close_pat",
"Prims.Nil",
"FStar.Stubs.Syntax.Syntax.subst_elt"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_branch (b: branch) : Tot R.branch | [] | FStar.Tactics.NamedView.close_branch | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Tactics.NamedView.branch -> FStar.Reflection.V2.Data.branch | {
"end_col": 11,
"end_line": 371,
"start_col": 46,
"start_line": 367
} |
FStar.Tactics.Effect.Tac | val pack_sigelt (sv:named_sigelt_view{~(Unk? sv)}) : Tac sigelt | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pack_sigelt (sv:named_sigelt_view{~(Unk? sv)}) : Tac sigelt =
let sv = close_sigelt_view sv in
R.pack_sigelt sv | val pack_sigelt (sv:named_sigelt_view{~(Unk? sv)}) : Tac sigelt
let pack_sigelt (sv: named_sigelt_view{~(Unk? sv)}) : Tac sigelt = | true | null | false | let sv = close_sigelt_view sv in
R.pack_sigelt sv | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Tactics.NamedView.named_sigelt_view",
"Prims.l_not",
"Prims.b2t",
"FStar.Tactics.NamedView.uu___is_Unk",
"FStar.Reflection.V2.Builtins.pack_sigelt",
"FStar.Reflection.Types.sigelt",
"FStar.Reflection.V2.Data.sigelt_view",
"FStar.Reflection.V2.Data.uu___is_Unk",
"FStar.Tactics.NamedView.close_sigelt_view"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk
private
let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t')
private
let close_sigelt_view (sv : named_sigelt_view{~(Unk? sv)}) : Tac (sv:sigelt_view{~(RD.Unk? sv)}) =
match sv with
| Sg_Let { isrec; lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive {nm; univs; params; typ; ctors} ->
let nparams = List.Tot.length params in
(* Abstract constructors by the parameters. This
is the inverse of the open_n_binders_from_arrow above. *)
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
(* Close parameters in themselves and typ *)
let params, typ = close_term_n params typ in
(* close univs *)
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val {nm; univs; typ} ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ
[@@plugin]
let inspect_sigelt (s : sigelt) : Tac named_sigelt_view =
let sv = R.inspect_sigelt s in
(* dump ("sv orig = " ^ term_to_string (quote sv)); *)
open_sigelt_view sv | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pack_sigelt (sv:named_sigelt_view{~(Unk? sv)}) : Tac sigelt | [] | FStar.Tactics.NamedView.pack_sigelt | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | sv: FStar.Tactics.NamedView.named_sigelt_view{~(Unk? sv)}
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.sigelt | {
"end_col": 18,
"end_line": 656,
"start_col": 65,
"start_line": 654
} |
FStar.Tactics.Effect.Tac | val inspect_sigelt (s : sigelt) : Tac named_sigelt_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inspect_sigelt (s : sigelt) : Tac named_sigelt_view =
let sv = R.inspect_sigelt s in
(* dump ("sv orig = " ^ term_to_string (quote sv)); *)
open_sigelt_view sv | val inspect_sigelt (s : sigelt) : Tac named_sigelt_view
let inspect_sigelt (s: sigelt) : Tac named_sigelt_view = | true | null | false | let sv = R.inspect_sigelt s in
open_sigelt_view sv | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.Types.sigelt",
"FStar.Tactics.NamedView.open_sigelt_view",
"FStar.Tactics.NamedView.named_sigelt_view",
"FStar.Reflection.V2.Data.sigelt_view",
"FStar.Reflection.V2.Builtins.inspect_sigelt"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk
private
let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t')
private
let close_sigelt_view (sv : named_sigelt_view{~(Unk? sv)}) : Tac (sv:sigelt_view{~(RD.Unk? sv)}) =
match sv with
| Sg_Let { isrec; lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive {nm; univs; params; typ; ctors} ->
let nparams = List.Tot.length params in
(* Abstract constructors by the parameters. This
is the inverse of the open_n_binders_from_arrow above. *)
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
(* Close parameters in themselves and typ *)
let params, typ = close_term_n params typ in
(* close univs *)
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val {nm; univs; typ} ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inspect_sigelt (s : sigelt) : Tac named_sigelt_view | [] | FStar.Tactics.NamedView.inspect_sigelt | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Reflection.Types.sigelt
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.named_sigelt_view | {
"end_col": 21,
"end_line": 651,
"start_col": 57,
"start_line": 648
} |
Prims.Tot | val close_universe_view (v: named_universe_view) : R.universe_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk | val close_universe_view (v: named_universe_view) : R.universe_view
let close_universe_view (v: named_universe_view) : R.universe_view = | false | null | false | match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.named_universe_view",
"FStar.Reflection.V2.Data.Uv_Zero",
"FStar.Tactics.NamedView.universe",
"FStar.Reflection.V2.Data.Uv_Succ",
"FStar.Reflection.V2.Data.universes",
"FStar.Reflection.V2.Data.Uv_Max",
"Prims.nat",
"FStar.Reflection.V2.Data.Uv_BVar",
"FStar.Tactics.NamedView.univ_name",
"FStar.Reflection.V2.Data.Uv_Name",
"FStar.Reflection.V2.Builtins.pack_ident",
"FStar.Reflection.Types.universe_uvar",
"FStar.Reflection.V2.Data.Uv_Unif",
"FStar.Reflection.V2.Data.Uv_Unk",
"FStar.Reflection.V2.Data.universe_view"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_universe_view (v: named_universe_view) : R.universe_view | [] | FStar.Tactics.NamedView.close_universe_view | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | v: FStar.Tactics.NamedView.named_universe_view -> FStar.Reflection.V2.Data.universe_view | {
"end_col": 22,
"end_line": 55,
"start_col": 2,
"start_line": 48
} |
FStar.Tactics.Effect.Tac | val open_comp_simple (b: R.simple_binder) (t: comp) : Tac (simple_binder & comp) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t') | val open_comp_simple (b: R.simple_binder) (t: comp) : Tac (simple_binder & comp)
let open_comp_simple (b: R.simple_binder) (t: comp) : Tac (simple_binder & comp) = | true | null | false | let n = fresh () in
let bv:binder_view = inspect_binder b in
let nv:R.namedv = pack_namedv ({ uniq = n; sort = seal bv.sort; ppname = bv.ppname }) in
let t' = subst_comp [DB 0 nv] t in
let bndr:binder =
{ uniq = n; sort = bv.sort; ppname = bv.ppname; qual = bv.qual; attrs = bv.attrs }
in
(bndr, t') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.V2.Data.simple_binder",
"FStar.Tactics.NamedView.comp",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.simple_binder",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.Mkbinder",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__ppname",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__sort",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__qual",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__attrs",
"FStar.Tactics.NamedView.subst_comp",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.DB",
"Prims.Nil",
"FStar.Reflection.Types.namedv",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Sealed.seal",
"FStar.Reflection.Types.typ",
"FStar.Reflection.V2.Data.binder_view",
"FStar.Reflection.V2.Builtins.inspect_binder",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"FStar.Tactics.V2.Builtins.fresh"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t') | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_comp_simple (b: R.simple_binder) (t: comp) : Tac (simple_binder & comp) | [] | FStar.Tactics.NamedView.open_comp_simple | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Reflection.V2.Data.simple_binder -> t: FStar.Tactics.NamedView.comp
-> FStar.Tactics.Effect.Tac (FStar.Tactics.NamedView.simple_binder * FStar.Tactics.NamedView.comp) | {
"end_col": 12,
"end_line": 193,
"start_col": 84,
"start_line": 175
} |
Prims.Tot | val open_universe_view (v: RD.universe_view) : named_universe_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk | val open_universe_view (v: RD.universe_view) : named_universe_view
let open_universe_view (v: RD.universe_view) : named_universe_view = | false | null | false | match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Reflection.V2.Data.universe_view",
"FStar.Tactics.NamedView.Uv_Zero",
"FStar.Reflection.Types.universe",
"FStar.Tactics.NamedView.Uv_Succ",
"FStar.Reflection.V2.Data.universes",
"FStar.Tactics.NamedView.Uv_Max",
"Prims.nat",
"FStar.Tactics.NamedView.Uv_BVar",
"FStar.Reflection.Types.univ_name",
"FStar.Tactics.NamedView.Uv_Name",
"FStar.Reflection.V2.Builtins.inspect_ident",
"FStar.Reflection.Types.universe_uvar",
"FStar.Tactics.NamedView.Uv_Unif",
"FStar.Tactics.NamedView.Uv_Unk",
"FStar.Tactics.NamedView.named_universe_view"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_universe_view (v: RD.universe_view) : named_universe_view | [] | FStar.Tactics.NamedView.open_universe_view | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | v: FStar.Reflection.V2.Data.universe_view -> FStar.Tactics.NamedView.named_universe_view | {
"end_col": 22,
"end_line": 41,
"start_col": 2,
"start_line": 34
} |
FStar.Tactics.Effect.Tac | val open_term_simple (b: R.simple_binder) (t: term) : Tac (simple_binder & term) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t') | val open_term_simple (b: R.simple_binder) (t: term) : Tac (simple_binder & term)
let open_term_simple (b: R.simple_binder) (t: term) : Tac (simple_binder & term) = | true | null | false | let n = fresh () in
let bv:binder_view = inspect_binder b in
let nv:R.namedv = pack_namedv ({ uniq = n; sort = seal bv.sort; ppname = bv.ppname }) in
let t' = subst_term [DB 0 nv] t in
let bndr:binder =
{ uniq = n; sort = bv.sort; ppname = bv.ppname; qual = bv.qual; attrs = bv.attrs }
in
(bndr, t') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.V2.Data.simple_binder",
"FStar.Tactics.NamedView.term",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.simple_binder",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.Mkbinder",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__ppname",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__sort",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__qual",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__attrs",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.subst_term",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.DB",
"Prims.Nil",
"FStar.Reflection.Types.namedv",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Sealed.seal",
"FStar.Reflection.Types.typ",
"FStar.Reflection.V2.Data.binder_view",
"FStar.Reflection.V2.Builtins.inspect_binder",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"FStar.Tactics.V2.Builtins.fresh"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *) | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_term_simple (b: R.simple_binder) (t: term) : Tac (simple_binder & term) | [] | FStar.Tactics.NamedView.open_term_simple | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Reflection.V2.Data.simple_binder -> t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac (FStar.Tactics.NamedView.simple_binder * FStar.Tactics.NamedView.term) | {
"end_col": 12,
"end_line": 172,
"start_col": 84,
"start_line": 154
} |
Prims.Tot | val close_comp_simple (b: simple_binder) (t: comp) : R.simple_binder & comp | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t') | val close_comp_simple (b: simple_binder) (t: comp) : R.simple_binder & comp
let close_comp_simple (b: simple_binder) (t: comp) : R.simple_binder & comp = | false | null | false | let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv:binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.simple_binder",
"FStar.Tactics.NamedView.comp",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V2.Data.simple_binder",
"Prims.unit",
"FStar.Reflection.V2.Builtins.inspect_pack_binder",
"FStar.Reflection.Types.binder",
"FStar.Reflection.V2.Builtins.pack_binder",
"FStar.Reflection.V2.Data.binder_view",
"FStar.Reflection.V2.Data.Mkbinder_view",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__sort",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__qual",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__attrs",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__ppname",
"FStar.Tactics.NamedView.subst_comp",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.NM",
"Prims.Nil",
"FStar.Reflection.Types.namedv",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t') | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_comp_simple (b: simple_binder) (t: comp) : R.simple_binder & comp | [] | FStar.Tactics.NamedView.close_comp_simple | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Tactics.NamedView.simple_binder -> t: FStar.Tactics.NamedView.comp
-> FStar.Reflection.V2.Data.simple_binder * FStar.Tactics.NamedView.comp | {
"end_col": 9,
"end_line": 223,
"start_col": 75,
"start_line": 217
} |
Prims.Tot | val close_term_n (bs: list binder) (t: term) : list R.binder & term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t | val close_term_n (bs: list binder) (t: term) : list R.binder & term
let close_term_n (bs: list binder) (t: term) : list R.binder & term = | false | null | false | let rec aux (bs: list binder) (cbs: list R.binder) (s: subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b :: bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b :: cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"Prims.list",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.term",
"FStar.Reflection.Types.binder",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Pervasives.Native.Mktuple2",
"FStar.List.Tot.Base.rev",
"FStar.Reflection.V2.Builtins.subst_term",
"FStar.Pervasives.Native.tuple2",
"Prims.Nil",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.NM",
"FStar.Reflection.V2.Derived.shift_subst",
"FStar.Tactics.NamedView.close_binder",
"FStar.Reflection.Types.namedv",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"FStar.Tactics.NamedView.subst_binder_sort"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_term_n (bs: list binder) (t: term) : list R.binder & term | [] | FStar.Tactics.NamedView.close_term_n | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Tactics.NamedView.binder -> t: FStar.Tactics.NamedView.term
-> Prims.list FStar.Reflection.Types.binder * FStar.Tactics.NamedView.term | {
"end_col": 34,
"end_line": 272,
"start_col": 71,
"start_line": 261
} |
Prims.Tot | val close_view (tv: named_term_view) : Tot term_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs | val close_view (tv: named_term_view) : Tot term_view
let close_view (tv: named_term_view) : Tot term_view = | false | null | false | match tv with
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def = if recf then subst_term [NM (r_binder_to_namedv nb) 0] def else def in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.named_term_view",
"FStar.Tactics.NamedView.namedv",
"FStar.Reflection.V2.Data.Tv_Var",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Tactics.NamedView.bv",
"FStar.Reflection.V2.Data.Tv_BVar",
"FStar.Reflection.V2.Builtins.pack_bv",
"FStar.Reflection.Types.fv",
"FStar.Reflection.V2.Data.Tv_FVar",
"FStar.Reflection.V2.Data.universes",
"FStar.Reflection.V2.Data.Tv_UInst",
"FStar.Tactics.NamedView.term",
"FStar.Reflection.V2.Data.argv",
"FStar.Reflection.V2.Data.Tv_App",
"FStar.Tactics.NamedView.universe",
"FStar.Reflection.V2.Data.Tv_Type",
"FStar.Reflection.V2.Data.vconst",
"FStar.Reflection.V2.Data.Tv_Const",
"Prims.nat",
"FStar.Reflection.Types.ctx_uvar_and_subst",
"FStar.Reflection.V2.Data.Tv_Uvar",
"FStar.Pervasives.Native.option",
"Prims.bool",
"FStar.Reflection.V2.Data.Tv_AscribedT",
"FStar.Tactics.NamedView.comp",
"FStar.Reflection.V2.Data.Tv_AscribedC",
"FStar.Reflection.V2.Builtins.pack_comp",
"FStar.Reflection.V2.Data.Tv_Unknown",
"FStar.Reflection.V2.Data.Tv_Unsupp",
"FStar.Tactics.NamedView.binder",
"FStar.Reflection.Types.binder",
"FStar.Reflection.V2.Data.Tv_Abs",
"FStar.Reflection.V2.Data.term_view",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.close_term",
"FStar.Reflection.V2.Data.Tv_Arrow",
"FStar.Reflection.Types.comp",
"FStar.Tactics.NamedView.close_comp",
"FStar.Tactics.NamedView.simple_binder",
"FStar.Reflection.V2.Data.simple_binder",
"FStar.Reflection.V2.Data.Tv_Refine",
"FStar.Tactics.NamedView.close_term_simple",
"Prims.list",
"FStar.Reflection.V2.Data.Tv_Let",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.subst_term",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.NM",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"Prims.Nil",
"FStar.Tactics.NamedView.match_returns_ascription",
"FStar.Tactics.NamedView.branch",
"FStar.Reflection.V2.Data.Tv_Match",
"FStar.Reflection.Types.match_returns_ascription",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"FStar.Tactics.NamedView.close_match_returns_ascription",
"FStar.Reflection.V2.Data.branch",
"FStar.List.Tot.Base.map",
"FStar.Tactics.NamedView.close_branch"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_view (tv: named_term_view) : Tot term_view | [] | FStar.Tactics.NamedView.close_view | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | tv: FStar.Tactics.NamedView.named_term_view -> FStar.Reflection.V2.Data.term_view | {
"end_col": 33,
"end_line": 507,
"start_col": 2,
"start_line": 458
} |
Prims.Tot | val close_term_n_simple (bs: list simple_binder) (t: term) : list R.simple_binder & term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'') | val close_term_n_simple (bs: list simple_binder) (t: term) : list R.simple_binder & term
let rec close_term_n_simple (bs: list simple_binder) (t: term) : list R.simple_binder & term = | false | null | false | match bs with
| [] -> ([], t)
| b :: bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b' :: bs', t'') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"Prims.list",
"FStar.Tactics.NamedView.simple_binder",
"FStar.Tactics.NamedView.term",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V2.Data.simple_binder",
"Prims.Nil",
"Prims.Cons",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.close_term_simple",
"FStar.Tactics.NamedView.close_term_n_simple"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_term_n_simple (bs: list simple_binder) (t: term) : list R.simple_binder & term | [
"recursion"
] | FStar.Tactics.NamedView.close_term_n_simple | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Tactics.NamedView.simple_binder -> t: FStar.Tactics.NamedView.term
-> Prims.list FStar.Reflection.V2.Data.simple_binder * FStar.Tactics.NamedView.term | {
"end_col": 18,
"end_line": 290,
"start_col": 2,
"start_line": 285
} |
FStar.Tactics.Effect.Tac | val __open_term_n_aux (bs: list R.binder) (nbs: list binder) (s: subst_t)
: Tac (list binder & subst_t) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s) | val __open_term_n_aux (bs: list R.binder) (nbs: list binder) (s: subst_t)
: Tac (list binder & subst_t)
let rec __open_term_n_aux (bs: list R.binder) (nbs: list binder) (s: subst_t)
: Tac (list binder & subst_t) = | true | null | false | match bs with
| [] -> nbs, s
| b :: bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b :: nbs) (DB 0 nv :: shift_subst 1 s) | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"Prims.list",
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.binder",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.__open_term_n_aux",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.DB",
"FStar.Reflection.V2.Derived.shift_subst",
"FStar.Reflection.Types.namedv",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"FStar.Tactics.NamedView.open_binder",
"FStar.Tactics.NamedView.r_subst_binder_sort"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val __open_term_n_aux (bs: list R.binder) (nbs: list binder) (s: subst_t)
: Tac (list binder & subst_t) | [
"recursion"
] | FStar.Tactics.NamedView.__open_term_n_aux | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
bs: Prims.list FStar.Reflection.Types.binder ->
nbs: Prims.list FStar.Tactics.NamedView.binder ->
s: FStar.Stubs.Syntax.Syntax.subst_t
-> FStar.Tactics.Effect.Tac
(Prims.list FStar.Tactics.NamedView.binder * FStar.Stubs.Syntax.Syntax.subst_t) | {
"end_col": 62,
"end_line": 243,
"start_col": 2,
"start_line": 237
} |
FStar.Tactics.Effect.Tac | val open_n_binders_from_arrow (bs: binders) (t: term) : Tac term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders | val open_n_binders_from_arrow (bs: binders) (t: term) : Tac term
let rec open_n_binders_from_arrow (bs: binders) (t: term) : Tac term = | true | null | false | match bs with
| [] -> t
| b :: bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' =
subst_term [
NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))
]
t'
in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Tactics.NamedView.binders",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.binder",
"Prims.list",
"FStar.Reflection.Types.typ",
"FStar.Tactics.NamedView.open_n_binders_from_arrow",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.subst_term",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.NT",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"FStar.Tactics.NamedView.pack",
"FStar.Tactics.NamedView.Tv_Var",
"FStar.Reflection.V2.Builtins.inspect_namedv",
"Prims.Nil",
"FStar.Tactics.NamedView.named_term_view",
"FStar.Tactics.Effect.raise",
"FStar.Tactics.NamedView.NotEnoughBinders",
"FStar.Tactics.NamedView.inspect"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_n_binders_from_arrow (bs: binders) (t: term) : Tac term | [
"recursion"
] | FStar.Tactics.NamedView.open_n_binders_from_arrow | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: FStar.Tactics.NamedView.binders -> t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.term | {
"end_col": 33,
"end_line": 562,
"start_col": 2,
"start_line": 555
} |
Prims.Tot | val close_match_returns_ascription (mra: match_returns_ascription) : R.match_returns_ascription | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq)) | val close_match_returns_ascription (mra: match_returns_ascription) : R.match_returns_ascription
let close_match_returns_ascription (mra: match_returns_ascription) : R.match_returns_ascription = | false | null | false | let nb, (ct, topt, use_eq) = mra in
let b = close_binder nb in
let ct =
match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq)) | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.match_returns_ascription",
"FStar.Tactics.NamedView.binder",
"FStar.Pervasives.either",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.comp",
"FStar.Pervasives.Native.option",
"Prims.bool",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.Types.binder",
"FStar.Pervasives.Native.tuple3",
"FStar.Reflection.Types.term",
"FStar.Reflection.Types.comp",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.snd",
"FStar.Tactics.NamedView.close_term",
"FStar.Pervasives.Inl",
"FStar.Pervasives.Inr",
"FStar.Reflection.V2.Builtins.pack_comp",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.close_comp",
"FStar.Tactics.NamedView.close_binder",
"FStar.Reflection.Types.match_returns_ascription"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq)) | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_match_returns_ascription (mra: match_returns_ascription) : R.match_returns_ascription | [] | FStar.Tactics.NamedView.close_match_returns_ascription | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | mra: FStar.Tactics.NamedView.match_returns_ascription
-> FStar.Reflection.Types.match_returns_ascription | {
"end_col": 25,
"end_line": 408,
"start_col": 98,
"start_line": 392
} |
FStar.Tactics.Effect.Tac | val open_sigelt_view (sv: sigelt_view) : Tac named_sigelt_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk | val open_sigelt_view (sv: sigelt_view) : Tac named_sigelt_view
let open_sigelt_view (sv: sigelt_view) : Tac named_sigelt_view = | true | null | false | match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
Sg_Let ({ isrec = isrec; lbs = lbs })
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
let params, typ = open_term_n params typ in
let ctors =
map (fun (nm, ty) ->
let ty' = open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive ({ nm = nm; univs = univs; params = params; typ = typ; ctors = ctors })
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val ({ nm = nm; univs = univs; typ = typ })
| RD.Unk -> Unk | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.V2.Data.sigelt_view",
"Prims.bool",
"Prims.list",
"FStar.Reflection.Types.letbinding",
"FStar.Tactics.NamedView.Sg_Let",
"FStar.Tactics.NamedView.Mknamed_sigelt_view__Sg_Let__payload",
"FStar.Tactics.NamedView.named_sigelt_view",
"FStar.Tactics.NamedView.letbinding",
"FStar.Tactics.Util.map",
"FStar.Tactics.NamedView.open_lb",
"FStar.Reflection.Types.name",
"FStar.Reflection.Types.univ_name",
"FStar.Reflection.Types.binders",
"FStar.Reflection.Types.typ",
"FStar.Reflection.V2.Data.ctor",
"FStar.Tactics.NamedView.univ_name",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.Sg_Inductive",
"FStar.Tactics.NamedView.Mknamed_sigelt_view__Sg_Inductive__payload",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.open_n_binders_from_arrow",
"FStar.Tactics.NamedView.open_term_n",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.subst_term",
"FStar.Reflection.V2.Derived.shift_subst",
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.subst_r_binders",
"FStar.Tactics.NamedView.open_univ_s",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Tactics.NamedView.Sg_Val",
"FStar.Tactics.NamedView.Mknamed_sigelt_view__Sg_Val__payload",
"FStar.Tactics.NamedView.Unk"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_sigelt_view (sv: sigelt_view) : Tac named_sigelt_view | [] | FStar.Tactics.NamedView.open_sigelt_view | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | sv: FStar.Reflection.V2.Data.sigelt_view
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.named_sigelt_view | {
"end_col": 17,
"end_line": 603,
"start_col": 2,
"start_line": 566
} |
FStar.Tactics.Effect.Tac | val open_pat (p: R.pattern) (s: subst_t) : Tac (pattern & subst_t) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s | val open_pat (p: R.pattern) (s: subst_t) : Tac (pattern & subst_t)
let rec open_pat (p: R.pattern) (s: subst_t) : Tac (pattern & subst_t) = | true | null | false | match p with
| R.Pat_Constant c -> Pat_Constant ({ c = c }), s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv:namedv = { uniq = fresh (); sort = seal sort; ppname = n } in
let nv = pack_namedv nvv in
Pat_Var ({ v = nvv; sort = seal sort }), (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s =
fold_left (fun (pats, s) (pat, b) ->
let pat, s' = open_pat pat s in
((pat, b) :: pats, s'))
([], s)
subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons ({ head = head; univs = univs; subpats = subpats }), s
| R.Pat_Dot_Term None -> Pat_Dot_Term ({ t = None }), s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term ({ t = Some t }), s | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.V2.Data.pattern",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Reflection.V2.Data.vconst",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.pattern",
"FStar.Tactics.NamedView.Pat_Constant",
"FStar.Tactics.NamedView.Mkpattern__Pat_Constant__payload",
"FStar.Pervasives.Native.tuple2",
"FStar.Sealed.sealed",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Data.ppname_t",
"FStar.Tactics.NamedView.Pat_Var",
"FStar.Tactics.NamedView.Mkpattern__Pat_Var__payload",
"FStar.Sealed.seal",
"FStar.Reflection.Types.typ",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.DB",
"FStar.Reflection.V2.Derived.shift_subst",
"FStar.Reflection.Types.namedv",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Tactics.NamedView.namedv",
"FStar.Reflection.V2.Data.Mknamedv_view",
"Prims.nat",
"FStar.Tactics.V2.Builtins.fresh",
"FStar.Reflection.V2.Builtins.subst_term",
"FStar.Tactics.Unseal.unseal",
"FStar.Reflection.Types.fv",
"FStar.Pervasives.Native.option",
"FStar.Reflection.V2.Data.universes",
"Prims.list",
"Prims.bool",
"FStar.Tactics.NamedView.Pat_Cons",
"FStar.Tactics.NamedView.Mkpattern__Pat_Cons__payload",
"FStar.List.Tot.Base.rev",
"FStar.Tactics.Util.fold_left",
"FStar.Tactics.NamedView.open_pat",
"Prims.Nil",
"FStar.Tactics.NamedView.Pat_Dot_Term",
"FStar.Tactics.NamedView.Mkpattern__Pat_Dot_Term__payload",
"FStar.Pervasives.Native.None",
"FStar.Tactics.NamedView.term",
"FStar.Pervasives.Native.Some"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_pat (p: R.pattern) (s: subst_t) : Tac (pattern & subst_t) | [
"recursion"
] | FStar.Tactics.NamedView.open_pat | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: FStar.Reflection.V2.Data.pattern -> s: FStar.Stubs.Syntax.Syntax.subst_t
-> FStar.Tactics.Effect.Tac (FStar.Tactics.NamedView.pattern * FStar.Stubs.Syntax.Syntax.subst_t) | {
"end_col": 30,
"end_line": 324,
"start_col": 2,
"start_line": 294
} |
Prims.Tot | val close_term_simple (b: simple_binder) (t: term) : R.simple_binder & term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t') | val close_term_simple (b: simple_binder) (t: term) : R.simple_binder & term
let close_term_simple (b: simple_binder) (t: term) : R.simple_binder & term = | false | null | false | let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv:binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
"total"
] | [
"FStar.Tactics.NamedView.simple_binder",
"FStar.Tactics.NamedView.term",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V2.Data.simple_binder",
"Prims.unit",
"FStar.Reflection.V2.Builtins.inspect_pack_binder",
"FStar.Reflection.Types.binder",
"FStar.Reflection.V2.Builtins.pack_binder",
"FStar.Reflection.V2.Data.binder_view",
"FStar.Reflection.V2.Data.Mkbinder_view",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__sort",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__qual",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__attrs",
"FStar.Tactics.NamedView.__proj__Mkbinder__item__ppname",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.subst_term",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.NM",
"Prims.Nil",
"FStar.Reflection.Types.namedv",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t') | false | true | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_term_simple (b: simple_binder) (t: term) : R.simple_binder & term | [] | FStar.Tactics.NamedView.close_term_simple | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Tactics.NamedView.simple_binder -> t: FStar.Tactics.NamedView.term
-> FStar.Reflection.V2.Data.simple_binder * FStar.Tactics.NamedView.term | {
"end_col": 9,
"end_line": 215,
"start_col": 75,
"start_line": 209
} |
FStar.Tactics.Effect.Tac | val open_term_n_simple (bs: list R.simple_binder) (t: term) : Tac (list simple_binder & term) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'') | val open_term_n_simple (bs: list R.simple_binder) (t: term) : Tac (list simple_binder & term)
let rec open_term_n_simple (bs: list R.simple_binder) (t: term) : Tac (list simple_binder & term) = | true | null | false | match bs with
| [] -> ([], t)
| b :: bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b' :: bs', t'') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"Prims.list",
"FStar.Reflection.V2.Data.simple_binder",
"FStar.Tactics.NamedView.term",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.simple_binder",
"Prims.Nil",
"FStar.Pervasives.Native.tuple2",
"Prims.Cons",
"FStar.Tactics.NamedView.open_term_simple",
"FStar.Tactics.NamedView.open_term_n_simple"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_term_n_simple (bs: list R.simple_binder) (t: term) : Tac (list simple_binder & term) | [
"recursion"
] | FStar.Tactics.NamedView.open_term_n_simple | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Reflection.V2.Data.simple_binder -> t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac
(Prims.list FStar.Tactics.NamedView.simple_binder * FStar.Tactics.NamedView.term) | {
"end_col": 18,
"end_line": 281,
"start_col": 2,
"start_line": 276
} |
FStar.Tactics.Effect.Tac | val mk_arr (args: list binder) (t: term) : Tac term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t') | val mk_arr (args: list binder) (t: term) : Tac term
let rec mk_arr (args: list binder) (t: term) : Tac term = | true | null | false | match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t') | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"Prims.list",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.pack",
"FStar.Tactics.NamedView.Tv_Arrow",
"FStar.Reflection.V2.Data.comp_view",
"FStar.Reflection.V2.Data.C_Total",
"FStar.Reflection.Types.typ",
"FStar.Tactics.NamedView.mk_arr"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk
private | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_arr (args: list binder) (t: term) : Tac term | [
"recursion"
] | FStar.Tactics.NamedView.mk_arr | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | args: Prims.list FStar.Tactics.NamedView.binder -> t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.term | {
"end_col": 24,
"end_line": 611,
"start_col": 2,
"start_line": 607
} |
FStar.Tactics.Effect.Tac | val open_match_returns_ascription (mra: R.match_returns_ascription) : Tac match_returns_ascription | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq)) | val open_match_returns_ascription (mra: R.match_returns_ascription) : Tac match_returns_ascription
let open_match_returns_ascription (mra: R.match_returns_ascription) : Tac match_returns_ascription = | true | null | false | let b, (ct, topt, use_eq) = mra in
let nb = open_binder b in
let ct =
match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq)) | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.Types.match_returns_ascription",
"FStar.Reflection.Types.binder",
"FStar.Pervasives.either",
"FStar.Reflection.Types.term",
"FStar.Reflection.Types.comp",
"FStar.Pervasives.Native.option",
"Prims.bool",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.binder",
"FStar.Pervasives.Native.tuple3",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.comp",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Tactics.NamedView.match_returns_ascription",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"FStar.Tactics.NamedView.open_term_with",
"FStar.Pervasives.Inl",
"FStar.Pervasives.Inr",
"FStar.Tactics.NamedView.open_comp_with",
"FStar.Reflection.V2.Data.comp_view",
"Prims.precedes",
"FStar.Reflection.V2.Builtins.inspect_comp",
"FStar.Tactics.NamedView.open_binder"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t') | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_match_returns_ascription (mra: R.match_returns_ascription) : Tac match_returns_ascription | [] | FStar.Tactics.NamedView.open_match_returns_ascription | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | mra: FStar.Reflection.Types.match_returns_ascription
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.match_returns_ascription | {
"end_col": 26,
"end_line": 389,
"start_col": 101,
"start_line": 374
} |
FStar.Tactics.Effect.Tac | val close_sigelt_view (sv: named_sigelt_view{~(Unk? sv)}) : Tac (sv: sigelt_view{~(RD.Unk? sv)}) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_sigelt_view (sv : named_sigelt_view{~(Unk? sv)}) : Tac (sv:sigelt_view{~(RD.Unk? sv)}) =
match sv with
| Sg_Let { isrec; lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive {nm; univs; params; typ; ctors} ->
let nparams = List.Tot.length params in
(* Abstract constructors by the parameters. This
is the inverse of the open_n_binders_from_arrow above. *)
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
(* Close parameters in themselves and typ *)
let params, typ = close_term_n params typ in
(* close univs *)
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val {nm; univs; typ} ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ | val close_sigelt_view (sv: named_sigelt_view{~(Unk? sv)}) : Tac (sv: sigelt_view{~(RD.Unk? sv)})
let close_sigelt_view (sv: named_sigelt_view{~(Unk? sv)}) : Tac (sv: sigelt_view{~(RD.Unk? sv)}) = | true | null | false | match sv with
| Sg_Let { isrec = isrec ; lbs = lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive { nm = nm ; univs = univs ; params = params ; typ = typ ; ctors = ctors } ->
let nparams = List.Tot.length params in
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
let params, typ = close_term_n params typ in
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val { nm = nm ; univs = univs ; typ = typ } ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Tactics.NamedView.named_sigelt_view",
"Prims.l_not",
"Prims.b2t",
"FStar.Tactics.NamedView.uu___is_Unk",
"Prims.bool",
"Prims.list",
"FStar.Tactics.NamedView.letbinding",
"FStar.Reflection.V2.Data.Sg_Let",
"FStar.Reflection.Types.letbinding",
"FStar.List.Tot.Base.map",
"FStar.Tactics.NamedView.close_lb",
"FStar.Reflection.V2.Data.sigelt_view",
"FStar.Reflection.V2.Data.uu___is_Unk",
"FStar.Reflection.Types.name",
"FStar.Tactics.NamedView.univ_name",
"FStar.Tactics.NamedView.binders",
"FStar.Reflection.Types.typ",
"FStar.Reflection.V2.Data.ctor",
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.term",
"FStar.Reflection.Types.univ_name",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Reflection.V2.Data.Sg_Inductive",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.term",
"FStar.Tactics.Util.map",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V2.Builtins.subst_term",
"FStar.Reflection.V2.Derived.shift_subst",
"FStar.Tactics.NamedView.subst_r_binders",
"FStar.Tactics.NamedView.close_univ_s",
"FStar.Tactics.NamedView.close_term_n",
"FStar.Tactics.NamedView.mk_arr",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Tactics.NamedView.binder",
"FStar.Reflection.V2.Data.Sg_Val"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk
private
let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t')
private | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_sigelt_view (sv: named_sigelt_view{~(Unk? sv)}) : Tac (sv: sigelt_view{~(RD.Unk? sv)}) | [] | FStar.Tactics.NamedView.close_sigelt_view | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | sv: FStar.Tactics.NamedView.named_sigelt_view{~(Unk? sv)}
-> FStar.Tactics.Effect.Tac (sv: FStar.Reflection.V2.Data.sigelt_view{~(Unk? sv)}) | {
"end_col": 26,
"end_line": 645,
"start_col": 2,
"start_line": 615
} |
FStar.Tactics.Effect.Tac | val open_view (tv: term_view) : Tac named_term_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Data",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs | val open_view (tv: term_view) : Tac named_term_view
let open_view (tv: term_view) : Tac named_term_view = | true | null | false | match tv with
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def = if recf then subst_term [DB 0 (r_binder_to_namedv nb)] def else def in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs | {
"checked_file": "FStar.Tactics.NamedView.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.Builtins.fsti.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [] | [
"FStar.Reflection.V2.Data.term_view",
"FStar.Reflection.Types.namedv",
"FStar.Tactics.NamedView.Tv_Var",
"FStar.Reflection.V2.Builtins.inspect_namedv",
"FStar.Tactics.NamedView.named_term_view",
"FStar.Reflection.Types.bv",
"FStar.Tactics.NamedView.Tv_BVar",
"FStar.Reflection.V2.Builtins.inspect_bv",
"FStar.Reflection.Types.fv",
"FStar.Tactics.NamedView.Tv_FVar",
"FStar.Reflection.V2.Data.universes",
"FStar.Tactics.NamedView.Tv_UInst",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Data.argv",
"FStar.Tactics.NamedView.Tv_App",
"FStar.Reflection.Types.universe",
"FStar.Tactics.NamedView.Tv_Type",
"FStar.Reflection.V2.Data.vconst",
"FStar.Tactics.NamedView.Tv_Const",
"Prims.nat",
"FStar.Reflection.Types.ctx_uvar_and_subst",
"FStar.Tactics.NamedView.Tv_Uvar",
"FStar.Pervasives.Native.option",
"Prims.bool",
"FStar.Tactics.NamedView.Tv_AscribedT",
"FStar.Reflection.Types.comp",
"FStar.Tactics.NamedView.Tv_AscribedC",
"FStar.Reflection.V2.Builtins.inspect_comp",
"FStar.Tactics.NamedView.Tv_Unknown",
"FStar.Tactics.NamedView.Tv_Unsupp",
"FStar.Reflection.Types.binder",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.Tv_Abs",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.open_term",
"FStar.Tactics.NamedView.comp",
"FStar.Tactics.NamedView.Tv_Arrow",
"FStar.Tactics.NamedView.open_comp",
"FStar.Reflection.V2.Data.simple_binder",
"FStar.Tactics.NamedView.simple_binder",
"FStar.Tactics.NamedView.Tv_Refine",
"FStar.Tactics.NamedView.open_term_simple",
"Prims.list",
"FStar.Tactics.NamedView.Tv_Let",
"FStar.Reflection.V2.Builtins.subst_term",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.DB",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"Prims.Nil",
"FStar.Reflection.Types.match_returns_ascription",
"FStar.Reflection.V2.Data.branch",
"FStar.Tactics.NamedView.Tv_Match",
"FStar.Tactics.NamedView.match_returns_ascription",
"FStar.Tactics.Util.map_opt",
"FStar.Tactics.NamedView.open_match_returns_ascription",
"FStar.Tactics.NamedView.branch",
"FStar.Tactics.Util.map",
"FStar.Tactics.NamedView.open_branch"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private | false | false | FStar.Tactics.NamedView.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_view (tv: term_view) : Tac named_term_view | [] | FStar.Tactics.NamedView.open_view | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | tv: FStar.Reflection.V2.Data.term_view
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.named_term_view | {
"end_col": 30,
"end_line": 454,
"start_col": 2,
"start_line": 412
} |
FStar.Tactics.Effect.Tac | val is_arith_goal: Prims.unit -> Tac bool | [
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Arith",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Formula",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_arith_goal () : Tac bool =
let g = cur_goal () in
match run_tm (is_arith_prop g) with
| Inr _ -> true
| _ -> false | val is_arith_goal: Prims.unit -> Tac bool
let is_arith_goal () : Tac bool = | true | null | false | let g = cur_goal () in
match run_tm (is_arith_prop g) with
| Inr _ -> true
| _ -> false | {
"checked_file": "FStar.Tactics.Arith.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.V2.Formula.fst.checked",
"FStar.Reflection.V2.Arith.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.Arith.fst"
} | [] | [
"Prims.unit",
"FStar.Reflection.V2.Arith.prop",
"FStar.Pervasives.either",
"Prims.string",
"Prims.bool",
"FStar.Reflection.V2.Arith.run_tm",
"FStar.Reflection.V2.Arith.is_arith_prop",
"FStar.Reflection.Types.typ",
"FStar.Tactics.V2.Derived.cur_goal"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.Arith
open FStar.Tactics.V2
open FStar.Reflection.V2.Formula
open FStar.Reflection.V2.Arith | false | false | FStar.Tactics.Arith.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_arith_goal: Prims.unit -> Tac bool | [] | FStar.Tactics.Arith.is_arith_goal | {
"file_name": "ulib/FStar.Tactics.Arith.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.bool | {
"end_col": 16,
"end_line": 27,
"start_col": 33,
"start_line": 23
} |
FStar.Tactics.Effect.Tac | val split_arith : unit -> Tac unit | [
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Arith",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Formula",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec split_arith () =
if is_arith_goal () then
begin
prune "";
addns "Prims";
smt ()
end
else begin
let g = cur_goal () in
match term_as_formula g with
| True_ ->
trivial ()
| And l r ->
seq FStar.Tactics.split split_arith
| Implies p q ->
let _ = implies_intro () in
seq split_arith l_revert
| Forall _x _sort _p ->
let bs = forall_intros () in
seq split_arith (fun () -> l_revert_all bs)
| _ ->
()
end | val split_arith : unit -> Tac unit
let rec split_arith () = | true | null | false | if is_arith_goal ()
then
(prune "";
addns "Prims";
smt ())
else
let g = cur_goal () in
match term_as_formula g with
| True_ -> trivial ()
| And l r -> seq FStar.Tactics.split split_arith
| Implies p q ->
let _ = implies_intro () in
seq split_arith l_revert
| Forall _x _sort _p ->
let bs = forall_intros () in
seq split_arith (fun () -> l_revert_all bs)
| _ -> () | {
"checked_file": "FStar.Tactics.Arith.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.V2.Formula.fst.checked",
"FStar.Reflection.V2.Arith.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.Arith.fst"
} | [] | [
"Prims.unit",
"FStar.Tactics.V2.Derived.smt",
"FStar.Tactics.V2.Builtins.addns",
"FStar.Tactics.V2.Builtins.prune",
"Prims.bool",
"FStar.Tactics.V2.Derived.trivial",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.V2.Derived.seq",
"FStar.Tactics.V1.Logic.split",
"FStar.Tactics.Arith.split_arith",
"FStar.Tactics.V2.Logic.l_revert",
"FStar.Tactics.NamedView.binding",
"FStar.Tactics.V2.Logic.implies_intro",
"FStar.Tactics.NamedView.bv",
"FStar.Reflection.Types.typ",
"FStar.Tactics.V2.Logic.l_revert_all",
"Prims.list",
"FStar.Tactics.V2.Logic.forall_intros",
"FStar.Reflection.V2.Formula.formula",
"FStar.Reflection.V2.Formula.term_as_formula",
"FStar.Tactics.V2.Derived.cur_goal",
"FStar.Tactics.Arith.is_arith_goal"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.Arith
open FStar.Tactics.V2
open FStar.Reflection.V2.Formula
open FStar.Reflection.V2.Arith
// decide if the current goal is arith, drop the built representation of it
let is_arith_goal () : Tac bool =
let g = cur_goal () in
match run_tm (is_arith_prop g) with
| Inr _ -> true
| _ -> false
val split_arith : unit -> Tac unit | false | false | FStar.Tactics.Arith.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val split_arith : unit -> Tac unit | [
"recursion"
] | FStar.Tactics.Arith.split_arith | {
"file_name": "ulib/FStar.Tactics.Arith.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit | {
"end_col": 7,
"end_line": 52,
"start_col": 4,
"start_line": 31
} |
FStar.Tactics.Effect.Tac | val printout_success (ge: genv) (a: assertions) : Tac unit | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let printout_success (ge:genv) (a:assertions) : Tac unit =
printout_result "ainfo" (ESuccess ge a) | val printout_success (ge: genv) (a: assertions) : Tac unit
let printout_success (ge: genv) (a: assertions) : Tac unit = | true | null | false | printout_result "ainfo" (ESuccess ge a) | {
"checked_file": "FStar.InteractiveHelpers.Output.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.InteractiveHelpers.Propositions.assertions",
"FStar.InteractiveHelpers.Output.printout_result",
"FStar.InteractiveHelpers.Output.ESuccess",
"Prims.unit"
] | [] | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix ""
let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p
let propositions_to_printout (ge:genv) (prefix:string) (pl:list proposition) : Tac string =
let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i+1
in
let str, _ = fold_left concat_prop (str,0) pl in
str
let error_message_to_printout (prefix : string) (message : option string) : Tot string =
let msg = match message with | Some msg -> msg | _ -> "" in
string_to_printout (prefix ^ ":error") msg
/// Utility type and function to communicate the results to emacs.
noeq type export_result =
| ESuccess : ge:genv -> a:assertions -> export_result
| EFailure : err:string -> export_result
let result_to_printout (prefix:string) (res:export_result) :
Tac string =
let str = prefix ^ ":BEGIN\n" in
(* Note that the emacs commands will always look for fields for the error message
* and the pre/post assertions, so we need to generate them, even though they
* might be empty. *)
let err, ge, pres, posts =
match res with
| ESuccess ge a -> None, ge, a.pres, a.posts
| EFailure err ->
let ge = mk_init_genv (top_env ()) in (* dummy environment - will not be used *)
Some err, ge, [], []
in
(* Error message *)
let str = str ^ error_message_to_printout prefix err in
(* Assertions *)
let str = str ^ propositions_to_printout ge (prefix ^ ":pres") pres in
let str = str ^ propositions_to_printout ge (prefix ^ ":posts") posts in
str ^ prefix ^ ":END\n" ^ "%FIH:FSTAR_META:END%"
let printout_result (prefix:string) (res:export_result) :
Tac unit =
print (result_to_printout prefix res)
/// The function to use to export the results in case of success | false | false | FStar.InteractiveHelpers.Output.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val printout_success (ge: genv) (a: assertions) : Tac unit | [] | FStar.InteractiveHelpers.Output.printout_success | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | ge: FStar.InteractiveHelpers.Base.genv -> a: FStar.InteractiveHelpers.Propositions.assertions
-> FStar.Tactics.Effect.Tac Prims.unit | {
"end_col": 41,
"end_line": 150,
"start_col": 2,
"start_line": 150
} |
Prims.Tot | val string_to_printout (prefix data: string) : Tot string | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n" | val string_to_printout (prefix data: string) : Tot string
let string_to_printout (prefix data: string) : Tot string = | false | null | false | prefix ^ ":\n" ^ data ^ "\n" | {
"checked_file": "FStar.InteractiveHelpers.Output.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
"total"
] | [
"Prims.string",
"Prims.op_Hat"
] | [] | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example). | false | true | FStar.InteractiveHelpers.Output.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val string_to_printout (prefix data: string) : Tot string | [] | FStar.InteractiveHelpers.Output.string_to_printout | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | prefix: Prims.string -> data: Prims.string -> Prims.string | {
"end_col": 30,
"end_line": 83,
"start_col": 2,
"start_line": 83
} |
FStar.Tactics.Effect.Tac | val tadmit_no_warning: Prims.unit -> Tac unit | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tadmit_no_warning () : Tac unit =
apply (`magic_witness) | val tadmit_no_warning: Prims.unit -> Tac unit
let tadmit_no_warning () : Tac unit = | true | null | false | apply (`magic_witness) | {
"checked_file": "FStar.InteractiveHelpers.Output.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [] | [
"Prims.unit",
"FStar.Tactics.V1.Derived.apply"
] | [] | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix ""
let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p
let propositions_to_printout (ge:genv) (prefix:string) (pl:list proposition) : Tac string =
let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i+1
in
let str, _ = fold_left concat_prop (str,0) pl in
str
let error_message_to_printout (prefix : string) (message : option string) : Tot string =
let msg = match message with | Some msg -> msg | _ -> "" in
string_to_printout (prefix ^ ":error") msg
/// Utility type and function to communicate the results to emacs.
noeq type export_result =
| ESuccess : ge:genv -> a:assertions -> export_result
| EFailure : err:string -> export_result
let result_to_printout (prefix:string) (res:export_result) :
Tac string =
let str = prefix ^ ":BEGIN\n" in
(* Note that the emacs commands will always look for fields for the error message
* and the pre/post assertions, so we need to generate them, even though they
* might be empty. *)
let err, ge, pres, posts =
match res with
| ESuccess ge a -> None, ge, a.pres, a.posts
| EFailure err ->
let ge = mk_init_genv (top_env ()) in (* dummy environment - will not be used *)
Some err, ge, [], []
in
(* Error message *)
let str = str ^ error_message_to_printout prefix err in
(* Assertions *)
let str = str ^ propositions_to_printout ge (prefix ^ ":pres") pres in
let str = str ^ propositions_to_printout ge (prefix ^ ":posts") posts in
str ^ prefix ^ ":END\n" ^ "%FIH:FSTAR_META:END%"
let printout_result (prefix:string) (res:export_result) :
Tac unit =
print (result_to_printout prefix res)
/// The function to use to export the results in case of success
let printout_success (ge:genv) (a:assertions) : Tac unit =
printout_result "ainfo" (ESuccess ge a)
/// The function to use to communicate failure in case of error
let printout_failure (err : string) : Tac unit =
printout_result "ainfo" (EFailure err)
let _debug_print_var (name : string) (t : term) : Tac unit =
print ("_debug_print_var: " ^ name ^ ": " ^ term_to_string t);
begin match safe_tc (top_env ()) t with
| Some ty -> print ("type: " ^ term_to_string ty)
| _ -> ()
end;
print ("qualifier: " ^ term_construct t);
begin match inspect t with
| Tv_Var bv ->
let b : bv_view = inspect_bv bv in
print ("Tv_Var: ppname: " ^ name_of_bv bv ^
"; index: " ^ (string_of_int b.bv_index))
| _ -> ()
end;
print "end of _debug_print_var"
/// We use the following to solve goals requiring a unification variable (for
/// which we might not have a candidate, or for which the candidate may not
/// typecheck correctly). We can't use the tactic ``tadmit`` for the simple
/// reason that it generates a warning which may mess up with the subsequent
/// parsing of the data generated by the tactics.
// TODO: actually, there already exists Prims.magic
assume val magic_witness (#a : Type) : a | false | false | FStar.InteractiveHelpers.Output.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tadmit_no_warning: Prims.unit -> Tac unit | [] | FStar.InteractiveHelpers.Output.tadmit_no_warning | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit | {
"end_col": 24,
"end_line": 181,
"start_col": 2,
"start_line": 181
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.