effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.GTot | val refl_ext_point (a: LSeq.lseq uint64 20) : GTot Spec.Ed25519.ext_point | [
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Field51",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let refl_ext_point (a:LSeq.lseq uint64 20) : GTot Spec.Ed25519.ext_point =
let open Hacl.Spec.Curve25519.Field51.Definition in
let x = feval (lseq_as_felem (LSeq.sub a 0 5)) in
let y = feval (lseq_as_felem (LSeq.sub a 5 5)) in
let z = feval (lseq_as_felem (LSeq.sub a 10 5)) in
let t = feval (lseq_as_felem (LSeq.sub a 15 5)) in
(x, y, z, t) | val refl_ext_point (a: LSeq.lseq uint64 20) : GTot Spec.Ed25519.ext_point
let refl_ext_point (a: LSeq.lseq uint64 20) : GTot Spec.Ed25519.ext_point = | false | null | false | let open Hacl.Spec.Curve25519.Field51.Definition in
let x = feval (lseq_as_felem (LSeq.sub a 0 5)) in
let y = feval (lseq_as_felem (LSeq.sub a 5 5)) in
let z = feval (lseq_as_felem (LSeq.sub a 10 5)) in
let t = feval (lseq_as_felem (LSeq.sub a 15 5)) in
(x, y, z, t) | {
"checked_file": "Hacl.Impl.Ed25519.Field51.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Ed25519.Field51.fst"
} | [
"sometrivial"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple4",
"Spec.Curve25519.elem",
"Hacl.Spec.Curve25519.Field51.Definition.feval",
"Hacl.Impl.Ed25519.Field51.lseq_as_felem",
"Lib.Sequence.sub",
"Spec.Ed25519.PointOps.ext_point"
] | [] | module Hacl.Impl.Ed25519.Field51
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
module LSeq = Lib.Sequence
module P = Hacl.Impl.Curve25519.Field51
module S = Spec.Curve25519
let felem = lbuffer uint64 5ul
let point = lbuffer uint64 20ul
let as_nat (h:mem) (f:felem) : GTot nat = P.as_nat h f
let fevalh (h:mem) (f:felem) : GTot S.elem = P.fevalh h f
noextract
val point_eval:h:mem -> p:point -> GTot Spec.Ed25519.ext_point
let point_eval h p =
let x = gsub p 0ul 5ul in
let y = gsub p 5ul 5ul in
let z = gsub p 10ul 5ul in
let t = gsub p 15ul 5ul in
(fevalh h x, fevalh h y, fevalh h z, fevalh h t)
noextract
val felem_fits: h:mem -> f:felem -> m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5 -> Type0
let felem_fits h f m = P.felem_fits h f m
noextract
let as_felem (h:mem) (f:felem) =
P.as_felem h f
noextract
let mul_inv_t (h:mem) (f:felem) : GTot Type0 =
P.mul_inv_t h f
noextract
let point_inv_t (h:mem) (p:point) : GTot Type0 =
mul_inv_t h (gsub p 0ul 5ul) /\
mul_inv_t h (gsub p 5ul 5ul) /\
mul_inv_t h (gsub p 10ul 5ul) /\
mul_inv_t h (gsub p 15ul 5ul)
unfold
let lseq_as_felem (a:LSeq.lseq uint64 5) : Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let open Lib.Sequence in
(a.[0], a.[1], a.[2], a.[3], a.[4])
unfold | false | false | Hacl.Impl.Ed25519.Field51.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val refl_ext_point (a: LSeq.lseq uint64 20) : GTot Spec.Ed25519.ext_point | [] | Hacl.Impl.Ed25519.Field51.refl_ext_point | {
"file_name": "code/ed25519/Hacl.Impl.Ed25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.Sequence.lseq Lib.IntTypes.uint64 20 -> Prims.GTot Spec.Ed25519.PointOps.ext_point | {
"end_col": 14,
"end_line": 62,
"start_col": 2,
"start_line": 57
} |
Prims.Tot | val linv (a: LSeq.lseq uint64 20) : Type0 | [
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Field51",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let linv (a:LSeq.lseq uint64 20) : Type0 =
let open Hacl.Spec.Curve25519.Field51 in
mul_inv_t (lseq_as_felem (LSeq.sub a 0 5)) /\
mul_inv_t (lseq_as_felem (LSeq.sub a 5 5)) /\
mul_inv_t (lseq_as_felem (LSeq.sub a 10 5)) /\
mul_inv_t (lseq_as_felem (LSeq.sub a 15 5)) /\
inv_ext_point a | val linv (a: LSeq.lseq uint64 20) : Type0
let linv (a: LSeq.lseq uint64 20) : Type0 = | false | null | false | let open Hacl.Spec.Curve25519.Field51 in
mul_inv_t (lseq_as_felem (LSeq.sub a 0 5)) /\ mul_inv_t (lseq_as_felem (LSeq.sub a 5 5)) /\
mul_inv_t (lseq_as_felem (LSeq.sub a 10 5)) /\ mul_inv_t (lseq_as_felem (LSeq.sub a 15 5)) /\
inv_ext_point a | {
"checked_file": "Hacl.Impl.Ed25519.Field51.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Ed25519.Field51.fst"
} | [
"total"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Prims.l_and",
"Hacl.Spec.Curve25519.Field51.mul_inv_t",
"Hacl.Impl.Ed25519.Field51.lseq_as_felem",
"Lib.Sequence.sub",
"Hacl.Impl.Ed25519.Field51.inv_ext_point"
] | [] | module Hacl.Impl.Ed25519.Field51
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
module LSeq = Lib.Sequence
module P = Hacl.Impl.Curve25519.Field51
module S = Spec.Curve25519
let felem = lbuffer uint64 5ul
let point = lbuffer uint64 20ul
let as_nat (h:mem) (f:felem) : GTot nat = P.as_nat h f
let fevalh (h:mem) (f:felem) : GTot S.elem = P.fevalh h f
noextract
val point_eval:h:mem -> p:point -> GTot Spec.Ed25519.ext_point
let point_eval h p =
let x = gsub p 0ul 5ul in
let y = gsub p 5ul 5ul in
let z = gsub p 10ul 5ul in
let t = gsub p 15ul 5ul in
(fevalh h x, fevalh h y, fevalh h z, fevalh h t)
noextract
val felem_fits: h:mem -> f:felem -> m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5 -> Type0
let felem_fits h f m = P.felem_fits h f m
noextract
let as_felem (h:mem) (f:felem) =
P.as_felem h f
noextract
let mul_inv_t (h:mem) (f:felem) : GTot Type0 =
P.mul_inv_t h f
noextract
let point_inv_t (h:mem) (p:point) : GTot Type0 =
mul_inv_t h (gsub p 0ul 5ul) /\
mul_inv_t h (gsub p 5ul 5ul) /\
mul_inv_t h (gsub p 10ul 5ul) /\
mul_inv_t h (gsub p 15ul 5ul)
unfold
let lseq_as_felem (a:LSeq.lseq uint64 5) : Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let open Lib.Sequence in
(a.[0], a.[1], a.[2], a.[3], a.[4])
unfold
let refl_ext_point (a:LSeq.lseq uint64 20) : GTot Spec.Ed25519.ext_point =
let open Hacl.Spec.Curve25519.Field51.Definition in
let x = feval (lseq_as_felem (LSeq.sub a 0 5)) in
let y = feval (lseq_as_felem (LSeq.sub a 5 5)) in
let z = feval (lseq_as_felem (LSeq.sub a 10 5)) in
let t = feval (lseq_as_felem (LSeq.sub a 15 5)) in
(x, y, z, t)
unfold
let inv_ext_point (a:LSeq.lseq uint64 20) : Type0 =
Spec.Ed25519.point_inv (refl_ext_point a)
unfold | false | false | Hacl.Impl.Ed25519.Field51.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val linv (a: LSeq.lseq uint64 20) : Type0 | [] | Hacl.Impl.Ed25519.Field51.linv | {
"file_name": "code/ed25519/Hacl.Impl.Ed25519.Field51.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.Sequence.lseq Lib.IntTypes.uint64 20 -> Type0 | {
"end_col": 17,
"end_line": 75,
"start_col": 2,
"start_line": 70
} |
Prims.Tot | val map_contains_prop (#k: eqtype) (#v: Type0) (x: k) (m: Map.t k v) : prop | [
{
"abbrev": true,
"full_module": "FStar.Seq.Permutation",
"short_module": "SeqPerm"
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": true,
"full_module": "Steel.ST.Array",
"short_module": "A"
},
{
"abbrev": true,
"full_module": "Steel.ST.Reference",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "FStar.PartialMap",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "FStar.PartialMap",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map_contains_prop (#k:eqtype) (#v:Type0) (x:k) (m:Map.t k v) : prop =
Map.contains m x == true | val map_contains_prop (#k: eqtype) (#v: Type0) (x: k) (m: Map.t k v) : prop
let map_contains_prop (#k: eqtype) (#v: Type0) (x: k) (m: Map.t k v) : prop = | false | null | false | Map.contains m x == true | {
"checked_file": "Steel.ST.EphemeralHashtbl.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Effect.Ghost.fsti.checked",
"Steel.ST.Effect.Atomic.fsti.checked",
"Steel.ST.Effect.fsti.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PartialMap.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.EphemeralHashtbl.fsti"
} | [
"total"
] | [
"Prims.eqtype",
"FStar.PartialMap.t",
"Prims.eq2",
"Prims.bool",
"FStar.PartialMap.contains",
"Prims.prop"
] | [] | (*
Copyright 2021 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.
Authors: Aseem Rastogi
*)
module Steel.ST.EphemeralHashtbl
open Steel.Memory
open Steel.ST.Effect.Ghost
open Steel.ST.Effect.Atomic
open Steel.ST.Effect
open Steel.ST.Util
module G = FStar.Ghost
module Map = FStar.PartialMap
module US = FStar.SizeT
/// This module provides a basic hashtable with no support for hash-collisions
///
/// In particular, if the table already contains a key k1 and the client calls `put`
/// with another key k2 that has a hash-collision with k1, then k1 is evicted from the table
///
/// The table is designed to support reference-like types as values,
/// in addition to the usual `key` and `value` type, the table is also indexed with a `contents` type
/// and a separation logic proposition (`vprop`) that relates a key, value,
/// and the content that the value may point to
///
/// The content of the value is erased, the table does not store any concrete contents
///
/// During `put` the client provides this `vprop` relating the key, value, and
/// the (erased) contents, and on `get`, the client gets it back
///
/// To account for these permissions, the table also maintains a ghost
/// map that maintains keys that have been read (or borrowed)
///
/// The module provides a logical view of the hashtable as a map from keys to contents,
/// thereby collapsing the indirection of key -> value -> content
///
/// The logical map provides a hash-collision-free view of the table,
/// in the example above, the map would contain both k1 and k2, with the mapping for k1 unchanged by the `put` operation on k2 (unless k1 == k2)
///
/// So in that sense, the concrete state maintains a partial view of the logical map
type us = US.t
/// Type of the hash functions
type hash_fn (k:eqtype) = k -> us
/// Type of the vprops that related the key, value, and contents type
type vp_t (k:eqtype) (v contents:Type0) = k -> v -> contents -> vprop
/// The main hashtable table, indexed with a hash function and a vprop
val tbl
(#k:eqtype)
(#v:Type0)
(#contents:Type)
(vp:vp_t k v contents)
(h:hash_fn k)
: Type0
/// The logical representation of the hashtable is a map from keys to contents,
/// thereby collapsing the value-indirection
type repr (k:eqtype) (contents:Type) = Map.t k contents
/// The hashtable separation logic permission
///
/// `tperm t m borrows` represents permission to a hashtable
/// whose concrete store is a partial view of `m`, and
/// all its entries that are present in `borrows` are currently borrowed
val tperm
(#k:eqtype)
(#v:Type0)
(#contents:Type)
(#vp:vp_t k v contents)
(#h:hash_fn k)
(t:tbl vp h)
(m:repr k contents)
(borrows:Map.t k v)
: vprop
/// The create function
///
/// Returns the `tperm` with repr and borrows maps initialized to empty
inline_for_extraction
val create
(#k:eqtype)
(#v:Type0)
(#contents:Type)
(vp:vp_t k v contents)
(h:hash_fn k)
(n:us{US.v n > 0})
: STT (tbl vp h)
emp
(fun a -> tperm a (Map.empty k contents) (Map.empty k v))
/// A second create function that takes an erased contents value
/// and initializes the repr map to contain the erased value
/// for all the keys
///
/// Internally, the permission `tperm` relates seq entries to
/// the map, and does not specify any relation the other way round,
/// so it is possible to provide a const map initially
inline_for_extraction
val create_v
(#k:eqtype)
(#v:Type0)
(#contents:Type)
(vp:vp_t k v contents)
(h:hash_fn k)
(n:us{US.v n > 0})
(c:G.erased contents)
: STT (tbl vp h)
emp
(fun a -> tperm a (Map.const k (G.reveal c)) (Map.empty k v))
/// Return type for `get`
/// - Present v: the key is present in the table, and is mapped to the value v
/// - Absent: the key is not in the table, and its "slot" does not contain any other key either
/// - Missing k': the key is not in the table, and its "slot" contains another key k'
type get_result (k:eqtype) (v:Type0) =
| Present : v -> get_result k v
| Absent
| Missing : k -> get_result k v | false | false | Steel.ST.EphemeralHashtbl.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 map_contains_prop (#k: eqtype) (#v: Type0) (x: k) (m: Map.t k v) : prop | [] | Steel.ST.EphemeralHashtbl.map_contains_prop | {
"file_name": "lib/steel/Steel.ST.EphemeralHashtbl.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: k -> m: FStar.PartialMap.t k v -> Prims.prop | {
"end_col": 26,
"end_line": 148,
"start_col": 2,
"start_line": 148
} |
Prims.Tot | val get_post:
#k: eqtype ->
#v: Type0 ->
#contents: Type ->
#vp: vp_t k v contents ->
#h: hash_fn k ->
m: G.erased (repr k contents) ->
borrows: G.erased (Map.t k v) ->
a: tbl vp h ->
i: k ->
get_result k v
-> vprop | [
{
"abbrev": true,
"full_module": "FStar.Seq.Permutation",
"short_module": "SeqPerm"
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": true,
"full_module": "Steel.ST.Array",
"short_module": "A"
},
{
"abbrev": true,
"full_module": "Steel.ST.Reference",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "FStar.PartialMap",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "FStar.PartialMap",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_post
(#k:eqtype)
(#v:Type0)
(#contents:Type)
(#vp:vp_t k v contents)
(#h:hash_fn k)
(m:G.erased (repr k contents))
(borrows:G.erased (Map.t k v))
(a:tbl vp h)
(i:k)
: get_result k v -> vprop
= fun r ->
match r, Map.sel m i with
| Present x, Some c ->
tperm a m (Map.upd borrows i x) //when `get` succeeds, the key is added to `borrows`
`star`
vp i x c //in addition, we return the vp permission for the key
| Present x, None -> pure False //It can never be the case that the key is present in the table,
//but is not mapped in the representation map
| Missing j, _ ->
tperm a m borrows
`star`
pure (map_contains_prop j m)
| _ -> tperm a m borrows | val get_post:
#k: eqtype ->
#v: Type0 ->
#contents: Type ->
#vp: vp_t k v contents ->
#h: hash_fn k ->
m: G.erased (repr k contents) ->
borrows: G.erased (Map.t k v) ->
a: tbl vp h ->
i: k ->
get_result k v
-> vprop
let get_post
(#k: eqtype)
(#v: Type0)
(#contents: Type)
(#vp: vp_t k v contents)
(#h: hash_fn k)
(m: G.erased (repr k contents))
(borrows: G.erased (Map.t k v))
(a: tbl vp h)
(i: k)
: get_result k v -> vprop = | false | null | false | fun r ->
match r, Map.sel m i with
| Present x, Some c -> (tperm a m (Map.upd borrows i x)) `star` (vp i x c)
| Present x, None -> pure False
| Missing j, _ -> (tperm a m borrows) `star` (pure (map_contains_prop j m))
| _ -> tperm a m borrows | {
"checked_file": "Steel.ST.EphemeralHashtbl.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Effect.Ghost.fsti.checked",
"Steel.ST.Effect.Atomic.fsti.checked",
"Steel.ST.Effect.fsti.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PartialMap.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.EphemeralHashtbl.fsti"
} | [
"total"
] | [
"Prims.eqtype",
"Steel.ST.EphemeralHashtbl.vp_t",
"Steel.ST.EphemeralHashtbl.hash_fn",
"FStar.Ghost.erased",
"Steel.ST.EphemeralHashtbl.repr",
"FStar.PartialMap.t",
"Steel.ST.EphemeralHashtbl.tbl",
"Steel.ST.EphemeralHashtbl.get_result",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.option",
"FStar.PartialMap.sel",
"FStar.Ghost.reveal",
"Steel.Effect.Common.star",
"Steel.ST.EphemeralHashtbl.tperm",
"FStar.PartialMap.upd",
"Steel.ST.Util.pure",
"Prims.l_False",
"Steel.ST.EphemeralHashtbl.map_contains_prop",
"FStar.Pervasives.Native.tuple2",
"Steel.Effect.Common.vprop"
] | [] | (*
Copyright 2021 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.
Authors: Aseem Rastogi
*)
module Steel.ST.EphemeralHashtbl
open Steel.Memory
open Steel.ST.Effect.Ghost
open Steel.ST.Effect.Atomic
open Steel.ST.Effect
open Steel.ST.Util
module G = FStar.Ghost
module Map = FStar.PartialMap
module US = FStar.SizeT
/// This module provides a basic hashtable with no support for hash-collisions
///
/// In particular, if the table already contains a key k1 and the client calls `put`
/// with another key k2 that has a hash-collision with k1, then k1 is evicted from the table
///
/// The table is designed to support reference-like types as values,
/// in addition to the usual `key` and `value` type, the table is also indexed with a `contents` type
/// and a separation logic proposition (`vprop`) that relates a key, value,
/// and the content that the value may point to
///
/// The content of the value is erased, the table does not store any concrete contents
///
/// During `put` the client provides this `vprop` relating the key, value, and
/// the (erased) contents, and on `get`, the client gets it back
///
/// To account for these permissions, the table also maintains a ghost
/// map that maintains keys that have been read (or borrowed)
///
/// The module provides a logical view of the hashtable as a map from keys to contents,
/// thereby collapsing the indirection of key -> value -> content
///
/// The logical map provides a hash-collision-free view of the table,
/// in the example above, the map would contain both k1 and k2, with the mapping for k1 unchanged by the `put` operation on k2 (unless k1 == k2)
///
/// So in that sense, the concrete state maintains a partial view of the logical map
type us = US.t
/// Type of the hash functions
type hash_fn (k:eqtype) = k -> us
/// Type of the vprops that related the key, value, and contents type
type vp_t (k:eqtype) (v contents:Type0) = k -> v -> contents -> vprop
/// The main hashtable table, indexed with a hash function and a vprop
val tbl
(#k:eqtype)
(#v:Type0)
(#contents:Type)
(vp:vp_t k v contents)
(h:hash_fn k)
: Type0
/// The logical representation of the hashtable is a map from keys to contents,
/// thereby collapsing the value-indirection
type repr (k:eqtype) (contents:Type) = Map.t k contents
/// The hashtable separation logic permission
///
/// `tperm t m borrows` represents permission to a hashtable
/// whose concrete store is a partial view of `m`, and
/// all its entries that are present in `borrows` are currently borrowed
val tperm
(#k:eqtype)
(#v:Type0)
(#contents:Type)
(#vp:vp_t k v contents)
(#h:hash_fn k)
(t:tbl vp h)
(m:repr k contents)
(borrows:Map.t k v)
: vprop
/// The create function
///
/// Returns the `tperm` with repr and borrows maps initialized to empty
inline_for_extraction
val create
(#k:eqtype)
(#v:Type0)
(#contents:Type)
(vp:vp_t k v contents)
(h:hash_fn k)
(n:us{US.v n > 0})
: STT (tbl vp h)
emp
(fun a -> tperm a (Map.empty k contents) (Map.empty k v))
/// A second create function that takes an erased contents value
/// and initializes the repr map to contain the erased value
/// for all the keys
///
/// Internally, the permission `tperm` relates seq entries to
/// the map, and does not specify any relation the other way round,
/// so it is possible to provide a const map initially
inline_for_extraction
val create_v
(#k:eqtype)
(#v:Type0)
(#contents:Type)
(vp:vp_t k v contents)
(h:hash_fn k)
(n:us{US.v n > 0})
(c:G.erased contents)
: STT (tbl vp h)
emp
(fun a -> tperm a (Map.const k (G.reveal c)) (Map.empty k v))
/// Return type for `get`
/// - Present v: the key is present in the table, and is mapped to the value v
/// - Absent: the key is not in the table, and its "slot" does not contain any other key either
/// - Missing k': the key is not in the table, and its "slot" contains another key k'
type get_result (k:eqtype) (v:Type0) =
| Present : v -> get_result k v
| Absent
| Missing : k -> get_result k v
unfold let map_contains_prop (#k:eqtype) (#v:Type0) (x:k) (m:Map.t k v) : prop =
Map.contains m x == true
/// post vprop for `get`
let get_post
(#k:eqtype)
(#v:Type0)
(#contents:Type)
(#vp:vp_t k v contents)
(#h:hash_fn k)
(m:G.erased (repr k contents))
(borrows:G.erased (Map.t k v))
(a:tbl vp h)
(i:k) | false | false | Steel.ST.EphemeralHashtbl.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 get_post:
#k: eqtype ->
#v: Type0 ->
#contents: Type ->
#vp: vp_t k v contents ->
#h: hash_fn k ->
m: G.erased (repr k contents) ->
borrows: G.erased (Map.t k v) ->
a: tbl vp h ->
i: k ->
get_result k v
-> vprop | [] | Steel.ST.EphemeralHashtbl.get_post | {
"file_name": "lib/steel/Steel.ST.EphemeralHashtbl.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
m: FStar.Ghost.erased (Steel.ST.EphemeralHashtbl.repr k contents) ->
borrows: FStar.Ghost.erased (FStar.PartialMap.t k v) ->
a: Steel.ST.EphemeralHashtbl.tbl vp h ->
i: k ->
_: Steel.ST.EphemeralHashtbl.get_result k v
-> Steel.Effect.Common.vprop | {
"end_col": 28,
"end_line": 177,
"start_col": 4,
"start_line": 163
} |
Prims.Tot | val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs | val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = | false | null | false | transpose4x4_0 #t vs | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Prims.eq2",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U64",
"Lib.IntVector.Transpose.vec_t4",
"Lib.IntVector.Transpose.transpose4x4_0"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction | false | false | Lib.IntVector.Transpose.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 transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t | [] | Lib.IntVector.Transpose.transpose4x4_uint64 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | vs: Lib.IntVector.Transpose.vec_t4 t -> Lib.IntVector.Transpose.vec_t4 t | {
"end_col": 52,
"end_line": 36,
"start_col": 32,
"start_line": 36
} |
Prims.Tot | val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs | val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_lseq #w #t n vs = | false | null | false | Loops.repeati n (transposewxw_f #w n) vs | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.width",
"Lib.IntVector.v_inttype",
"Prims.nat",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Prims.pow2",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.LoopCombinators.repeati",
"Lib.IntVector.Transpose.transposewxw_f"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w | false | false | Lib.IntVector.Transpose.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 transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w | [] | Lib.IntVector.Transpose.transposewxw_lseq | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Prims.nat{Prims.pow2 n == w} -> vs: Lib.Sequence.lseq (Lib.IntVector.vec_t t w) w
-> Lib.Sequence.lseq (Lib.IntVector.vec_t t w) w | {
"end_col": 42,
"end_line": 168,
"start_col": 2,
"start_line": 168
} |
Prims.Tot | val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs) | val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs = | false | null | false | createi w (transposewxw_f_l #w n i vs) | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.width",
"Lib.IntVector.v_inttype",
"Prims.nat",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Prims.pow2",
"Prims.op_LessThan",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.Sequence.createi",
"Lib.IntVector.Transpose.transposewxw_f_l"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w | false | false | Lib.IntVector.Transpose.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 transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w | [] | Lib.IntVector.Transpose.transposewxw_f | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n: Prims.nat{Prims.pow2 n == w} ->
i: Prims.nat{i < n} ->
vs: Lib.Sequence.lseq (Lib.IntVector.vec_t t w) w
-> Lib.Sequence.lseq (Lib.IntVector.vec_t t w) w | {
"end_col": 40,
"end_line": 164,
"start_col": 2,
"start_line": 164
} |
Prims.Tot | val transpose8x8: #t:v_inttype{t = U32} -> vec_t8 t -> vec_t8 t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs | val transpose8x8: #t:v_inttype{t = U32} -> vec_t8 t -> vec_t8 t
let transpose8x8 #t vs = | false | null | false | match t with | U32 -> transpose8x8_uint32 #t vs | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U32",
"Lib.IntVector.Transpose.vec_t8",
"Lib.IntVector.Transpose.transpose8x8_uint32"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7') | false | false | Lib.IntVector.Transpose.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 transpose8x8: #t:v_inttype{t = U32} -> vec_t8 t -> vec_t8 t | [] | Lib.IntVector.Transpose.transpose8x8 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | vs: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t | {
"end_col": 36,
"end_line": 109,
"start_col": 2,
"start_line": 108
} |
Prims.Tot | val transpose4x4: #t:v_inttype{t = U32 \/ t = U64} -> vec_t4 t -> vec_t4 t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs | val transpose4x4: #t:v_inttype{t = U32 \/ t = U64} -> vec_t4 t -> vec_t4 t
let transpose4x4 #t vs = | false | null | false | match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntVector.Transpose.vec_t4",
"Lib.IntVector.Transpose.transpose4x4_uint32",
"Lib.IntVector.Transpose.transpose4x4_uint64"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs | false | false | Lib.IntVector.Transpose.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 transpose4x4: #t:v_inttype{t = U32 \/ t = U64} -> vec_t4 t -> vec_t4 t | [] | Lib.IntVector.Transpose.transpose4x4 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | vs: Lib.IntVector.Transpose.vec_t4 t -> Lib.IntVector.Transpose.vec_t4 t | {
"end_col": 36,
"end_line": 42,
"start_col": 2,
"start_line": 40
} |
Prims.Tot | val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7') | val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0, v1, v2, v3, v4, v5, v6, v7) = | false | null | false | let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0', v1', v2', v3', v4', v5', v6', v7') | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.Transpose.vec_t8",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple8",
"Lib.IntVector.vec_interleave_high_n",
"Lib.IntVector.vec_interleave_low_n"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction | false | false | Lib.IntVector.Transpose.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 transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t | [] | Lib.IntVector.Transpose.transpose8x8_1 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t | {
"end_col": 35,
"end_line": 73,
"start_col": 49,
"start_line": 64
} |
Prims.Tot | val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'') | val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0, v1, v2, v3) = | false | null | false | let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'', v2'', v1'', v3'') | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.Transpose.vec_t4",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple4",
"Lib.IntVector.vec_interleave_high_n",
"Lib.IntVector.vec_interleave_low_n",
"Lib.IntVector.vec_interleave_high",
"Lib.IntVector.vec_interleave_low"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction | false | false | Lib.IntVector.Transpose.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 transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t | [] | Lib.IntVector.Transpose.transpose4x4_0 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntVector.Transpose.vec_t4 t -> Lib.IntVector.Transpose.vec_t4 t | {
"end_col": 23,
"end_line": 24,
"start_col": 37,
"start_line": 14
} |
Prims.Tot | val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'') | val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs = | false | null | false | let v0'', v2'', v1'', v3'' = transpose4x4_0 #t vs in
(v0'', v1'', v2'', v3'') | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Prims.eq2",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U32",
"Lib.IntVector.Transpose.vec_t4",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple4",
"Lib.IntVector.Transpose.transpose4x4_0"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction | false | false | Lib.IntVector.Transpose.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 transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t | [] | Lib.IntVector.Transpose.transpose4x4_uint32 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | vs: Lib.IntVector.Transpose.vec_t4 t -> Lib.IntVector.Transpose.vec_t4 t | {
"end_col": 23,
"end_line": 31,
"start_col": 31,
"start_line": 29
} |
Prims.Tot | val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7') | val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 = | false | null | false | let v0', v1', v2', v3', v4', v5', v6', v7' = transpose8x8_012 #t vs0 in
(v0', v2', v1', v3', v4', v6', v5', v7') | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Prims.eq2",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U32",
"Lib.IntVector.Transpose.vec_t8",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple8",
"Lib.IntVector.Transpose.transpose8x8_012"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction | false | false | Lib.IntVector.Transpose.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 transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t | [] | Lib.IntVector.Transpose.transpose8x8_uint32 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | vs0: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t | {
"end_col": 35,
"end_line": 104,
"start_col": 32,
"start_line": 102
} |
Prims.Tot | val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7') | val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0, v1, v2, v3, v4, v5, v6, v7) = | false | null | false | let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0', v1', v2', v3', v4', v5', v6', v7') | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.Transpose.vec_t8",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple8",
"Lib.IntVector.vec_interleave_high_n",
"Lib.IntVector.vec_interleave_low_n"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction | false | false | Lib.IntVector.Transpose.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 transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t | [] | Lib.IntVector.Transpose.transpose8x8_2 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t | {
"end_col": 35,
"end_line": 87,
"start_col": 49,
"start_line": 78
} |
Prims.Tot | val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7') | val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0, v1, v2, v3, v4, v5, v6, v7) = | false | null | false | let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0', v1', v2', v3', v4', v5', v6', v7') | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.Transpose.vec_t8",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple8",
"Lib.IntVector.vec_interleave_high",
"Lib.IntVector.vec_interleave_low"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction | false | false | Lib.IntVector.Transpose.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 transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t | [] | Lib.IntVector.Transpose.transpose8x8_0 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t | {
"end_col": 35,
"end_line": 59,
"start_col": 49,
"start_line": 50
} |
Prims.Tot | val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7') | val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 = | false | null | false | let v0, v1, v2, v3, v4, v5, v6, v7 = vs0 in
let v0', v1', v2', v3', v4', v5', v6', v7' = transpose8x8_0 #t (v0, v1, v2, v3, v4, v5, v6, v7) in
let v0', v1', v2', v3', v4', v5', v6', v7' =
transpose8x8_1 #t (v0', v1', v2', v3', v4', v5', v6', v7')
in
let v0', v1', v2', v3', v4', v5', v6', v7' =
transpose8x8_2 #t (v0', v1', v2', v3', v4', v5', v6', v7')
in
(v0', v1', v2', v3', v4', v5', v6', v7') | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.Transpose.vec_t8",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple8",
"Lib.IntVector.Transpose.transpose8x8_2",
"Lib.IntVector.Transpose.transpose8x8_1",
"Lib.IntVector.Transpose.transpose8x8_0"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction | false | false | Lib.IntVector.Transpose.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 transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t | [] | Lib.IntVector.Transpose.transpose8x8_012 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | vs0: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t | {
"end_col": 35,
"end_line": 97,
"start_col": 29,
"start_line": 92
} |
Prims.Tot | val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l] | val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l = | false | null | false | Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then
(lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[ l ] vs.[ l + pow2 i ])
else vec_interleave_high_n (pow2 i) vs.[ l - pow2 i ] vs.[ l ] | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.width",
"Lib.IntVector.v_inttype",
"Prims.nat",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Prims.pow2",
"Prims.op_LessThan",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Lib.IntVector.vec_interleave_low_n",
"Lib.Sequence.op_String_Access",
"Prims.op_Addition",
"Prims.unit",
"Lib.IntVector.Transpose.lemma_l_plus_pow2i_lt",
"Prims.bool",
"Lib.IntVector.vec_interleave_high_n",
"Prims.op_Subtraction",
"FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_1"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w | false | false | Lib.IntVector.Transpose.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 transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w | [] | Lib.IntVector.Transpose.transposewxw_f_l | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n: Prims.nat{Prims.pow2 n == w} ->
i: Prims.nat{i < n} ->
vs: Lib.Sequence.lseq (Lib.IntVector.vec_t t w) w ->
l: Prims.nat{l < w}
-> Lib.IntVector.vec_t t w | {
"end_col": 57,
"end_line": 158,
"start_col": 2,
"start_line": 152
} |
Prims.Tot | val f_lseq4 (#t: v_inttype) (vs: lseq (vec_t t 4) 4) (f: (vec_t4 t -> vec_t4 t))
: lseq (vec_t t 4) 4 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let f_lseq4 (#t:v_inttype) (vs:lseq (vec_t t 4) 4) (f:vec_t4 t -> vec_t4 t) : lseq (vec_t t 4) 4 =
let (v0,v1,v2,v3) = (vs.[0],vs.[1],vs.[2],vs.[3]) in
let (r0,r1,r2,r3) = f (v0,v1,v2,v3) in
create4 r0 r1 r2 r3 | val f_lseq4 (#t: v_inttype) (vs: lseq (vec_t t 4) 4) (f: (vec_t4 t -> vec_t4 t))
: lseq (vec_t t 4) 4
let f_lseq4 (#t: v_inttype) (vs: lseq (vec_t t 4) 4) (f: (vec_t4 t -> vec_t4 t))
: lseq (vec_t t 4) 4 = | false | null | false | let v0, v1, v2, v3 = (vs.[ 0 ], vs.[ 1 ], vs.[ 2 ], vs.[ 3 ]) in
let r0, r1, r2, r3 = f (v0, v1, v2, v3) in
create4 r0 r1 r2 r3 | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.IntVector.Transpose.vec_t4",
"Lib.Sequence.create4",
"FStar.Pervasives.Native.Mktuple4",
"FStar.Pervasives.Native.tuple4",
"Lib.Sequence.op_String_Access"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs
///
/// transposewxw_lseq lemmas
/// | false | false | Lib.IntVector.Transpose.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 f_lseq4 (#t: v_inttype) (vs: lseq (vec_t t 4) 4) (f: (vec_t4 t -> vec_t4 t))
: lseq (vec_t t 4) 4 | [] | Lib.IntVector.Transpose.f_lseq4 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
vs: Lib.Sequence.lseq (Lib.IntVector.vec_t t 4) 4 ->
f: (_: Lib.IntVector.Transpose.vec_t4 t -> Lib.IntVector.Transpose.vec_t4 t)
-> Lib.Sequence.lseq (Lib.IntVector.vec_t t 4) 4 | {
"end_col": 21,
"end_line": 178,
"start_col": 98,
"start_line": 175
} |
FStar.Pervasives.Lemma | val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_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_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
} | val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l = | false | null | true | let pow2i1 = pow2 (i + 1) in
calc ( < ) {
l + pow2 i;
( == ) { Math.Lemmas.euclidean_division_definition l pow2i1 }
(l / pow2i1) * pow2i1 + l % pow2i1 + pow2 i;
( == ) { Math.Lemmas.pow2_plus 1 i }
(l / pow2i1) * pow2i1 + l % (2 * pow2 i) + pow2 i;
( < ) { assert (l % (2 * pow2 i) < pow2 i) }
(l / pow2i1) * pow2i1 + pow2 i + pow2 i;
( == ) { Math.Lemmas.pow2_double_sum i }
(l / pow2i1) * pow2i1 + pow2i1;
( == ) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
( <= ) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
( == ) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
} | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"lemma"
] | [
"Prims.pos",
"Prims.nat",
"Prims.eq2",
"Prims.pow2",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.op_Addition",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.op_LessThanOrEqual",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"Prims.op_Division",
"Prims.op_Modulus",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.euclidean_division_definition",
"Prims.squash",
"FStar.Math.Lemmas.pow2_plus",
"Prims._assert",
"FStar.Math.Lemmas.pow2_double_sum",
"FStar.Math.Lemmas.distributivity_add_left",
"FStar.Math.Lemmas.lemma_div_lt_nat"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w) | false | false | Lib.IntVector.Transpose.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 lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w) | [] | Lib.IntVector.Transpose.lemma_l_plus_pow2i_lt | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Prims.nat{Prims.pow2 n == w} -> i: Prims.nat{i < n} -> l: Prims.nat{l < w}
-> FStar.Pervasives.Lemma (requires l % (2 * Prims.pow2 i) < Prims.pow2 i)
(ensures l + Prims.pow2 i < w) | {
"end_col": 3,
"end_line": 138,
"start_col": 36,
"start_line": 119
} |
Prims.Tot | val f_lseq8 (#t: v_inttype) (vs: lseq (vec_t t 8) 8) (f: (vec_t8 t -> vec_t8 t))
: lseq (vec_t t 8) 8 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let f_lseq8 (#t:v_inttype) (vs:lseq (vec_t t 8) 8) (f:vec_t8 t -> vec_t8 t) : lseq (vec_t t 8) 8 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = (vs.[0],vs.[1],vs.[2],vs.[3],vs.[4],vs.[5],vs.[6],vs.[7]) in
let (r0,r1,r2,r3,r4,r5,r6,r7) = f (v0,v1,v2,v3,v4,v5,v6,v7) in
create8 r0 r1 r2 r3 r4 r5 r6 r7 | val f_lseq8 (#t: v_inttype) (vs: lseq (vec_t t 8) 8) (f: (vec_t8 t -> vec_t8 t))
: lseq (vec_t t 8) 8
let f_lseq8 (#t: v_inttype) (vs: lseq (vec_t t 8) 8) (f: (vec_t8 t -> vec_t8 t))
: lseq (vec_t t 8) 8 = | false | null | false | let v0, v1, v2, v3, v4, v5, v6, v7 =
(vs.[ 0 ], vs.[ 1 ], vs.[ 2 ], vs.[ 3 ], vs.[ 4 ], vs.[ 5 ], vs.[ 6 ], vs.[ 7 ])
in
let r0, r1, r2, r3, r4, r5, r6, r7 = f (v0, v1, v2, v3, v4, v5, v6, v7) in
create8 r0 r1 r2 r3 r4 r5 r6 r7 | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.IntVector.Transpose.vec_t8",
"Lib.Sequence.create8",
"FStar.Pervasives.Native.Mktuple8",
"FStar.Pervasives.Native.tuple8",
"Lib.Sequence.op_String_Access"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs
///
/// transposewxw_lseq lemmas
///
inline_for_extraction
let f_lseq4 (#t:v_inttype) (vs:lseq (vec_t t 4) 4) (f:vec_t4 t -> vec_t4 t) : lseq (vec_t t 4) 4 =
let (v0,v1,v2,v3) = (vs.[0],vs.[1],vs.[2],vs.[3]) in
let (r0,r1,r2,r3) = f (v0,v1,v2,v3) in
create4 r0 r1 r2 r3
val transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0)
let transpose4x4_lseq_is_transposewxw #t vs0 =
let n = 2 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
eq_intro (transposewxw_lseq 2 vs0) (f_lseq4 vs0 transpose4x4_0) | false | false | Lib.IntVector.Transpose.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 f_lseq8 (#t: v_inttype) (vs: lseq (vec_t t 8) 8) (f: (vec_t8 t -> vec_t8 t))
: lseq (vec_t t 8) 8 | [] | Lib.IntVector.Transpose.f_lseq8 | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
vs: Lib.Sequence.lseq (Lib.IntVector.vec_t t 8) 8 ->
f: (_: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t)
-> Lib.Sequence.lseq (Lib.IntVector.vec_t t 8) 8 | {
"end_col": 33,
"end_line": 195,
"start_col": 98,
"start_line": 192
} |
FStar.Pervasives.Lemma | val transpose8x8_lemma: #t:v_inttype{t = U32} -> vs:lseq (vec_t t 8) 8 ->
Lemma (forall (i:nat{i < 8}) (j:nat{j < 8}). (vec_v (transpose8x8_lseq vs).[i]).[j] == (vec_v vs.[j]).[i]) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose8x8_lemma #t vs =
match t with
| U32 -> Classical.forall_intro_2 (transpose8x8_lemma_uint32_ij vs) | val transpose8x8_lemma: #t:v_inttype{t = U32} -> vs:lseq (vec_t t 8) 8 ->
Lemma (forall (i:nat{i < 8}) (j:nat{j < 8}). (vec_v (transpose8x8_lseq vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose8x8_lemma #t vs = | false | null | true | match t with | U32 -> Classical.forall_intro_2 (transpose8x8_lemma_uint32_ij vs) | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"lemma"
] | [
"Lib.IntVector.v_inttype",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U32",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"FStar.Classical.forall_intro_2",
"Prims.nat",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.IntVector.vec_v",
"Lib.Sequence.op_String_Access",
"Lib.IntVector.Transpose.transpose8x8_lseq",
"Lib.IntVector.Transpose.transpose8x8_lemma_uint32_ij",
"Prims.unit"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs
///
/// transposewxw_lseq lemmas
///
inline_for_extraction
let f_lseq4 (#t:v_inttype) (vs:lseq (vec_t t 4) 4) (f:vec_t4 t -> vec_t4 t) : lseq (vec_t t 4) 4 =
let (v0,v1,v2,v3) = (vs.[0],vs.[1],vs.[2],vs.[3]) in
let (r0,r1,r2,r3) = f (v0,v1,v2,v3) in
create4 r0 r1 r2 r3
val transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0)
let transpose4x4_lseq_is_transposewxw #t vs0 =
let n = 2 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
eq_intro (transposewxw_lseq 2 vs0) (f_lseq4 vs0 transpose4x4_0)
inline_for_extraction
let f_lseq8 (#t:v_inttype) (vs:lseq (vec_t t 8) 8) (f:vec_t8 t -> vec_t8 t) : lseq (vec_t t 8) 8 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = (vs.[0],vs.[1],vs.[2],vs.[3],vs.[4],vs.[5],vs.[6],vs.[7]) in
let (r0,r1,r2,r3,r4,r5,r6,r7) = f (v0,v1,v2,v3,v4,v5,v6,v7) in
create8 r0 r1 r2 r3 r4 r5 r6 r7
val transpose8x8_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 8) 8 ->
Lemma (transposewxw_lseq 3 vs `Seq.equal` f_lseq8 vs transpose8x8_012)
let transpose8x8_lseq_is_transposewxw #t vs0 =
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
eq_intro res0 (f_lseq8 vs0 transpose8x8_0);
let res1 = transposewxw_f n 1 res0 in
eq_intro res1 (f_lseq8 res0 transpose8x8_1);
let res2 = transposewxw_f n 2 res1 in
eq_intro res2 (f_lseq8 res1 transpose8x8_2);
eq_intro (transposewxw_lseq 3 vs0) (f_lseq8 vs0 transpose8x8_012)
val transpose4x4_lemma_uint32_ij: vs:lseq (vec_t U32 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma_uint32_ij vs0 i j =
transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_low_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint32_4 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint32_4 vs0.[2] vs0.[3]
val transpose4x4_lemma_uint64_ij: vs:lseq (vec_t U64 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U64 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma_uint64_ij vs0 i j =
transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint64_4_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint64_4_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint64_4_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint64_4_2 res0.[1] res0.[3];
vec_interleave_low_lemma_uint64_4 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint64_4 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint64_4 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint64_4 vs0.[2] vs0.[3]
val transpose8x8_lemma_uint32_ij: vs:lseq (vec_t U32 8) 8 -> i:nat{i < 8} -> j:nat{j < 8} ->
Lemma ((vec_v (transpose8x8_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose8x8_lemma_uint32_ij vs0 i j =
transpose8x8_lseq_is_transposewxw vs0;
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
let res1 = transposewxw_f n 1 res0 in
let res2 = transposewxw_f n 2 res1 in
vec_interleave_low_n_lemma_uint32_8_4 res1.[0] res1.[4];
vec_interleave_low_n_lemma_uint32_8_4 res1.[1] res1.[5];
vec_interleave_low_n_lemma_uint32_8_4 res1.[2] res1.[6];
vec_interleave_low_n_lemma_uint32_8_4 res1.[3] res1.[7];
vec_interleave_high_n_lemma_uint32_8_4 res1.[0] res1.[4];
vec_interleave_high_n_lemma_uint32_8_4 res1.[1] res1.[5];
vec_interleave_high_n_lemma_uint32_8_4 res1.[2] res1.[6];
vec_interleave_high_n_lemma_uint32_8_4 res1.[3] res1.[7];
vec_interleave_low_n_lemma_uint32_8_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint32_8_2 res0.[1] res0.[3];
vec_interleave_low_n_lemma_uint32_8_2 res0.[4] res0.[6];
vec_interleave_low_n_lemma_uint32_8_2 res0.[5] res0.[7];
vec_interleave_high_n_lemma_uint32_8_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint32_8_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint32_8_2 res0.[4] res0.[6];
vec_interleave_high_n_lemma_uint32_8_2 res0.[5] res0.[7];
vec_interleave_low_lemma_uint32_8 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint32_8 vs0.[2] vs0.[3];
vec_interleave_low_lemma_uint32_8 vs0.[4] vs0.[5];
vec_interleave_low_lemma_uint32_8 vs0.[6] vs0.[7];
vec_interleave_high_lemma_uint32_8 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint32_8 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint32_8 vs0.[4] vs0.[5];
vec_interleave_high_lemma_uint32_8 vs0.[6] vs0.[7]
let transpose4x4_lemma #t vs =
match t with
| U32 -> Classical.forall_intro_2 (transpose4x4_lemma_uint32_ij vs)
| U64 -> Classical.forall_intro_2 (transpose4x4_lemma_uint64_ij vs) | false | false | Lib.IntVector.Transpose.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 transpose8x8_lemma: #t:v_inttype{t = U32} -> vs:lseq (vec_t t 8) 8 ->
Lemma (forall (i:nat{i < 8}) (j:nat{j < 8}). (vec_v (transpose8x8_lseq vs).[i]).[j] == (vec_v vs.[j]).[i]) | [] | Lib.IntVector.Transpose.transpose8x8_lemma | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | vs: Lib.Sequence.lseq (Lib.IntVector.vec_t t 8) 8
-> FStar.Pervasives.Lemma
(ensures
forall (i: Prims.nat{i < 8}) (j: Prims.nat{j < 8}).
(Lib.IntVector.vec_v (Lib.IntVector.Transpose.transpose8x8_lseq vs).[ i ]).[ j ] ==
(Lib.IntVector.vec_v vs.[ j ]).[ i ]) | {
"end_col": 69,
"end_line": 318,
"start_col": 2,
"start_line": 317
} |
FStar.Pervasives.Lemma | val transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose4x4_lseq_is_transposewxw #t vs0 =
let n = 2 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
eq_intro (transposewxw_lseq 2 vs0) (f_lseq4 vs0 transpose4x4_0) | val transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0)
let transpose4x4_lseq_is_transposewxw #t vs0 = | false | null | true | let n = 2 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
eq_intro (transposewxw_lseq 2 vs0) (f_lseq4 vs0 transpose4x4_0) | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"lemma"
] | [
"Lib.IntVector.v_inttype",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.Sequence.eq_intro",
"Lib.IntVector.Transpose.transposewxw_lseq",
"Lib.IntVector.Transpose.f_lseq4",
"Lib.IntVector.Transpose.transpose4x4_0",
"Prims.unit",
"Lib.LoopCombinators.eq_repeati0",
"Lib.IntVector.Transpose.transposewxw_f",
"Lib.LoopCombinators.unfold_repeati",
"Prims.int"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs
///
/// transposewxw_lseq lemmas
///
inline_for_extraction
let f_lseq4 (#t:v_inttype) (vs:lseq (vec_t t 4) 4) (f:vec_t4 t -> vec_t4 t) : lseq (vec_t t 4) 4 =
let (v0,v1,v2,v3) = (vs.[0],vs.[1],vs.[2],vs.[3]) in
let (r0,r1,r2,r3) = f (v0,v1,v2,v3) in
create4 r0 r1 r2 r3
val transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0) | false | false | Lib.IntVector.Transpose.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 transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0) | [] | Lib.IntVector.Transpose.transpose4x4_lseq_is_transposewxw | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | vs: Lib.Sequence.lseq (Lib.IntVector.vec_t t 4) 4
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.equal (Lib.IntVector.Transpose.transposewxw_lseq 2 vs)
(Lib.IntVector.Transpose.f_lseq4 vs Lib.IntVector.Transpose.transpose4x4_0)) | {
"end_col": 65,
"end_line": 188,
"start_col": 46,
"start_line": 183
} |
FStar.Pervasives.Lemma | val transpose4x4_lemma: #t:v_inttype{t = U32 \/ t = U64} -> vs:lseq (vec_t t 4) 4 ->
Lemma (forall (i:nat{i < 4}) (j:nat{j < 4}). (vec_v (transpose4x4_lseq vs).[i]).[j] == (vec_v vs.[j]).[i]) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose4x4_lemma #t vs =
match t with
| U32 -> Classical.forall_intro_2 (transpose4x4_lemma_uint32_ij vs)
| U64 -> Classical.forall_intro_2 (transpose4x4_lemma_uint64_ij vs) | val transpose4x4_lemma: #t:v_inttype{t = U32 \/ t = U64} -> vs:lseq (vec_t t 4) 4 ->
Lemma (forall (i:nat{i < 4}) (j:nat{j < 4}). (vec_v (transpose4x4_lseq vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma #t vs = | false | null | true | match t with
| U32 -> Classical.forall_intro_2 (transpose4x4_lemma_uint32_ij vs)
| U64 -> Classical.forall_intro_2 (transpose4x4_lemma_uint64_ij vs) | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"lemma"
] | [
"Lib.IntVector.v_inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"FStar.Classical.forall_intro_2",
"Prims.nat",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.IntVector.vec_v",
"Lib.Sequence.op_String_Access",
"Lib.IntVector.Transpose.transpose4x4_lseq",
"Lib.IntVector.Transpose.transpose4x4_lemma_uint32_ij",
"Lib.IntVector.Transpose.transpose4x4_lemma_uint64_ij",
"Prims.unit"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs
///
/// transposewxw_lseq lemmas
///
inline_for_extraction
let f_lseq4 (#t:v_inttype) (vs:lseq (vec_t t 4) 4) (f:vec_t4 t -> vec_t4 t) : lseq (vec_t t 4) 4 =
let (v0,v1,v2,v3) = (vs.[0],vs.[1],vs.[2],vs.[3]) in
let (r0,r1,r2,r3) = f (v0,v1,v2,v3) in
create4 r0 r1 r2 r3
val transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0)
let transpose4x4_lseq_is_transposewxw #t vs0 =
let n = 2 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
eq_intro (transposewxw_lseq 2 vs0) (f_lseq4 vs0 transpose4x4_0)
inline_for_extraction
let f_lseq8 (#t:v_inttype) (vs:lseq (vec_t t 8) 8) (f:vec_t8 t -> vec_t8 t) : lseq (vec_t t 8) 8 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = (vs.[0],vs.[1],vs.[2],vs.[3],vs.[4],vs.[5],vs.[6],vs.[7]) in
let (r0,r1,r2,r3,r4,r5,r6,r7) = f (v0,v1,v2,v3,v4,v5,v6,v7) in
create8 r0 r1 r2 r3 r4 r5 r6 r7
val transpose8x8_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 8) 8 ->
Lemma (transposewxw_lseq 3 vs `Seq.equal` f_lseq8 vs transpose8x8_012)
let transpose8x8_lseq_is_transposewxw #t vs0 =
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
eq_intro res0 (f_lseq8 vs0 transpose8x8_0);
let res1 = transposewxw_f n 1 res0 in
eq_intro res1 (f_lseq8 res0 transpose8x8_1);
let res2 = transposewxw_f n 2 res1 in
eq_intro res2 (f_lseq8 res1 transpose8x8_2);
eq_intro (transposewxw_lseq 3 vs0) (f_lseq8 vs0 transpose8x8_012)
val transpose4x4_lemma_uint32_ij: vs:lseq (vec_t U32 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma_uint32_ij vs0 i j =
transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_low_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint32_4 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint32_4 vs0.[2] vs0.[3]
val transpose4x4_lemma_uint64_ij: vs:lseq (vec_t U64 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U64 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma_uint64_ij vs0 i j =
transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint64_4_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint64_4_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint64_4_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint64_4_2 res0.[1] res0.[3];
vec_interleave_low_lemma_uint64_4 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint64_4 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint64_4 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint64_4 vs0.[2] vs0.[3]
val transpose8x8_lemma_uint32_ij: vs:lseq (vec_t U32 8) 8 -> i:nat{i < 8} -> j:nat{j < 8} ->
Lemma ((vec_v (transpose8x8_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose8x8_lemma_uint32_ij vs0 i j =
transpose8x8_lseq_is_transposewxw vs0;
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
let res1 = transposewxw_f n 1 res0 in
let res2 = transposewxw_f n 2 res1 in
vec_interleave_low_n_lemma_uint32_8_4 res1.[0] res1.[4];
vec_interleave_low_n_lemma_uint32_8_4 res1.[1] res1.[5];
vec_interleave_low_n_lemma_uint32_8_4 res1.[2] res1.[6];
vec_interleave_low_n_lemma_uint32_8_4 res1.[3] res1.[7];
vec_interleave_high_n_lemma_uint32_8_4 res1.[0] res1.[4];
vec_interleave_high_n_lemma_uint32_8_4 res1.[1] res1.[5];
vec_interleave_high_n_lemma_uint32_8_4 res1.[2] res1.[6];
vec_interleave_high_n_lemma_uint32_8_4 res1.[3] res1.[7];
vec_interleave_low_n_lemma_uint32_8_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint32_8_2 res0.[1] res0.[3];
vec_interleave_low_n_lemma_uint32_8_2 res0.[4] res0.[6];
vec_interleave_low_n_lemma_uint32_8_2 res0.[5] res0.[7];
vec_interleave_high_n_lemma_uint32_8_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint32_8_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint32_8_2 res0.[4] res0.[6];
vec_interleave_high_n_lemma_uint32_8_2 res0.[5] res0.[7];
vec_interleave_low_lemma_uint32_8 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint32_8 vs0.[2] vs0.[3];
vec_interleave_low_lemma_uint32_8 vs0.[4] vs0.[5];
vec_interleave_low_lemma_uint32_8 vs0.[6] vs0.[7];
vec_interleave_high_lemma_uint32_8 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint32_8 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint32_8 vs0.[4] vs0.[5];
vec_interleave_high_lemma_uint32_8 vs0.[6] vs0.[7] | false | false | Lib.IntVector.Transpose.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 transpose4x4_lemma: #t:v_inttype{t = U32 \/ t = U64} -> vs:lseq (vec_t t 4) 4 ->
Lemma (forall (i:nat{i < 4}) (j:nat{j < 4}). (vec_v (transpose4x4_lseq vs).[i]).[j] == (vec_v vs.[j]).[i]) | [] | Lib.IntVector.Transpose.transpose4x4_lemma | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | vs: Lib.Sequence.lseq (Lib.IntVector.vec_t t 4) 4
-> FStar.Pervasives.Lemma
(ensures
forall (i: Prims.nat{i < 4}) (j: Prims.nat{j < 4}).
(Lib.IntVector.vec_v (Lib.IntVector.Transpose.transpose4x4_lseq vs).[ i ]).[ j ] ==
(Lib.IntVector.vec_v vs.[ j ]).[ i ]) | {
"end_col": 69,
"end_line": 313,
"start_col": 2,
"start_line": 311
} |
FStar.Pervasives.Lemma | val transpose4x4_lemma_uint32_ij: vs:lseq (vec_t U32 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i]) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose4x4_lemma_uint32_ij vs0 i j =
transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_low_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint32_4 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint32_4 vs0.[2] vs0.[3] | val transpose4x4_lemma_uint32_ij: vs:lseq (vec_t U32 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma_uint32_ij vs0 i j = | false | null | true | transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint32_4_2 res0.[ 0 ] res0.[ 2 ];
vec_interleave_high_n_lemma_uint32_4_2 res0.[ 0 ] res0.[ 2 ];
vec_interleave_low_n_lemma_uint32_4_2 res0.[ 1 ] res0.[ 3 ];
vec_interleave_high_n_lemma_uint32_4_2 res0.[ 1 ] res0.[ 3 ];
vec_interleave_low_lemma_uint32_4 vs0.[ 0 ] vs0.[ 1 ];
vec_interleave_high_lemma_uint32_4 vs0.[ 0 ] vs0.[ 1 ];
vec_interleave_low_lemma_uint32_4 vs0.[ 2 ] vs0.[ 3 ];
vec_interleave_high_lemma_uint32_4 vs0.[ 2 ] vs0.[ 3 ] | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"lemma"
] | [
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.IntTypes.U32",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntVector.vec_interleave_high_lemma_uint32_4",
"Lib.Sequence.op_String_Access",
"Prims.unit",
"Lib.IntVector.vec_interleave_low_lemma_uint32_4",
"Lib.IntVector.vec_interleave_high_n_lemma_uint32_4_2",
"Lib.IntVector.vec_interleave_low_n_lemma_uint32_4_2",
"Lib.IntVector.Transpose.transposewxw_f",
"Lib.LoopCombinators.eq_repeati0",
"Lib.LoopCombinators.unfold_repeati",
"Lib.IntVector.Transpose.transposewxw_lseq",
"Prims.int",
"Lib.IntVector.Transpose.transpose4x4_lseq_is_transposewxw"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs
///
/// transposewxw_lseq lemmas
///
inline_for_extraction
let f_lseq4 (#t:v_inttype) (vs:lseq (vec_t t 4) 4) (f:vec_t4 t -> vec_t4 t) : lseq (vec_t t 4) 4 =
let (v0,v1,v2,v3) = (vs.[0],vs.[1],vs.[2],vs.[3]) in
let (r0,r1,r2,r3) = f (v0,v1,v2,v3) in
create4 r0 r1 r2 r3
val transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0)
let transpose4x4_lseq_is_transposewxw #t vs0 =
let n = 2 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
eq_intro (transposewxw_lseq 2 vs0) (f_lseq4 vs0 transpose4x4_0)
inline_for_extraction
let f_lseq8 (#t:v_inttype) (vs:lseq (vec_t t 8) 8) (f:vec_t8 t -> vec_t8 t) : lseq (vec_t t 8) 8 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = (vs.[0],vs.[1],vs.[2],vs.[3],vs.[4],vs.[5],vs.[6],vs.[7]) in
let (r0,r1,r2,r3,r4,r5,r6,r7) = f (v0,v1,v2,v3,v4,v5,v6,v7) in
create8 r0 r1 r2 r3 r4 r5 r6 r7
val transpose8x8_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 8) 8 ->
Lemma (transposewxw_lseq 3 vs `Seq.equal` f_lseq8 vs transpose8x8_012)
let transpose8x8_lseq_is_transposewxw #t vs0 =
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
eq_intro res0 (f_lseq8 vs0 transpose8x8_0);
let res1 = transposewxw_f n 1 res0 in
eq_intro res1 (f_lseq8 res0 transpose8x8_1);
let res2 = transposewxw_f n 2 res1 in
eq_intro res2 (f_lseq8 res1 transpose8x8_2);
eq_intro (transposewxw_lseq 3 vs0) (f_lseq8 vs0 transpose8x8_012)
val transpose4x4_lemma_uint32_ij: vs:lseq (vec_t U32 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i]) | false | false | Lib.IntVector.Transpose.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 transpose4x4_lemma_uint32_ij: vs:lseq (vec_t U32 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i]) | [] | Lib.IntVector.Transpose.transpose4x4_lemma_uint32_ij | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
vs: Lib.Sequence.lseq (Lib.IntVector.vec_t Lib.IntTypes.U32 4) 4 ->
i: Prims.nat{i < 4} ->
j: Prims.nat{j < 4}
-> FStar.Pervasives.Lemma
(ensures
(Lib.IntVector.vec_v (Lib.IntVector.Transpose.transpose4x4_lseq vs).[ i ]).[ j ] ==
(Lib.IntVector.vec_v vs.[ j ]).[ i ]) | {
"end_col": 52,
"end_line": 239,
"start_col": 2,
"start_line": 221
} |
FStar.Pervasives.Lemma | val transpose4x4_lemma_uint64_ij: vs:lseq (vec_t U64 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U64 vs).[i]).[j] == (vec_v vs.[j]).[i]) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose4x4_lemma_uint64_ij vs0 i j =
transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint64_4_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint64_4_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint64_4_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint64_4_2 res0.[1] res0.[3];
vec_interleave_low_lemma_uint64_4 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint64_4 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint64_4 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint64_4 vs0.[2] vs0.[3] | val transpose4x4_lemma_uint64_ij: vs:lseq (vec_t U64 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U64 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma_uint64_ij vs0 i j = | false | null | true | transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint64_4_2 res0.[ 0 ] res0.[ 2 ];
vec_interleave_high_n_lemma_uint64_4_2 res0.[ 0 ] res0.[ 2 ];
vec_interleave_low_n_lemma_uint64_4_2 res0.[ 1 ] res0.[ 3 ];
vec_interleave_high_n_lemma_uint64_4_2 res0.[ 1 ] res0.[ 3 ];
vec_interleave_low_lemma_uint64_4 vs0.[ 0 ] vs0.[ 1 ];
vec_interleave_high_lemma_uint64_4 vs0.[ 0 ] vs0.[ 1 ];
vec_interleave_low_lemma_uint64_4 vs0.[ 2 ] vs0.[ 3 ];
vec_interleave_high_lemma_uint64_4 vs0.[ 2 ] vs0.[ 3 ] | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"lemma"
] | [
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.IntTypes.U64",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntVector.vec_interleave_high_lemma_uint64_4",
"Lib.Sequence.op_String_Access",
"Prims.unit",
"Lib.IntVector.vec_interleave_low_lemma_uint64_4",
"Lib.IntVector.vec_interleave_high_n_lemma_uint64_4_2",
"Lib.IntVector.vec_interleave_low_n_lemma_uint64_4_2",
"Lib.IntVector.Transpose.transposewxw_f",
"Lib.LoopCombinators.eq_repeati0",
"Lib.LoopCombinators.unfold_repeati",
"Lib.IntVector.Transpose.transposewxw_lseq",
"Prims.int",
"Lib.IntVector.Transpose.transpose4x4_lseq_is_transposewxw"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs
///
/// transposewxw_lseq lemmas
///
inline_for_extraction
let f_lseq4 (#t:v_inttype) (vs:lseq (vec_t t 4) 4) (f:vec_t4 t -> vec_t4 t) : lseq (vec_t t 4) 4 =
let (v0,v1,v2,v3) = (vs.[0],vs.[1],vs.[2],vs.[3]) in
let (r0,r1,r2,r3) = f (v0,v1,v2,v3) in
create4 r0 r1 r2 r3
val transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0)
let transpose4x4_lseq_is_transposewxw #t vs0 =
let n = 2 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
eq_intro (transposewxw_lseq 2 vs0) (f_lseq4 vs0 transpose4x4_0)
inline_for_extraction
let f_lseq8 (#t:v_inttype) (vs:lseq (vec_t t 8) 8) (f:vec_t8 t -> vec_t8 t) : lseq (vec_t t 8) 8 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = (vs.[0],vs.[1],vs.[2],vs.[3],vs.[4],vs.[5],vs.[6],vs.[7]) in
let (r0,r1,r2,r3,r4,r5,r6,r7) = f (v0,v1,v2,v3,v4,v5,v6,v7) in
create8 r0 r1 r2 r3 r4 r5 r6 r7
val transpose8x8_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 8) 8 ->
Lemma (transposewxw_lseq 3 vs `Seq.equal` f_lseq8 vs transpose8x8_012)
let transpose8x8_lseq_is_transposewxw #t vs0 =
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
eq_intro res0 (f_lseq8 vs0 transpose8x8_0);
let res1 = transposewxw_f n 1 res0 in
eq_intro res1 (f_lseq8 res0 transpose8x8_1);
let res2 = transposewxw_f n 2 res1 in
eq_intro res2 (f_lseq8 res1 transpose8x8_2);
eq_intro (transposewxw_lseq 3 vs0) (f_lseq8 vs0 transpose8x8_012)
val transpose4x4_lemma_uint32_ij: vs:lseq (vec_t U32 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma_uint32_ij vs0 i j =
transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_low_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint32_4 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint32_4 vs0.[2] vs0.[3]
val transpose4x4_lemma_uint64_ij: vs:lseq (vec_t U64 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U64 vs).[i]).[j] == (vec_v vs.[j]).[i]) | false | false | Lib.IntVector.Transpose.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 transpose4x4_lemma_uint64_ij: vs:lseq (vec_t U64 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U64 vs).[i]).[j] == (vec_v vs.[j]).[i]) | [] | Lib.IntVector.Transpose.transpose4x4_lemma_uint64_ij | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
vs: Lib.Sequence.lseq (Lib.IntVector.vec_t Lib.IntTypes.U64 4) 4 ->
i: Prims.nat{i < 4} ->
j: Prims.nat{j < 4}
-> FStar.Pervasives.Lemma
(ensures
(Lib.IntVector.vec_v (Lib.IntVector.Transpose.transpose4x4_lseq vs).[ i ]).[ j ] ==
(Lib.IntVector.vec_v vs.[ j ]).[ i ]) | {
"end_col": 52,
"end_line": 264,
"start_col": 2,
"start_line": 246
} |
FStar.Pervasives.Lemma | val transpose8x8_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 8) 8 ->
Lemma (transposewxw_lseq 3 vs `Seq.equal` f_lseq8 vs transpose8x8_012) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose8x8_lseq_is_transposewxw #t vs0 =
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
eq_intro res0 (f_lseq8 vs0 transpose8x8_0);
let res1 = transposewxw_f n 1 res0 in
eq_intro res1 (f_lseq8 res0 transpose8x8_1);
let res2 = transposewxw_f n 2 res1 in
eq_intro res2 (f_lseq8 res1 transpose8x8_2);
eq_intro (transposewxw_lseq 3 vs0) (f_lseq8 vs0 transpose8x8_012) | val transpose8x8_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 8) 8 ->
Lemma (transposewxw_lseq 3 vs `Seq.equal` f_lseq8 vs transpose8x8_012)
let transpose8x8_lseq_is_transposewxw #t vs0 = | false | null | true | let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
eq_intro res0 (f_lseq8 vs0 transpose8x8_0);
let res1 = transposewxw_f n 1 res0 in
eq_intro res1 (f_lseq8 res0 transpose8x8_1);
let res2 = transposewxw_f n 2 res1 in
eq_intro res2 (f_lseq8 res1 transpose8x8_2);
eq_intro (transposewxw_lseq 3 vs0) (f_lseq8 vs0 transpose8x8_012) | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"lemma"
] | [
"Lib.IntVector.v_inttype",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.Sequence.eq_intro",
"Lib.IntVector.Transpose.transposewxw_lseq",
"Lib.IntVector.Transpose.f_lseq8",
"Lib.IntVector.Transpose.transpose8x8_012",
"Prims.unit",
"Lib.IntVector.Transpose.transpose8x8_2",
"Lib.IntVector.Transpose.transposewxw_f",
"Lib.IntVector.Transpose.transpose8x8_1",
"Lib.IntVector.Transpose.transpose8x8_0",
"Lib.LoopCombinators.eq_repeati0",
"Lib.LoopCombinators.unfold_repeati",
"Prims.int"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs
///
/// transposewxw_lseq lemmas
///
inline_for_extraction
let f_lseq4 (#t:v_inttype) (vs:lseq (vec_t t 4) 4) (f:vec_t4 t -> vec_t4 t) : lseq (vec_t t 4) 4 =
let (v0,v1,v2,v3) = (vs.[0],vs.[1],vs.[2],vs.[3]) in
let (r0,r1,r2,r3) = f (v0,v1,v2,v3) in
create4 r0 r1 r2 r3
val transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0)
let transpose4x4_lseq_is_transposewxw #t vs0 =
let n = 2 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
eq_intro (transposewxw_lseq 2 vs0) (f_lseq4 vs0 transpose4x4_0)
inline_for_extraction
let f_lseq8 (#t:v_inttype) (vs:lseq (vec_t t 8) 8) (f:vec_t8 t -> vec_t8 t) : lseq (vec_t t 8) 8 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = (vs.[0],vs.[1],vs.[2],vs.[3],vs.[4],vs.[5],vs.[6],vs.[7]) in
let (r0,r1,r2,r3,r4,r5,r6,r7) = f (v0,v1,v2,v3,v4,v5,v6,v7) in
create8 r0 r1 r2 r3 r4 r5 r6 r7
val transpose8x8_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 8) 8 ->
Lemma (transposewxw_lseq 3 vs `Seq.equal` f_lseq8 vs transpose8x8_012) | false | false | Lib.IntVector.Transpose.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 transpose8x8_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 8) 8 ->
Lemma (transposewxw_lseq 3 vs `Seq.equal` f_lseq8 vs transpose8x8_012) | [] | Lib.IntVector.Transpose.transpose8x8_lseq_is_transposewxw | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | vs: Lib.Sequence.lseq (Lib.IntVector.vec_t t 8) 8
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.equal (Lib.IntVector.Transpose.transposewxw_lseq 3 vs)
(Lib.IntVector.Transpose.f_lseq8 vs Lib.IntVector.Transpose.transpose8x8_012)) | {
"end_col": 67,
"end_line": 214,
"start_col": 46,
"start_line": 201
} |
FStar.Pervasives.Lemma | val transpose8x8_lemma_uint32_ij: vs:lseq (vec_t U32 8) 8 -> i:nat{i < 8} -> j:nat{j < 8} ->
Lemma ((vec_v (transpose8x8_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i]) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let transpose8x8_lemma_uint32_ij vs0 i j =
transpose8x8_lseq_is_transposewxw vs0;
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
let res1 = transposewxw_f n 1 res0 in
let res2 = transposewxw_f n 2 res1 in
vec_interleave_low_n_lemma_uint32_8_4 res1.[0] res1.[4];
vec_interleave_low_n_lemma_uint32_8_4 res1.[1] res1.[5];
vec_interleave_low_n_lemma_uint32_8_4 res1.[2] res1.[6];
vec_interleave_low_n_lemma_uint32_8_4 res1.[3] res1.[7];
vec_interleave_high_n_lemma_uint32_8_4 res1.[0] res1.[4];
vec_interleave_high_n_lemma_uint32_8_4 res1.[1] res1.[5];
vec_interleave_high_n_lemma_uint32_8_4 res1.[2] res1.[6];
vec_interleave_high_n_lemma_uint32_8_4 res1.[3] res1.[7];
vec_interleave_low_n_lemma_uint32_8_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint32_8_2 res0.[1] res0.[3];
vec_interleave_low_n_lemma_uint32_8_2 res0.[4] res0.[6];
vec_interleave_low_n_lemma_uint32_8_2 res0.[5] res0.[7];
vec_interleave_high_n_lemma_uint32_8_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint32_8_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint32_8_2 res0.[4] res0.[6];
vec_interleave_high_n_lemma_uint32_8_2 res0.[5] res0.[7];
vec_interleave_low_lemma_uint32_8 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint32_8 vs0.[2] vs0.[3];
vec_interleave_low_lemma_uint32_8 vs0.[4] vs0.[5];
vec_interleave_low_lemma_uint32_8 vs0.[6] vs0.[7];
vec_interleave_high_lemma_uint32_8 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint32_8 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint32_8 vs0.[4] vs0.[5];
vec_interleave_high_lemma_uint32_8 vs0.[6] vs0.[7] | val transpose8x8_lemma_uint32_ij: vs:lseq (vec_t U32 8) 8 -> i:nat{i < 8} -> j:nat{j < 8} ->
Lemma ((vec_v (transpose8x8_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose8x8_lemma_uint32_ij vs0 i j = | false | null | true | transpose8x8_lseq_is_transposewxw vs0;
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
let res1 = transposewxw_f n 1 res0 in
let res2 = transposewxw_f n 2 res1 in
vec_interleave_low_n_lemma_uint32_8_4 res1.[ 0 ] res1.[ 4 ];
vec_interleave_low_n_lemma_uint32_8_4 res1.[ 1 ] res1.[ 5 ];
vec_interleave_low_n_lemma_uint32_8_4 res1.[ 2 ] res1.[ 6 ];
vec_interleave_low_n_lemma_uint32_8_4 res1.[ 3 ] res1.[ 7 ];
vec_interleave_high_n_lemma_uint32_8_4 res1.[ 0 ] res1.[ 4 ];
vec_interleave_high_n_lemma_uint32_8_4 res1.[ 1 ] res1.[ 5 ];
vec_interleave_high_n_lemma_uint32_8_4 res1.[ 2 ] res1.[ 6 ];
vec_interleave_high_n_lemma_uint32_8_4 res1.[ 3 ] res1.[ 7 ];
vec_interleave_low_n_lemma_uint32_8_2 res0.[ 0 ] res0.[ 2 ];
vec_interleave_low_n_lemma_uint32_8_2 res0.[ 1 ] res0.[ 3 ];
vec_interleave_low_n_lemma_uint32_8_2 res0.[ 4 ] res0.[ 6 ];
vec_interleave_low_n_lemma_uint32_8_2 res0.[ 5 ] res0.[ 7 ];
vec_interleave_high_n_lemma_uint32_8_2 res0.[ 0 ] res0.[ 2 ];
vec_interleave_high_n_lemma_uint32_8_2 res0.[ 1 ] res0.[ 3 ];
vec_interleave_high_n_lemma_uint32_8_2 res0.[ 4 ] res0.[ 6 ];
vec_interleave_high_n_lemma_uint32_8_2 res0.[ 5 ] res0.[ 7 ];
vec_interleave_low_lemma_uint32_8 vs0.[ 0 ] vs0.[ 1 ];
vec_interleave_low_lemma_uint32_8 vs0.[ 2 ] vs0.[ 3 ];
vec_interleave_low_lemma_uint32_8 vs0.[ 4 ] vs0.[ 5 ];
vec_interleave_low_lemma_uint32_8 vs0.[ 6 ] vs0.[ 7 ];
vec_interleave_high_lemma_uint32_8 vs0.[ 0 ] vs0.[ 1 ];
vec_interleave_high_lemma_uint32_8 vs0.[ 2 ] vs0.[ 3 ];
vec_interleave_high_lemma_uint32_8 vs0.[ 4 ] vs0.[ 5 ];
vec_interleave_high_lemma_uint32_8 vs0.[ 6 ] vs0.[ 7 ] | {
"checked_file": "Lib.IntVector.Transpose.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
} | [
"lemma"
] | [
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.IntTypes.U32",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntVector.vec_interleave_high_lemma_uint32_8",
"Lib.Sequence.op_String_Access",
"Prims.unit",
"Lib.IntVector.vec_interleave_low_lemma_uint32_8",
"Lib.IntVector.vec_interleave_high_n_lemma_uint32_8_2",
"Lib.IntVector.vec_interleave_low_n_lemma_uint32_8_2",
"Lib.IntVector.vec_interleave_high_n_lemma_uint32_8_4",
"Lib.IntVector.vec_interleave_low_n_lemma_uint32_8_4",
"Lib.IntVector.Transpose.transposewxw_f",
"Lib.LoopCombinators.eq_repeati0",
"Lib.LoopCombinators.unfold_repeati",
"Prims.int",
"Lib.IntVector.Transpose.transpose8x8_lseq_is_transposewxw"
] | [] | module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs
///
/// transposewxw_lseq lemmas
///
inline_for_extraction
let f_lseq4 (#t:v_inttype) (vs:lseq (vec_t t 4) 4) (f:vec_t4 t -> vec_t4 t) : lseq (vec_t t 4) 4 =
let (v0,v1,v2,v3) = (vs.[0],vs.[1],vs.[2],vs.[3]) in
let (r0,r1,r2,r3) = f (v0,v1,v2,v3) in
create4 r0 r1 r2 r3
val transpose4x4_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 4) 4 ->
Lemma (transposewxw_lseq 2 vs `Seq.equal` f_lseq4 vs transpose4x4_0)
let transpose4x4_lseq_is_transposewxw #t vs0 =
let n = 2 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
eq_intro (transposewxw_lseq 2 vs0) (f_lseq4 vs0 transpose4x4_0)
inline_for_extraction
let f_lseq8 (#t:v_inttype) (vs:lseq (vec_t t 8) 8) (f:vec_t8 t -> vec_t8 t) : lseq (vec_t t 8) 8 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = (vs.[0],vs.[1],vs.[2],vs.[3],vs.[4],vs.[5],vs.[6],vs.[7]) in
let (r0,r1,r2,r3,r4,r5,r6,r7) = f (v0,v1,v2,v3,v4,v5,v6,v7) in
create8 r0 r1 r2 r3 r4 r5 r6 r7
val transpose8x8_lseq_is_transposewxw: #t:v_inttype -> vs:lseq (vec_t t 8) 8 ->
Lemma (transposewxw_lseq 3 vs `Seq.equal` f_lseq8 vs transpose8x8_012)
let transpose8x8_lseq_is_transposewxw #t vs0 =
let n = 3 in
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 2;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #8 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #8 n) vs0;
let res0 = transposewxw_f n 0 vs0 in
eq_intro res0 (f_lseq8 vs0 transpose8x8_0);
let res1 = transposewxw_f n 1 res0 in
eq_intro res1 (f_lseq8 res0 transpose8x8_1);
let res2 = transposewxw_f n 2 res1 in
eq_intro res2 (f_lseq8 res1 transpose8x8_2);
eq_intro (transposewxw_lseq 3 vs0) (f_lseq8 vs0 transpose8x8_012)
val transpose4x4_lemma_uint32_ij: vs:lseq (vec_t U32 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma_uint32_ij vs0 i j =
transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint32_4_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint32_4_2 res0.[1] res0.[3];
vec_interleave_low_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint32_4 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint32_4 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint32_4 vs0.[2] vs0.[3]
val transpose4x4_lemma_uint64_ij: vs:lseq (vec_t U64 4) 4 -> i:nat{i < 4} -> j:nat{j < 4} ->
Lemma ((vec_v (transpose4x4_lseq #U64 vs).[i]).[j] == (vec_v vs.[j]).[i])
let transpose4x4_lemma_uint64_ij vs0 i j =
transpose4x4_lseq_is_transposewxw vs0;
let n = 2 in
let r = transposewxw_lseq 2 vs0 in
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 1;
Loops.unfold_repeati n (transposewxw_f #4 n) vs0 0;
Loops.eq_repeati0 n (transposewxw_f #4 n) vs0;
let res0 = transposewxw_f 2 0 vs0 in
let res1 = transposewxw_f 2 1 res0 in
vec_interleave_low_n_lemma_uint64_4_2 res0.[0] res0.[2];
vec_interleave_high_n_lemma_uint64_4_2 res0.[0] res0.[2];
vec_interleave_low_n_lemma_uint64_4_2 res0.[1] res0.[3];
vec_interleave_high_n_lemma_uint64_4_2 res0.[1] res0.[3];
vec_interleave_low_lemma_uint64_4 vs0.[0] vs0.[1];
vec_interleave_high_lemma_uint64_4 vs0.[0] vs0.[1];
vec_interleave_low_lemma_uint64_4 vs0.[2] vs0.[3];
vec_interleave_high_lemma_uint64_4 vs0.[2] vs0.[3]
val transpose8x8_lemma_uint32_ij: vs:lseq (vec_t U32 8) 8 -> i:nat{i < 8} -> j:nat{j < 8} ->
Lemma ((vec_v (transpose8x8_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i]) | false | false | Lib.IntVector.Transpose.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 transpose8x8_lemma_uint32_ij: vs:lseq (vec_t U32 8) 8 -> i:nat{i < 8} -> j:nat{j < 8} ->
Lemma ((vec_v (transpose8x8_lseq #U32 vs).[i]).[j] == (vec_v vs.[j]).[i]) | [] | Lib.IntVector.Transpose.transpose8x8_lemma_uint32_ij | {
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
vs: Lib.Sequence.lseq (Lib.IntVector.vec_t Lib.IntTypes.U32 8) 8 ->
i: Prims.nat{i < 8} ->
j: Prims.nat{j < 8}
-> FStar.Pervasives.Lemma
(ensures
(Lib.IntVector.vec_v (Lib.IntVector.Transpose.transpose8x8_lseq vs).[ i ]).[ j ] ==
(Lib.IntVector.vec_v vs.[ j ]).[ i ]) | {
"end_col": 52,
"end_line": 307,
"start_col": 2,
"start_line": 271
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let half = half_perm full_perm | let half = | false | null | false | half_perm full_perm | {
"checked_file": "Steel.LockCoupling.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Reference.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.LockCoupling.fsti"
} | [
"total"
] | [
"Steel.FractionalPermission.half_perm",
"Steel.FractionalPermission.full_perm"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.LockCoupling
open Steel.ST.Util
open Steel.ST.Reference
open Steel.FractionalPermission
(*
This example sketches how an invariant for lock-coupling list
(a list that stores a lock at each cell protecting its tail pointer)
might work.
It relies on strictly positive version of the exists and pts_to
separation logic predicates, although the libraries are not
currently annotated with such positivity annotations.=
*)
(* It is relatively easy to show that h_exists is strictly positive *)
val h_exists (#[@@@strictly_positive] a:Type)
([@@@strictly_positive] p:(a -> vprop))
: vprop
(* the pts_to predicate is a bit more subtle. It is an instance
of a more general form that involves assertions about a PCM,
and it is possible to construct PCMs that are not strictly
positive. However, the basic pts_to predicate that this refers to,
for the fractional permission PCM, is strictly positive.
Revising the library to enable decorating pts_to predicates derived
from positive PCMs remains to be done. *)
val pts_to (#[@@@strictly_positive] a:Type)
(r:ref a)
(f:perm)
(v:a) : vprop
val lock ([@@@strictly_positive] p:vprop) : Type0 | false | true | Steel.LockCoupling.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 half : Steel.FractionalPermission.perm | [] | Steel.LockCoupling.half | {
"file_name": "lib/steel/Steel.LockCoupling.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Steel.FractionalPermission.perm | {
"end_col": 30,
"end_line": 51,
"start_col": 11,
"start_line": 51
} |
|
Prims.Tot | val list_inv (#a: Type) (p: ref (llist_cell a)) (repr: list a) : Tot vprop (decreases repr) | [
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_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 list_inv (#a:Type) (p:ref (llist_cell a)) (repr:list a)
: Tot vprop (decreases repr)
= match repr with
| [] -> pure (p == null)
| hd::tl ->
h_exists (fun cell ->
pts_to p half cell `star`
pure (cell.v == hd) `star`
list_inv cell.next tl) | val list_inv (#a: Type) (p: ref (llist_cell a)) (repr: list a) : Tot vprop (decreases repr)
let rec list_inv (#a: Type) (p: ref (llist_cell a)) (repr: list a) : Tot vprop (decreases repr) = | false | null | false | match repr with
| [] -> pure (p == null)
| hd :: tl ->
h_exists (fun cell ->
((pts_to p half cell) `star` (pure (cell.v == hd))) `star` (list_inv cell.next tl)) | {
"checked_file": "Steel.LockCoupling.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Reference.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.LockCoupling.fsti"
} | [
"total",
""
] | [
"Steel.ST.Reference.ref",
"Steel.LockCoupling.llist_cell",
"Prims.list",
"Steel.ST.Util.pure",
"Prims.eq2",
"Steel.ST.Reference.null",
"Steel.LockCoupling.h_exists",
"Steel.Effect.Common.star",
"Steel.LockCoupling.pts_to",
"Steel.LockCoupling.half",
"Steel.LockCoupling.__proj__Mkllist_cell__item__v",
"Steel.LockCoupling.list_inv",
"Steel.LockCoupling.__proj__Mkllist_cell__item__next",
"Steel.Effect.Common.vprop"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.LockCoupling
open Steel.ST.Util
open Steel.ST.Reference
open Steel.FractionalPermission
(*
This example sketches how an invariant for lock-coupling list
(a list that stores a lock at each cell protecting its tail pointer)
might work.
It relies on strictly positive version of the exists and pts_to
separation logic predicates, although the libraries are not
currently annotated with such positivity annotations.=
*)
(* It is relatively easy to show that h_exists is strictly positive *)
val h_exists (#[@@@strictly_positive] a:Type)
([@@@strictly_positive] p:(a -> vprop))
: vprop
(* the pts_to predicate is a bit more subtle. It is an instance
of a more general form that involves assertions about a PCM,
and it is possible to construct PCMs that are not strictly
positive. However, the basic pts_to predicate that this refers to,
for the fractional permission PCM, is strictly positive.
Revising the library to enable decorating pts_to predicates derived
from positive PCMs remains to be done. *)
val pts_to (#[@@@strictly_positive] a:Type)
(r:ref a)
(f:perm)
(v:a) : vprop
val lock ([@@@strictly_positive] p:vprop) : Type0
let half = half_perm full_perm
(* The lock at each cell holds half permission to the next pointer *)
noeq
type llist_cell (a:Type0) : Type = {
v : a;
next : ref (llist_cell a);
lock : lock (h_exists (pts_to next half))
}
(* A separation list_inv holds the other half permission *)
let rec list_inv (#a:Type) (p:ref (llist_cell a)) (repr:list a) | false | false | Steel.LockCoupling.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 list_inv (#a: Type) (p: ref (llist_cell a)) (repr: list a) : Tot vprop (decreases repr) | [
"recursion"
] | Steel.LockCoupling.list_inv | {
"file_name": "lib/steel/Steel.LockCoupling.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.ST.Reference.ref (Steel.LockCoupling.llist_cell a) -> repr: Prims.list a
-> Prims.Tot Steel.Effect.Common.vprop | {
"end_col": 30,
"end_line": 70,
"start_col": 4,
"start_line": 64
} |
Prims.Tot | val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let reverse #t #len b = createi len (fun i -> b.[len - i - 1]) | val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = | false | null | false | createi len (fun i -> b.[ len - i - 1 ]) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.Sequence.createi",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.Sequence.op_String_Access",
"Prims.op_Subtraction"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
/// | false | false | Hacl.Spec.Bignum.Convert.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 reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len | [] | Hacl.Spec.Bignum.Convert.reverse | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Hacl.Spec.Bignum.Definitions.lbignum t len -> Hacl.Spec.Bignum.Definitions.lbignum t len | {
"end_col": 62,
"end_line": 137,
"start_col": 24,
"start_line": 137
} |
Prims.Tot | val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x | val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x = | false | null | false | let b = create len (uint #t 0) in
b.[ 0 ] <- x | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Hacl.Spec.Bignum.Definitions.limb",
"Lib.Sequence.op_String_Assignment",
"Lib.Sequence.lseq",
"Prims.l_and",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.SEC",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.Sequence.index",
"Lib.Sequence.create",
"Lib.IntTypes.uint",
"Hacl.Spec.Bignum.Definitions.lbignum"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len | [] | Hacl.Spec.Bignum.Convert.bn_from_uint | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_pos -> x: Hacl.Spec.Bignum.Definitions.limb t
-> Hacl.Spec.Bignum.Definitions.lbignum t len | {
"end_col": 12,
"end_line": 17,
"start_col": 27,
"start_line": 15
} |
Prims.Tot | val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b) | val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b = | false | null | false | createi len (bn_from_bytes_be_f len b) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Lib.Sequence.createi",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Convert.bn_from_bytes_be_f",
"Hacl.Spec.Bignum.Definitions.lbignum"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len | [] | Hacl.Spec.Bignum.Convert.bn_from_bytes_be_ | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat{Lib.IntTypes.numbytes t * len <= Lib.IntTypes.max_size_t} ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.numbytes t * len)
-> Hacl.Spec.Bignum.Definitions.lbignum t len | {
"end_col": 40,
"end_line": 51,
"start_col": 2,
"start_line": 51
} |
Prims.Tot | val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1] | val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () = | false | null | false | (), uint_to_bytes_be b.[ len - i - 1 ] | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Lib.IntTypes.numbytes",
"Lib.ByteSequence.uint_to_bytes_be",
"Lib.IntTypes.SEC",
"Lib.Sequence.op_String_Access",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.op_Subtraction",
"FStar.Pervasives.Native.tuple2"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t) | [] | Hacl.Spec.Bignum.Convert.bn_to_bytes_be_f | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat ->
b: Hacl.Spec.Bignum.Definitions.lbignum t len ->
i: Prims.nat{i < len} ->
_: Prims.unit
-> Prims.unit * Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.numbytes t) | {
"end_col": 38,
"end_line": 91,
"start_col": 2,
"start_line": 91
} |
Prims.Tot | val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o | val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b = | false | null | false | let a_spec (i: nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec (bn_to_bytes_be_f len b) () in
o | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.Sequence.seq",
"Lib.IntTypes.uint8",
"Prims.eq2",
"Prims.int",
"Lib.Sequence.length",
"Lib.Sequence.lseq",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Lib.Sequence.generate_blocks",
"Hacl.Spec.Bignum.Convert.bn_to_bytes_be_f",
"Prims.nat",
"Prims.eqtype",
"Prims.unit"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len) | [] | Hacl.Spec.Bignum.Convert.bn_to_bytes_be_ | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat{Lib.IntTypes.numbytes t * len <= Lib.IntTypes.max_size_t} ->
b: Hacl.Spec.Bignum.Definitions.lbignum t len
-> Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.numbytes t * len) | {
"end_col": 3,
"end_line": 104,
"start_col": 30,
"start_line": 100
} |
FStar.Pervasives.Lemma | val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b | val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b = | false | null | true | let lemma_aux (i: nat{i < len}) : Lemma ((reverse (reverse b)).[ i ] == b.[ i ]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.Sequence.eq_intro",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Convert.reverse",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.op_String_Access",
"Prims.l_True",
"Prims.squash",
"Lib.Sequence.index",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1]) | false | false | Hacl.Spec.Bignum.Convert.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 twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b) | [] | Hacl.Spec.Bignum.Convert.twice_reverse | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Hacl.Spec.Bignum.Definitions.lbignum t len
-> FStar.Pervasives.Lemma
(ensures Hacl.Spec.Bignum.Convert.reverse (Hacl.Spec.Bignum.Convert.reverse b) == b) | {
"end_col": 34,
"end_line": 145,
"start_col": 29,
"start_line": 141
} |
Prims.Tot | val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t)) | val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i = | false | null | false | uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t)) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Prims.nat",
"Prims.op_LessThan",
"Lib.ByteSequence.uint_from_bytes_be",
"Lib.IntTypes.SEC",
"Lib.Sequence.sub",
"Prims.op_Subtraction",
"Hacl.Spec.Bignum.Definitions.limb"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t | [] | Hacl.Spec.Bignum.Convert.bn_from_bytes_be_f | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat{Lib.IntTypes.numbytes t * len <= Lib.IntTypes.max_size_t} ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.numbytes t * len) ->
i: Prims.nat{i < len}
-> Hacl.Spec.Bignum.Definitions.limb t | {
"end_col": 70,
"end_line": 41,
"start_col": 2,
"start_line": 41
} |
Prims.Tot | val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len | val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b = | false | null | false | let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.max_size_t",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.Sequence.sub",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Prims.op_Multiply",
"Lib.ByteSequence.uints_to_bytes_le",
"Prims.int",
"Prims.pos",
"Prims.op_Subtraction",
"Prims.pow2",
"Lib.IntTypes.uint8"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len | [] | Hacl.Spec.Bignum.Convert.bn_to_bytes_le | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len:
Lib.IntTypes.size_pos
{ Lib.IntTypes.numbytes t *
Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <=
Lib.IntTypes.max_size_t } ->
b:
Hacl.Spec.Bignum.Definitions.lbignum t
(Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t))
-> Lib.Sequence.lseq Lib.IntTypes.uint8 len | {
"end_col": 15,
"end_line": 130,
"start_col": 29,
"start_line": 126
} |
Prims.Tot | val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len | val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b = | false | null | false | let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.max_size_t",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.Sequence.sub",
"Lib.IntTypes.uint8",
"Prims.op_Subtraction",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Hacl.Spec.Bignum.Convert.bn_to_bytes_be_",
"Prims.int",
"Prims.pos",
"Prims.pow2"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len | [] | Hacl.Spec.Bignum.Convert.bn_to_bytes_be | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len:
Lib.IntTypes.size_pos
{ Lib.IntTypes.numbytes t *
Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <=
Lib.IntTypes.max_size_t } ->
b:
Hacl.Spec.Bignum.Definitions.lbignum t
(Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t))
-> Lib.Sequence.lseq Lib.IntTypes.uint8 len | {
"end_col": 28,
"end_line": 117,
"start_col": 29,
"start_line": 113
} |
FStar.Pervasives.Lemma | val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b) | val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b = | false | null | true | bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Prims._assert",
"Prims.eq2",
"Prims.nat",
"Prims.l_or",
"Prims.op_LessThan",
"Prims.pow2",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.ByteSequence.uints_from_bytes_be",
"Lib.IntTypes.bits",
"Lib.ByteSequence.nat_from_intseq_be",
"Lib.ByteSequence.nat_from_bytes_be",
"Prims.unit",
"Lib.ByteSequence.uints_from_bytes_be_nat_lemma",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Hacl.Spec.Bignum.Convert.bn_from_bytes_be_",
"Hacl.Spec.Bignum.Convert.twice_reverse",
"Hacl.Spec.Bignum.Convert.bn_from_bytes_be_is_uints_from_bytes_be_reverse",
"Hacl.Spec.Bignum.Convert.bn_v_is_nat_from_intseq_be_lemma"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b) | [] | Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma_ | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat{Lib.IntTypes.numbytes t * len <= Lib.IntTypes.max_size_t} ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.numbytes t * len)
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.Convert.bn_from_bytes_be_ len b) ==
Lib.ByteSequence.nat_from_bytes_be b) | {
"end_col": 89,
"end_line": 211,
"start_col": 2,
"start_line": 206
} |
FStar.Pervasives.Lemma | val lemma_nat_from_bytes_le_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_le b == 0) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec lemma_nat_from_bytes_le_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_le_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_le_lemma0 (slice b 0 1);
lemma_nat_from_bytes_le_zeroes (len-1) (slice b 1 len) end | val lemma_nat_from_bytes_le_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_le b == 0)
let rec lemma_nat_from_bytes_le_zeroes len b = | false | null | true | if len = 0
then ()
else
(nat_from_intseq_le_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_le_lemma0 (slice b 0 1);
lemma_nat_from_bytes_le_zeroes (len - 1) (slice b 1 len)) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Hacl.Spec.Bignum.Convert.lemma_nat_from_bytes_le_zeroes",
"Prims.op_Subtraction",
"Lib.Sequence.slice",
"Prims.unit",
"Lib.ByteSequence.nat_from_intseq_le_lemma0",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.ByteSequence.nat_from_intseq_le_slice_lemma"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b
val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
let index_bn_to_bytes_be_ #t len b i =
let numb = numbytes t in
let bi = b.[len - i / numb - 1] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[i] == (uint_to_bytes_be bi).[i % numb]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[i % numb] == uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)
let bn_to_bytes_be_lemma_aux #t len b i =
let pbits = bits t in
let numb = numbytes t in
let e = numb - 1 - i % numb in
let e1 = len - i / numb - 1 in
let e2 = numb * len - 1 - i in
calc (==) {
v b.[e1] / pow2 (8 * e) % pow2 8;
(==) { bn_eval_index b e1 }
(bn_v b / pow2 (pbits * e1) % pow2 (pbits)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (pbits * e1) (pbits + pbits * e1) }
(bn_v b % pow2 (pbits + pbits * e1) / pow2 (pbits * e1)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.division_multiplication_lemma (bn_v b % pow2 (pbits + pbits * e1)) (pow2 (pbits * e1)) (pow2 (8 * e)) }
(bn_v b % pow2 (pbits + pbits * e1)) / (pow2 (pbits * e1) * pow2 (8 * e)) % pow2 8;
(==) { Math.Lemmas.pow2_plus (pbits * e1) (8 * e) }
(bn_v b % pow2 (pbits + pbits * e1)) / pow2 (pbits * e1 + 8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (8 * e2) (pbits + pbits * e1) }
(bn_v b / pow2 (8 * e2)) % pow2 (pbits + pbits * e1 - 8 * e2) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 (bn_v b / pow2 (8 * e2)) 8 (pbits + pbits * e1 - 8 * e2) }
(bn_v b / pow2 (8 * (numb * len - i - 1))) % pow2 8;
}
val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b))
let bn_to_bytes_be_lemma_ #t len b =
let numb = numbytes t in
let lemma_aux (i:nat{i < numb * len}) :
Lemma ((bn_to_bytes_be_ #t len b).[i] == index #uint8 #(numb * len) (nat_to_intseq_be (numb * len) (bn_v b)) i)
=
let rp = nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) in
index_nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) (numb * len - i - 1);
assert (index #uint8 #(numb * len) rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8));
index_bn_to_bytes_be_ len b i;
assert ((bn_to_bytes_be_ #t len b).[i] == uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8));
bn_to_bytes_be_lemma_aux len b i;
() in
Classical.forall_intro lemma_aux;
eq_intro (bn_to_bytes_be_ len b) (nat_to_intseq_be (numb * len) (bn_v b))
val bn_to_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_be #t len b == nat_to_intseq_be #U8 #SEC len (bn_v b))
let bn_to_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
let res = sub tmp (tmpLen - len) len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
bn_to_bytes_be_lemma_ bnLen b;
assert (tmp == nat_to_intseq_be #U8 #SEC tmpLen (bn_v b));
let lemma_aux (i:nat{i < len}) :
Lemma (index (sub #uint8 #tmpLen (nat_to_intseq_be #U8 #SEC tmpLen (bn_v b)) (tmpLen - len) len) i ==
index #uint8 #len (nat_to_intseq_be #U8 #SEC len (bn_v b)) i) =
let rp = nat_to_intseq_be #U8 #SEC len (bn_v b) in
index_nat_to_intseq_be #U8 #SEC len (bn_v b) (len - i - 1);
assert (index #uint8 #len rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
let lp = nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) in
assert (index (sub #uint8 #tmpLen lp (tmpLen - len) len) i == index #uint8 #tmpLen lp (tmpLen - len + i));
index_nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) (len - i - 1);
assert (index #uint8 #tmpLen lp (tmpLen - len + i) == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
() in
Classical.forall_intro lemma_aux;
eq_intro (nat_to_intseq_be #U8 #SEC len (bn_v b)) res
(* Little-endian *)
val bn_v_is_nat_from_intseq_le_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_le b)
let rec bn_v_is_nat_from_intseq_le_lemma #t len b =
if len = 0 then
bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_le_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_le b1);
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v b == nat_from_intseq_le b1 + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_le_slice_lemma b (len - 1);
nat_from_intseq_le_lemma0 (slice b (len - 1) len);
assert (nat_from_intseq_le b == nat_from_intseq_le b1 + pow2 ((len - 1) * bits t) * v b.[len - 1]) end
val lemma_nat_from_bytes_le_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_le b == 0) | false | false | Hacl.Spec.Bignum.Convert.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 lemma_nat_from_bytes_le_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_le b == 0) | [
"recursion"
] | Hacl.Spec.Bignum.Convert.lemma_nat_from_bytes_le_zeroes | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_nat -> b: Lib.Sequence.lseq Lib.IntTypes.uint8 len
-> FStar.Pervasives.Lemma
(requires forall (i: Prims.nat). i < len ==> b.[ i ] == Lib.IntTypes.u8 0)
(ensures Lib.ByteSequence.nat_from_intseq_le b == 0) | {
"end_col": 62,
"end_line": 397,
"start_col": 2,
"start_line": 393
} |
FStar.Pervasives.Lemma | val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1) | val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x = | false | null | true | let b = create len (uint #t 0) in
let b = b.[ 0 ] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Definitions.bn_eval1",
"Lib.Sequence.slice",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.nat",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.op_Subtraction",
"Hacl.Spec.Bignum.Definitions.bn_eval_zeroes",
"Lib.Sequence.eq_intro",
"Lib.Sequence.create",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Prims.int",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.IntTypes.bits",
"Hacl.Spec.Bignum.Definitions.bn_eval_split_i",
"Lib.Sequence.lseq",
"Prims.l_and",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.upd",
"Lib.Sequence.index",
"Prims.l_Forall",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_imp",
"Prims.op_LessThan",
"Prims.op_disEquality",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.op_String_Assignment",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x) | [] | Hacl.Spec.Bignum.Convert.bn_from_uint_lemma | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_pos -> x: Hacl.Spec.Bignum.Definitions.limb t
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.Convert.bn_from_uint len x) ==
Lib.IntTypes.uint_v x) | {
"end_col": 24,
"end_line": 30,
"start_col": 33,
"start_line": 22
} |
Prims.Tot | val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp | val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b = | false | null | false | let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Hacl.Spec.Bignum.Convert.bn_from_bytes_be_",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.l_and",
"Prims.eq2",
"Lib.Sequence.sub",
"Prims.op_Subtraction",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_or",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_imp",
"Lib.Sequence.create",
"Lib.IntTypes.u8",
"Prims.int",
"Prims.pos",
"Prims.pow2",
"Prims.op_Multiply",
"Hacl.Spec.Bignum.Definitions.lbignum"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t)) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t)) | [] | Hacl.Spec.Bignum.Convert.bn_from_bytes_be | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len:
Lib.IntTypes.size_pos
{ Lib.IntTypes.numbytes t *
Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <=
Lib.IntTypes.max_size_t } ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 len
-> Hacl.Spec.Bignum.Definitions.lbignum t
(Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t)) | {
"end_col": 29,
"end_line": 65,
"start_col": 31,
"start_line": 60
} |
Prims.Tot | val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp | val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b = | false | null | false | let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Lib.ByteSequence.uints_from_bytes_le",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Prims.l_and",
"Prims.eq2",
"Lib.Sequence.sub",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_or",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_imp",
"Lib.Sequence.create",
"Lib.IntTypes.u8",
"Prims.int",
"Prims.pos",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_Multiply",
"Hacl.Spec.Bignum.Definitions.lbignum"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t)) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t)) | [] | Hacl.Spec.Bignum.Convert.bn_from_bytes_le | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len:
Lib.IntTypes.size_pos
{ Lib.IntTypes.numbytes t *
Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <=
Lib.IntTypes.max_size_t } ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 len
-> Hacl.Spec.Bignum.Definitions.lbignum t
(Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t)) | {
"end_col": 25,
"end_line": 79,
"start_col": 31,
"start_line": 74
} |
FStar.Pervasives.Lemma | val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end | val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b = | false | null | true | if len = 0
then ()
else
(nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len - 1) (slice b 1 len)) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Hacl.Spec.Bignum.Convert.lemma_nat_from_bytes_be_zeroes",
"Prims.op_Subtraction",
"Lib.Sequence.slice",
"Prims.unit",
"Lib.ByteSequence.nat_from_intseq_be_lemma0",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.ByteSequence.nat_from_intseq_be_slice_lemma"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0) | false | false | Hacl.Spec.Bignum.Convert.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 lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0) | [
"recursion"
] | Hacl.Spec.Bignum.Convert.lemma_nat_from_bytes_be_zeroes | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_nat -> b: Lib.Sequence.lseq Lib.IntTypes.uint8 len
-> FStar.Pervasives.Lemma
(requires forall (i: Prims.nat). i < len ==> b.[ i ] == Lib.IntTypes.u8 0)
(ensures Lib.ByteSequence.nat_from_intseq_be b == 0) | {
"end_col": 62,
"end_line": 223,
"start_col": 2,
"start_line": 219
} |
FStar.Pervasives.Lemma | val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b | val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b = | false | null | true | let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Hacl.Spec.Bignum.Convert.nat_from_bytes_be_eq_lemma",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.nat",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Hacl.Spec.Bignum.Convert.bn_from_bytes_be_",
"Lib.ByteSequence.nat_from_bytes_be",
"Lib.IntTypes.SEC",
"Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma_",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Prims.l_and",
"Lib.Sequence.sub",
"Prims.op_Subtraction",
"Prims.l_Forall",
"Prims.l_or",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_imp",
"Lib.Sequence.create",
"Lib.IntTypes.u8",
"Prims.int",
"Prims.pos",
"Prims.pow2",
"Prims.op_Multiply"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b) | [] | Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len:
Lib.IntTypes.size_pos
{ Lib.IntTypes.numbytes t *
Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <=
Lib.IntTypes.max_size_t } ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 len
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.Convert.bn_from_bytes_be len b) ==
Lib.ByteSequence.nat_from_bytes_be b) | {
"end_col": 41,
"end_line": 255,
"start_col": 37,
"start_line": 247
} |
FStar.Pervasives.Lemma | val bn_v_is_nat_from_intseq_le_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_le b) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec bn_v_is_nat_from_intseq_le_lemma #t len b =
if len = 0 then
bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_le_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_le b1);
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v b == nat_from_intseq_le b1 + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_le_slice_lemma b (len - 1);
nat_from_intseq_le_lemma0 (slice b (len - 1) len);
assert (nat_from_intseq_le b == nat_from_intseq_le b1 + pow2 ((len - 1) * bits t) * v b.[len - 1]) end | val bn_v_is_nat_from_intseq_le_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_le b)
let rec bn_v_is_nat_from_intseq_le_lemma #t len b = | false | null | true | if len = 0
then bn_eval0 b
else
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_le_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_le b1);
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v b == nat_from_intseq_le b1 + pow2 (bits t * (len - 1)) * v b.[ len - 1 ]);
nat_from_intseq_le_slice_lemma b (len - 1);
nat_from_intseq_le_lemma0 (slice b (len - 1) len);
assert (nat_from_intseq_le b ==
nat_from_intseq_le b1 + pow2 ((len - 1) * bits t) * v b.[ len - 1 ]) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.op_Equality",
"Prims.int",
"Hacl.Spec.Bignum.Definitions.bn_eval0",
"Prims.bool",
"Prims._assert",
"Prims.eq2",
"Lib.ByteSequence.nat_from_intseq_le",
"Lib.IntTypes.SEC",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.op_Subtraction",
"Lib.IntTypes.bits",
"Lib.IntTypes.v",
"Lib.Sequence.op_String_Access",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.unit",
"Lib.ByteSequence.nat_from_intseq_le_lemma0",
"Lib.Sequence.slice",
"Lib.ByteSequence.nat_from_intseq_le_slice_lemma",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Hacl.Spec.Bignum.Definitions.bn_eval_unfold_i",
"Hacl.Spec.Bignum.Definitions.bn_eval_split_i",
"Prims.nat",
"Hacl.Spec.Bignum.Convert.bn_v_is_nat_from_intseq_le_lemma",
"Lib.Sequence.lseq",
"Prims.l_and",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Prims.l_Forall",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.index"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b
val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
let index_bn_to_bytes_be_ #t len b i =
let numb = numbytes t in
let bi = b.[len - i / numb - 1] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[i] == (uint_to_bytes_be bi).[i % numb]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[i % numb] == uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)
let bn_to_bytes_be_lemma_aux #t len b i =
let pbits = bits t in
let numb = numbytes t in
let e = numb - 1 - i % numb in
let e1 = len - i / numb - 1 in
let e2 = numb * len - 1 - i in
calc (==) {
v b.[e1] / pow2 (8 * e) % pow2 8;
(==) { bn_eval_index b e1 }
(bn_v b / pow2 (pbits * e1) % pow2 (pbits)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (pbits * e1) (pbits + pbits * e1) }
(bn_v b % pow2 (pbits + pbits * e1) / pow2 (pbits * e1)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.division_multiplication_lemma (bn_v b % pow2 (pbits + pbits * e1)) (pow2 (pbits * e1)) (pow2 (8 * e)) }
(bn_v b % pow2 (pbits + pbits * e1)) / (pow2 (pbits * e1) * pow2 (8 * e)) % pow2 8;
(==) { Math.Lemmas.pow2_plus (pbits * e1) (8 * e) }
(bn_v b % pow2 (pbits + pbits * e1)) / pow2 (pbits * e1 + 8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (8 * e2) (pbits + pbits * e1) }
(bn_v b / pow2 (8 * e2)) % pow2 (pbits + pbits * e1 - 8 * e2) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 (bn_v b / pow2 (8 * e2)) 8 (pbits + pbits * e1 - 8 * e2) }
(bn_v b / pow2 (8 * (numb * len - i - 1))) % pow2 8;
}
val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b))
let bn_to_bytes_be_lemma_ #t len b =
let numb = numbytes t in
let lemma_aux (i:nat{i < numb * len}) :
Lemma ((bn_to_bytes_be_ #t len b).[i] == index #uint8 #(numb * len) (nat_to_intseq_be (numb * len) (bn_v b)) i)
=
let rp = nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) in
index_nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) (numb * len - i - 1);
assert (index #uint8 #(numb * len) rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8));
index_bn_to_bytes_be_ len b i;
assert ((bn_to_bytes_be_ #t len b).[i] == uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8));
bn_to_bytes_be_lemma_aux len b i;
() in
Classical.forall_intro lemma_aux;
eq_intro (bn_to_bytes_be_ len b) (nat_to_intseq_be (numb * len) (bn_v b))
val bn_to_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_be #t len b == nat_to_intseq_be #U8 #SEC len (bn_v b))
let bn_to_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
let res = sub tmp (tmpLen - len) len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
bn_to_bytes_be_lemma_ bnLen b;
assert (tmp == nat_to_intseq_be #U8 #SEC tmpLen (bn_v b));
let lemma_aux (i:nat{i < len}) :
Lemma (index (sub #uint8 #tmpLen (nat_to_intseq_be #U8 #SEC tmpLen (bn_v b)) (tmpLen - len) len) i ==
index #uint8 #len (nat_to_intseq_be #U8 #SEC len (bn_v b)) i) =
let rp = nat_to_intseq_be #U8 #SEC len (bn_v b) in
index_nat_to_intseq_be #U8 #SEC len (bn_v b) (len - i - 1);
assert (index #uint8 #len rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
let lp = nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) in
assert (index (sub #uint8 #tmpLen lp (tmpLen - len) len) i == index #uint8 #tmpLen lp (tmpLen - len + i));
index_nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) (len - i - 1);
assert (index #uint8 #tmpLen lp (tmpLen - len + i) == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
() in
Classical.forall_intro lemma_aux;
eq_intro (nat_to_intseq_be #U8 #SEC len (bn_v b)) res
(* Little-endian *)
val bn_v_is_nat_from_intseq_le_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_le b) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_v_is_nat_from_intseq_le_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_le b) | [
"recursion"
] | Hacl.Spec.Bignum.Convert.bn_v_is_nat_from_intseq_le_lemma | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_nat -> b: Hacl.Spec.Bignum.Definitions.lbignum t len
-> FStar.Pervasives.Lemma
(ensures Hacl.Spec.Bignum.Definitions.bn_v b == Lib.ByteSequence.nat_from_intseq_le b) | {
"end_col": 106,
"end_line": 385,
"start_col": 2,
"start_line": 372
} |
FStar.Pervasives.Lemma | val bn_from_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_le #t len b) == nat_from_bytes_le b) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_bytes_le_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
let res = uints_from_bytes_le #t #SEC #bnLen tmp in
uints_from_bytes_le_nat_lemma #t #SEC #bnLen tmp;
bn_v_is_nat_from_intseq_le_lemma bnLen res;
nat_from_bytes_le_eq_lemma len tmpLen b | val bn_from_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_le #t len b) == nat_from_bytes_le b)
let bn_from_bytes_le_lemma #t len b = | false | null | true | let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
let res = uints_from_bytes_le #t #SEC #bnLen tmp in
uints_from_bytes_le_nat_lemma #t #SEC #bnLen tmp;
bn_v_is_nat_from_intseq_le_lemma bnLen res;
nat_from_bytes_le_eq_lemma len tmpLen b | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Hacl.Spec.Bignum.Convert.nat_from_bytes_le_eq_lemma",
"Prims.unit",
"Hacl.Spec.Bignum.Convert.bn_v_is_nat_from_intseq_le_lemma",
"Lib.ByteSequence.uints_from_bytes_le_nat_lemma",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int_t",
"Lib.ByteSequence.uints_from_bytes_le",
"Lib.IntTypes.U8",
"Prims.l_and",
"Prims.eq2",
"Lib.Sequence.sub",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_or",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_imp",
"Lib.Sequence.create",
"Lib.IntTypes.u8",
"Prims.int",
"Prims.pos",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_Multiply"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b
val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
let index_bn_to_bytes_be_ #t len b i =
let numb = numbytes t in
let bi = b.[len - i / numb - 1] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[i] == (uint_to_bytes_be bi).[i % numb]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[i % numb] == uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)
let bn_to_bytes_be_lemma_aux #t len b i =
let pbits = bits t in
let numb = numbytes t in
let e = numb - 1 - i % numb in
let e1 = len - i / numb - 1 in
let e2 = numb * len - 1 - i in
calc (==) {
v b.[e1] / pow2 (8 * e) % pow2 8;
(==) { bn_eval_index b e1 }
(bn_v b / pow2 (pbits * e1) % pow2 (pbits)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (pbits * e1) (pbits + pbits * e1) }
(bn_v b % pow2 (pbits + pbits * e1) / pow2 (pbits * e1)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.division_multiplication_lemma (bn_v b % pow2 (pbits + pbits * e1)) (pow2 (pbits * e1)) (pow2 (8 * e)) }
(bn_v b % pow2 (pbits + pbits * e1)) / (pow2 (pbits * e1) * pow2 (8 * e)) % pow2 8;
(==) { Math.Lemmas.pow2_plus (pbits * e1) (8 * e) }
(bn_v b % pow2 (pbits + pbits * e1)) / pow2 (pbits * e1 + 8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (8 * e2) (pbits + pbits * e1) }
(bn_v b / pow2 (8 * e2)) % pow2 (pbits + pbits * e1 - 8 * e2) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 (bn_v b / pow2 (8 * e2)) 8 (pbits + pbits * e1 - 8 * e2) }
(bn_v b / pow2 (8 * (numb * len - i - 1))) % pow2 8;
}
val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b))
let bn_to_bytes_be_lemma_ #t len b =
let numb = numbytes t in
let lemma_aux (i:nat{i < numb * len}) :
Lemma ((bn_to_bytes_be_ #t len b).[i] == index #uint8 #(numb * len) (nat_to_intseq_be (numb * len) (bn_v b)) i)
=
let rp = nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) in
index_nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) (numb * len - i - 1);
assert (index #uint8 #(numb * len) rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8));
index_bn_to_bytes_be_ len b i;
assert ((bn_to_bytes_be_ #t len b).[i] == uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8));
bn_to_bytes_be_lemma_aux len b i;
() in
Classical.forall_intro lemma_aux;
eq_intro (bn_to_bytes_be_ len b) (nat_to_intseq_be (numb * len) (bn_v b))
val bn_to_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_be #t len b == nat_to_intseq_be #U8 #SEC len (bn_v b))
let bn_to_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
let res = sub tmp (tmpLen - len) len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
bn_to_bytes_be_lemma_ bnLen b;
assert (tmp == nat_to_intseq_be #U8 #SEC tmpLen (bn_v b));
let lemma_aux (i:nat{i < len}) :
Lemma (index (sub #uint8 #tmpLen (nat_to_intseq_be #U8 #SEC tmpLen (bn_v b)) (tmpLen - len) len) i ==
index #uint8 #len (nat_to_intseq_be #U8 #SEC len (bn_v b)) i) =
let rp = nat_to_intseq_be #U8 #SEC len (bn_v b) in
index_nat_to_intseq_be #U8 #SEC len (bn_v b) (len - i - 1);
assert (index #uint8 #len rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
let lp = nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) in
assert (index (sub #uint8 #tmpLen lp (tmpLen - len) len) i == index #uint8 #tmpLen lp (tmpLen - len + i));
index_nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) (len - i - 1);
assert (index #uint8 #tmpLen lp (tmpLen - len + i) == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
() in
Classical.forall_intro lemma_aux;
eq_intro (nat_to_intseq_be #U8 #SEC len (bn_v b)) res
(* Little-endian *)
val bn_v_is_nat_from_intseq_le_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_le b)
let rec bn_v_is_nat_from_intseq_le_lemma #t len b =
if len = 0 then
bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_le_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_le b1);
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v b == nat_from_intseq_le b1 + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_le_slice_lemma b (len - 1);
nat_from_intseq_le_lemma0 (slice b (len - 1) len);
assert (nat_from_intseq_le b == nat_from_intseq_le b1 + pow2 ((len - 1) * bits t) * v b.[len - 1]) end
val lemma_nat_from_bytes_le_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_le b == 0)
let rec lemma_nat_from_bytes_le_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_le_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_le_lemma0 (slice b 0 1);
lemma_nat_from_bytes_le_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_le_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 -> Lemma
(let tmp = create len (u8 0) in
nat_from_intseq_le b == nat_from_intseq_le (update_sub tmp 0 len0 b))
let nat_from_bytes_le_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp 0 len0 b in
assert (slice r 0 len0 == b);
assert (forall (i:nat). i < len - len0 ==> r.[len0 + i] == u8 0);
nat_from_intseq_le_slice_lemma #U8 #SEC #len r len0;
assert (nat_from_intseq_le r == nat_from_intseq_le (slice r 0 len0) + pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
assert (nat_from_intseq_le r == nat_from_intseq_le b + pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
lemma_nat_from_bytes_le_zeroes (len - len0) (Seq.slice r len0 len)
val bn_from_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_le #t len b) == nat_from_bytes_le b) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_le #t len b) == nat_from_bytes_le b) | [] | Hacl.Spec.Bignum.Convert.bn_from_bytes_le_lemma | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len:
Lib.IntTypes.size_pos
{ Lib.IntTypes.numbytes t *
Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <=
Lib.IntTypes.max_size_t } ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 len
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.Convert.bn_from_bytes_le len b) ==
Lib.ByteSequence.nat_from_bytes_le b) | {
"end_col": 41,
"end_line": 429,
"start_col": 37,
"start_line": 421
} |
FStar.Pervasives.Lemma | val nat_from_bytes_le_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 -> Lemma
(let tmp = create len (u8 0) in
nat_from_intseq_le b == nat_from_intseq_le (update_sub tmp 0 len0 b)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat_from_bytes_le_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp 0 len0 b in
assert (slice r 0 len0 == b);
assert (forall (i:nat). i < len - len0 ==> r.[len0 + i] == u8 0);
nat_from_intseq_le_slice_lemma #U8 #SEC #len r len0;
assert (nat_from_intseq_le r == nat_from_intseq_le (slice r 0 len0) + pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
assert (nat_from_intseq_le r == nat_from_intseq_le b + pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
lemma_nat_from_bytes_le_zeroes (len - len0) (Seq.slice r len0 len) | val nat_from_bytes_le_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 -> Lemma
(let tmp = create len (u8 0) in
nat_from_intseq_le b == nat_from_intseq_le (update_sub tmp 0 len0 b))
let nat_from_bytes_le_eq_lemma len0 len b = | false | null | true | let tmp = create len (u8 0) in
let r = update_sub tmp 0 len0 b in
assert (slice r 0 len0 == b);
assert (forall (i: nat). i < len - len0 ==> r.[ len0 + i ] == u8 0);
nat_from_intseq_le_slice_lemma #U8 #SEC #len r len0;
assert (nat_from_intseq_le r ==
nat_from_intseq_le (slice r 0 len0) +
pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
assert (nat_from_intseq_le r ==
nat_from_intseq_le b + pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
lemma_nat_from_bytes_le_zeroes (len - len0) (Seq.slice r len0 len) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Hacl.Spec.Bignum.Convert.lemma_nat_from_bytes_le_zeroes",
"Prims.op_Subtraction",
"FStar.Seq.Base.slice",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Lib.ByteSequence.nat_from_intseq_le",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.Sequence.slice",
"Lib.ByteSequence.nat_from_intseq_le_slice_lemma",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.op_LessThan",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.IntTypes.range_t",
"Lib.IntTypes.v",
"Lib.Sequence.op_String_Access",
"Lib.IntTypes.u8",
"Lib.Sequence.seq",
"Prims.l_and",
"FStar.Seq.Base.length",
"FStar.Seq.Base.seq",
"Lib.Sequence.index",
"Lib.IntTypes.int_t",
"Lib.Sequence.sub",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Lib.Sequence.create"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b
val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
let index_bn_to_bytes_be_ #t len b i =
let numb = numbytes t in
let bi = b.[len - i / numb - 1] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[i] == (uint_to_bytes_be bi).[i % numb]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[i % numb] == uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)
let bn_to_bytes_be_lemma_aux #t len b i =
let pbits = bits t in
let numb = numbytes t in
let e = numb - 1 - i % numb in
let e1 = len - i / numb - 1 in
let e2 = numb * len - 1 - i in
calc (==) {
v b.[e1] / pow2 (8 * e) % pow2 8;
(==) { bn_eval_index b e1 }
(bn_v b / pow2 (pbits * e1) % pow2 (pbits)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (pbits * e1) (pbits + pbits * e1) }
(bn_v b % pow2 (pbits + pbits * e1) / pow2 (pbits * e1)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.division_multiplication_lemma (bn_v b % pow2 (pbits + pbits * e1)) (pow2 (pbits * e1)) (pow2 (8 * e)) }
(bn_v b % pow2 (pbits + pbits * e1)) / (pow2 (pbits * e1) * pow2 (8 * e)) % pow2 8;
(==) { Math.Lemmas.pow2_plus (pbits * e1) (8 * e) }
(bn_v b % pow2 (pbits + pbits * e1)) / pow2 (pbits * e1 + 8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (8 * e2) (pbits + pbits * e1) }
(bn_v b / pow2 (8 * e2)) % pow2 (pbits + pbits * e1 - 8 * e2) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 (bn_v b / pow2 (8 * e2)) 8 (pbits + pbits * e1 - 8 * e2) }
(bn_v b / pow2 (8 * (numb * len - i - 1))) % pow2 8;
}
val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b))
let bn_to_bytes_be_lemma_ #t len b =
let numb = numbytes t in
let lemma_aux (i:nat{i < numb * len}) :
Lemma ((bn_to_bytes_be_ #t len b).[i] == index #uint8 #(numb * len) (nat_to_intseq_be (numb * len) (bn_v b)) i)
=
let rp = nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) in
index_nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) (numb * len - i - 1);
assert (index #uint8 #(numb * len) rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8));
index_bn_to_bytes_be_ len b i;
assert ((bn_to_bytes_be_ #t len b).[i] == uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8));
bn_to_bytes_be_lemma_aux len b i;
() in
Classical.forall_intro lemma_aux;
eq_intro (bn_to_bytes_be_ len b) (nat_to_intseq_be (numb * len) (bn_v b))
val bn_to_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_be #t len b == nat_to_intseq_be #U8 #SEC len (bn_v b))
let bn_to_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
let res = sub tmp (tmpLen - len) len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
bn_to_bytes_be_lemma_ bnLen b;
assert (tmp == nat_to_intseq_be #U8 #SEC tmpLen (bn_v b));
let lemma_aux (i:nat{i < len}) :
Lemma (index (sub #uint8 #tmpLen (nat_to_intseq_be #U8 #SEC tmpLen (bn_v b)) (tmpLen - len) len) i ==
index #uint8 #len (nat_to_intseq_be #U8 #SEC len (bn_v b)) i) =
let rp = nat_to_intseq_be #U8 #SEC len (bn_v b) in
index_nat_to_intseq_be #U8 #SEC len (bn_v b) (len - i - 1);
assert (index #uint8 #len rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
let lp = nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) in
assert (index (sub #uint8 #tmpLen lp (tmpLen - len) len) i == index #uint8 #tmpLen lp (tmpLen - len + i));
index_nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) (len - i - 1);
assert (index #uint8 #tmpLen lp (tmpLen - len + i) == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
() in
Classical.forall_intro lemma_aux;
eq_intro (nat_to_intseq_be #U8 #SEC len (bn_v b)) res
(* Little-endian *)
val bn_v_is_nat_from_intseq_le_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_le b)
let rec bn_v_is_nat_from_intseq_le_lemma #t len b =
if len = 0 then
bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_le_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_le b1);
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v b == nat_from_intseq_le b1 + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_le_slice_lemma b (len - 1);
nat_from_intseq_le_lemma0 (slice b (len - 1) len);
assert (nat_from_intseq_le b == nat_from_intseq_le b1 + pow2 ((len - 1) * bits t) * v b.[len - 1]) end
val lemma_nat_from_bytes_le_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_le b == 0)
let rec lemma_nat_from_bytes_le_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_le_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_le_lemma0 (slice b 0 1);
lemma_nat_from_bytes_le_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_le_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 -> Lemma
(let tmp = create len (u8 0) in
nat_from_intseq_le b == nat_from_intseq_le (update_sub tmp 0 len0 b)) | false | false | Hacl.Spec.Bignum.Convert.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 nat_from_bytes_le_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 -> Lemma
(let tmp = create len (u8 0) in
nat_from_intseq_le b == nat_from_intseq_le (update_sub tmp 0 len0 b)) | [] | Hacl.Spec.Bignum.Convert.nat_from_bytes_le_eq_lemma | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len0: Lib.IntTypes.size_nat ->
len: Lib.IntTypes.size_nat{len0 <= len} ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 len0
-> FStar.Pervasives.Lemma
(ensures
(let tmp = Lib.Sequence.create len (Lib.IntTypes.u8 0) in
Lib.ByteSequence.nat_from_intseq_le b ==
Lib.ByteSequence.nat_from_intseq_le (Lib.Sequence.update_sub tmp 0 len0 b))) | {
"end_col": 68,
"end_line": 412,
"start_col": 43,
"start_line": 404
} |
FStar.Pervasives.Lemma | val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b)) | val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b = | false | null | true | let lemma_aux (i: nat{i < len})
: Lemma ((bn_from_bytes_be_ len b).[ i ] == (reverse #t #len (uints_from_bytes_be b)).[ i ]) =
index_uints_from_bytes_be #t #SEC #len b (len - i - 1)
in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b)) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Lib.Sequence.eq_intro",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Convert.bn_from_bytes_be_",
"Hacl.Spec.Bignum.Convert.reverse",
"Lib.ByteSequence.uints_from_bytes_be",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.op_String_Access",
"Prims.l_True",
"Prims.squash",
"Lib.Sequence.index",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Lib.ByteSequence.index_uints_from_bytes_be",
"Prims.op_Subtraction"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b)) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b)) | [] | Hacl.Spec.Bignum.Convert.bn_from_bytes_be_is_uints_from_bytes_be_reverse | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat{Lib.IntTypes.numbytes t * len <= Lib.IntTypes.max_size_t} ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.numbytes t * len)
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_ len b ==
Hacl.Spec.Bignum.Convert.reverse (Lib.ByteSequence.uints_from_bytes_be b)) | {
"end_col": 70,
"end_line": 171,
"start_col": 62,
"start_line": 164
} |
FStar.Pervasives.Lemma | val bn_from_bytes_le_is_uints_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t /\ len % numbytes t = 0}
-> b:lseq uint8 len ->
Lemma (bn_from_bytes_le #t len b == uints_from_bytes_le b) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_bytes_le_is_uints_from_bytes_le #t len b =
let lp = bn_from_bytes_le #t len b in
let rp = uints_from_bytes_le #t #SEC #(len / numbytes t) b in
//uints_from_bytes_le_nat_lemma #t #SEC #(len / numbytes t) b;
//assert (nat_from_intseq_le rp == nat_from_bytes_le b);
//bn_from_bytes_le_lemma #t len b;
//assert (bn_v lp == nat_from_bytes_le b);
//assert (nat_from_intseq_le rp == bn_v lp);
assert (bn_v rp == bn_v lp);
bn_eval_inj (len / numbytes t) rp lp | val bn_from_bytes_le_is_uints_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t /\ len % numbytes t = 0}
-> b:lseq uint8 len ->
Lemma (bn_from_bytes_le #t len b == uints_from_bytes_le b)
let bn_from_bytes_le_is_uints_from_bytes_le #t len b = | false | null | true | let lp = bn_from_bytes_le #t len b in
let rp = uints_from_bytes_le #t #SEC #(len / numbytes t) b in
assert (bn_v rp == bn_v lp);
bn_eval_inj (len / numbytes t) rp lp | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.max_size_t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Hacl.Spec.Bignum.Definitions.bn_eval_inj",
"Prims.op_Division",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.nat",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.ByteSequence.uints_from_bytes_le",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Convert.bn_from_bytes_le"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b
val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
let index_bn_to_bytes_be_ #t len b i =
let numb = numbytes t in
let bi = b.[len - i / numb - 1] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[i] == (uint_to_bytes_be bi).[i % numb]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[i % numb] == uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)
let bn_to_bytes_be_lemma_aux #t len b i =
let pbits = bits t in
let numb = numbytes t in
let e = numb - 1 - i % numb in
let e1 = len - i / numb - 1 in
let e2 = numb * len - 1 - i in
calc (==) {
v b.[e1] / pow2 (8 * e) % pow2 8;
(==) { bn_eval_index b e1 }
(bn_v b / pow2 (pbits * e1) % pow2 (pbits)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (pbits * e1) (pbits + pbits * e1) }
(bn_v b % pow2 (pbits + pbits * e1) / pow2 (pbits * e1)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.division_multiplication_lemma (bn_v b % pow2 (pbits + pbits * e1)) (pow2 (pbits * e1)) (pow2 (8 * e)) }
(bn_v b % pow2 (pbits + pbits * e1)) / (pow2 (pbits * e1) * pow2 (8 * e)) % pow2 8;
(==) { Math.Lemmas.pow2_plus (pbits * e1) (8 * e) }
(bn_v b % pow2 (pbits + pbits * e1)) / pow2 (pbits * e1 + 8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (8 * e2) (pbits + pbits * e1) }
(bn_v b / pow2 (8 * e2)) % pow2 (pbits + pbits * e1 - 8 * e2) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 (bn_v b / pow2 (8 * e2)) 8 (pbits + pbits * e1 - 8 * e2) }
(bn_v b / pow2 (8 * (numb * len - i - 1))) % pow2 8;
}
val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b))
let bn_to_bytes_be_lemma_ #t len b =
let numb = numbytes t in
let lemma_aux (i:nat{i < numb * len}) :
Lemma ((bn_to_bytes_be_ #t len b).[i] == index #uint8 #(numb * len) (nat_to_intseq_be (numb * len) (bn_v b)) i)
=
let rp = nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) in
index_nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) (numb * len - i - 1);
assert (index #uint8 #(numb * len) rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8));
index_bn_to_bytes_be_ len b i;
assert ((bn_to_bytes_be_ #t len b).[i] == uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8));
bn_to_bytes_be_lemma_aux len b i;
() in
Classical.forall_intro lemma_aux;
eq_intro (bn_to_bytes_be_ len b) (nat_to_intseq_be (numb * len) (bn_v b))
val bn_to_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_be #t len b == nat_to_intseq_be #U8 #SEC len (bn_v b))
let bn_to_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
let res = sub tmp (tmpLen - len) len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
bn_to_bytes_be_lemma_ bnLen b;
assert (tmp == nat_to_intseq_be #U8 #SEC tmpLen (bn_v b));
let lemma_aux (i:nat{i < len}) :
Lemma (index (sub #uint8 #tmpLen (nat_to_intseq_be #U8 #SEC tmpLen (bn_v b)) (tmpLen - len) len) i ==
index #uint8 #len (nat_to_intseq_be #U8 #SEC len (bn_v b)) i) =
let rp = nat_to_intseq_be #U8 #SEC len (bn_v b) in
index_nat_to_intseq_be #U8 #SEC len (bn_v b) (len - i - 1);
assert (index #uint8 #len rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
let lp = nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) in
assert (index (sub #uint8 #tmpLen lp (tmpLen - len) len) i == index #uint8 #tmpLen lp (tmpLen - len + i));
index_nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) (len - i - 1);
assert (index #uint8 #tmpLen lp (tmpLen - len + i) == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
() in
Classical.forall_intro lemma_aux;
eq_intro (nat_to_intseq_be #U8 #SEC len (bn_v b)) res
(* Little-endian *)
val bn_v_is_nat_from_intseq_le_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_le b)
let rec bn_v_is_nat_from_intseq_le_lemma #t len b =
if len = 0 then
bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_le_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_le b1);
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v b == nat_from_intseq_le b1 + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_le_slice_lemma b (len - 1);
nat_from_intseq_le_lemma0 (slice b (len - 1) len);
assert (nat_from_intseq_le b == nat_from_intseq_le b1 + pow2 ((len - 1) * bits t) * v b.[len - 1]) end
val lemma_nat_from_bytes_le_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_le b == 0)
let rec lemma_nat_from_bytes_le_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_le_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_le_lemma0 (slice b 0 1);
lemma_nat_from_bytes_le_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_le_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 -> Lemma
(let tmp = create len (u8 0) in
nat_from_intseq_le b == nat_from_intseq_le (update_sub tmp 0 len0 b))
let nat_from_bytes_le_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp 0 len0 b in
assert (slice r 0 len0 == b);
assert (forall (i:nat). i < len - len0 ==> r.[len0 + i] == u8 0);
nat_from_intseq_le_slice_lemma #U8 #SEC #len r len0;
assert (nat_from_intseq_le r == nat_from_intseq_le (slice r 0 len0) + pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
assert (nat_from_intseq_le r == nat_from_intseq_le b + pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
lemma_nat_from_bytes_le_zeroes (len - len0) (Seq.slice r len0 len)
val bn_from_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_le #t len b) == nat_from_bytes_le b)
let bn_from_bytes_le_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
let res = uints_from_bytes_le #t #SEC #bnLen tmp in
uints_from_bytes_le_nat_lemma #t #SEC #bnLen tmp;
bn_v_is_nat_from_intseq_le_lemma bnLen res;
nat_from_bytes_le_eq_lemma len tmpLen b
val bn_to_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_le len b == nat_to_intseq_le #U8 len (bn_v b))
let bn_to_bytes_le_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
let res = sub tmp 0 len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
uints_to_bytes_le_nat_lemma #t #SEC bnLen (bn_v b);
bn_v_is_nat_from_intseq_le_lemma bnLen b;
lemma_nat_from_to_intseq_le_preserves_value bnLen b;
assert (uints_to_bytes_le #t #SEC #bnLen b == nat_to_intseq_le #U8 tmpLen (bn_v b));
let aux (i:nat{i < len}) :
Lemma (index #uint8 #tmpLen (nat_to_intseq_le #U8 tmpLen (bn_v b)) i ==
index #uint8 #len (nat_to_intseq_le #U8 len (bn_v b)) i) =
index_nat_to_intseq_le #U8 #SEC tmpLen (bn_v b) i;
index_nat_to_intseq_le #U8 #SEC len (bn_v b) i in
Classical.forall_intro aux;
eq_intro (nat_to_intseq_le #U8 #SEC len (bn_v b)) res
val bn_from_bytes_le_is_uints_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t /\ len % numbytes t = 0}
-> b:lseq uint8 len ->
Lemma (bn_from_bytes_le #t len b == uints_from_bytes_le b) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_bytes_le_is_uints_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t /\ len % numbytes t = 0}
-> b:lseq uint8 len ->
Lemma (bn_from_bytes_le #t len b == uints_from_bytes_le b) | [] | Hacl.Spec.Bignum.Convert.bn_from_bytes_le_is_uints_from_bytes_le | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len:
Lib.IntTypes.size_pos
{ Lib.IntTypes.numbytes t *
Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <=
Lib.IntTypes.max_size_t /\ len % Lib.IntTypes.numbytes t = 0 } ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 len
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Convert.bn_from_bytes_le len b == Lib.ByteSequence.uints_from_bytes_le b) | {
"end_col": 38,
"end_line": 478,
"start_col": 54,
"start_line": 468
} |
FStar.Pervasives.Lemma | val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0)) | val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b = | false | null | true | let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i: nat). i < len - len0 ==> r.[ i ] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r ==
nat_from_intseq_be (slice r (len - len0) len) +
pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r ==
nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0)) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Hacl.Spec.Bignum.Convert.lemma_nat_from_bytes_be_zeroes",
"Prims.op_Subtraction",
"FStar.Seq.Base.slice",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Lib.ByteSequence.nat_from_intseq_be",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.Sequence.slice",
"Lib.ByteSequence.nat_from_intseq_be_slice_lemma",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.op_LessThan",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.IntTypes.range_t",
"Lib.IntTypes.v",
"Lib.Sequence.op_String_Access",
"Lib.IntTypes.u8",
"Lib.Sequence.seq",
"Prims.l_and",
"FStar.Seq.Base.length",
"FStar.Seq.Base.seq",
"Lib.Sequence.index",
"Lib.IntTypes.int_t",
"Lib.Sequence.sub",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Lib.Sequence.create"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b)) | false | false | Hacl.Spec.Bignum.Convert.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 nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b)) | [] | Hacl.Spec.Bignum.Convert.nat_from_bytes_be_eq_lemma | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len0: Lib.IntTypes.size_nat ->
len: Lib.IntTypes.size_nat{len0 <= len} ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 len0
-> FStar.Pervasives.Lemma
(ensures
(let tmp = Lib.Sequence.create len (Lib.IntTypes.u8 0) in
Lib.ByteSequence.nat_from_intseq_be b ==
Lib.ByteSequence.nat_from_intseq_be (Lib.Sequence.update_sub tmp (len - len0) len0 b))) | {
"end_col": 74,
"end_line": 238,
"start_col": 43,
"start_line": 230
} |
FStar.Pervasives.Lemma | val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let index_bn_to_bytes_be_ #t len b i =
let numb = numbytes t in
let bi = b.[len - i / numb - 1] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[i] == (uint_to_bytes_be bi).[i % numb]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[i % numb] == uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)) | val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
let index_bn_to_bytes_be_ #t len b i = | false | null | true | let numb = numbytes t in
let bi = b.[ len - i / numb - 1 ] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[ i ] == (uint_to_bytes_be bi).[ i % numb ]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[ i % numb ] ==
uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.nat",
"Prims.op_LessThan",
"Prims._assert",
"Prims.eq2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.l_or",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v",
"Prims.op_Modulus",
"Prims.op_Division",
"Prims.pow2",
"Prims.op_Subtraction",
"Lib.IntTypes.uint_t",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.ByteSequence.uint_to_bytes_be",
"Lib.Sequence.op_String_Access",
"Lib.IntTypes.uint",
"Prims.unit",
"Lib.ByteSequence.index_uint_to_bytes_be",
"Lib.IntTypes.uint8",
"Hacl.Spec.Bignum.Convert.bn_to_bytes_be_",
"Lib.Sequence.index_generate_blocks",
"Hacl.Spec.Bignum.Convert.bn_to_bytes_be_f",
"Hacl.Spec.Bignum.Definitions.limb"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b
val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)) | false | false | Hacl.Spec.Bignum.Convert.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 index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)) | [] | Hacl.Spec.Bignum.Convert.index_bn_to_bytes_be_ | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat{Lib.IntTypes.numbytes t * len <= Lib.IntTypes.max_size_t} ->
b: Hacl.Spec.Bignum.Definitions.lbignum t len ->
i: Prims.nat{i < Lib.IntTypes.numbytes t * len}
-> FStar.Pervasives.Lemma
(ensures
(let numb = Lib.IntTypes.numbytes t in
(Hacl.Spec.Bignum.Convert.bn_to_bytes_be_ len b).[ i ] ==
Lib.IntTypes.uint (Lib.IntTypes.v b.[ len - i / numb - 1 ] /
Prims.pow2 (8 * (numb - 1 - i % numb)) %
Prims.pow2 8))) | {
"end_col": 111,
"end_line": 273,
"start_col": 38,
"start_line": 267
} |
FStar.Pervasives.Lemma | val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end | val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b = | false | null | true | if len = 0
then bn_eval0 b
else
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[ len - 1 ]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[ len - 1 ]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[ 0 ] == b.[ len - 1 ]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[ len - 1 ]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.op_Equality",
"Prims.int",
"Hacl.Spec.Bignum.Definitions.bn_eval0",
"Prims.bool",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.nat",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.ByteSequence.nat_from_intseq_be",
"Lib.IntTypes.SEC",
"Hacl.Spec.Bignum.Convert.reverse",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Mul.op_Star",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.Sequence.slice",
"Hacl.Spec.Bignum.Definitions.limb",
"Lib.IntTypes.bits",
"Lib.IntTypes.v",
"Lib.Sequence.op_String_Access",
"Prims.op_Subtraction",
"Lib.ByteSequence.nat_from_intseq_be_lemma0",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Hacl.Spec.Bignum.Convert.reverse_slice1",
"Lib.ByteSequence.nat_from_intseq_be_slice_lemma",
"Prims.op_Addition",
"Hacl.Spec.Bignum.Definitions.bn_eval_unfold_i",
"Hacl.Spec.Bignum.Definitions.bn_eval_split_i",
"Hacl.Spec.Bignum.Convert.bn_v_is_nat_from_intseq_be_lemma",
"Lib.Sequence.lseq",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.slice",
"Prims.l_Forall",
"Lib.Sequence.index"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b)) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b)) | [
"recursion"
] | Hacl.Spec.Bignum.Convert.bn_v_is_nat_from_intseq_be_lemma | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Lib.IntTypes.size_nat -> b: Hacl.Spec.Bignum.Definitions.lbignum t len
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Definitions.bn_v b ==
Lib.ByteSequence.nat_from_intseq_be (Hacl.Spec.Bignum.Convert.reverse b)) | {
"end_col": 10,
"end_line": 196,
"start_col": 2,
"start_line": 178
} |
FStar.Pervasives.Lemma | val bn_from_bytes_be_is_uints_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t /\ len % numbytes t = 0}
-> b:lseq uint8 len ->
Lemma (reverse (bn_from_bytes_be #t len b) == uints_from_bytes_be b) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_from_bytes_be_is_uints_from_bytes_be #t len b =
let lp = bn_from_bytes_be #t len b in
let rp = uints_from_bytes_be #t #SEC #(len / numbytes t) b in
uints_from_bytes_be_nat_lemma #t #SEC #(len / numbytes t) b;
assert (nat_from_intseq_be rp == nat_from_bytes_be b);
bn_from_bytes_be_lemma #t len b;
assert (bn_v lp == nat_from_bytes_be b);
bn_v_is_nat_from_intseq_be_lemma (len / numbytes t) lp;
assert (bn_v lp == nat_from_intseq_be (reverse lp));
assert (nat_from_intseq_be rp == nat_from_intseq_be (reverse lp));
nat_from_intseq_be_inj rp (reverse lp) | val bn_from_bytes_be_is_uints_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t /\ len % numbytes t = 0}
-> b:lseq uint8 len ->
Lemma (reverse (bn_from_bytes_be #t len b) == uints_from_bytes_be b)
let bn_from_bytes_be_is_uints_from_bytes_be #t len b = | false | null | true | let lp = bn_from_bytes_be #t len b in
let rp = uints_from_bytes_be #t #SEC #(len / numbytes t) b in
uints_from_bytes_be_nat_lemma #t #SEC #(len / numbytes t) b;
assert (nat_from_intseq_be rp == nat_from_bytes_be b);
bn_from_bytes_be_lemma #t len b;
assert (bn_v lp == nat_from_bytes_be b);
bn_v_is_nat_from_intseq_be_lemma (len / numbytes t) lp;
assert (bn_v lp == nat_from_intseq_be (reverse lp));
assert (nat_from_intseq_be rp == nat_from_intseq_be (reverse lp));
nat_from_intseq_be_inj rp (reverse lp) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.max_size_t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Lib.ByteSequence.nat_from_intseq_be_inj",
"Lib.IntTypes.SEC",
"Hacl.Spec.Bignum.Convert.reverse",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.nat",
"Prims.l_or",
"Prims.op_LessThan",
"Prims.pow2",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.bits",
"Lib.ByteSequence.nat_from_intseq_be",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Hacl.Spec.Bignum.Convert.bn_v_is_nat_from_intseq_be_lemma",
"Prims.op_Division",
"Lib.ByteSequence.nat_from_bytes_be",
"Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma",
"Lib.IntTypes.U8",
"Lib.ByteSequence.uints_from_bytes_be_nat_lemma",
"Lib.IntTypes.int_t",
"Lib.ByteSequence.uints_from_bytes_be",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Convert.bn_from_bytes_be"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b
val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
let index_bn_to_bytes_be_ #t len b i =
let numb = numbytes t in
let bi = b.[len - i / numb - 1] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[i] == (uint_to_bytes_be bi).[i % numb]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[i % numb] == uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)
let bn_to_bytes_be_lemma_aux #t len b i =
let pbits = bits t in
let numb = numbytes t in
let e = numb - 1 - i % numb in
let e1 = len - i / numb - 1 in
let e2 = numb * len - 1 - i in
calc (==) {
v b.[e1] / pow2 (8 * e) % pow2 8;
(==) { bn_eval_index b e1 }
(bn_v b / pow2 (pbits * e1) % pow2 (pbits)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (pbits * e1) (pbits + pbits * e1) }
(bn_v b % pow2 (pbits + pbits * e1) / pow2 (pbits * e1)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.division_multiplication_lemma (bn_v b % pow2 (pbits + pbits * e1)) (pow2 (pbits * e1)) (pow2 (8 * e)) }
(bn_v b % pow2 (pbits + pbits * e1)) / (pow2 (pbits * e1) * pow2 (8 * e)) % pow2 8;
(==) { Math.Lemmas.pow2_plus (pbits * e1) (8 * e) }
(bn_v b % pow2 (pbits + pbits * e1)) / pow2 (pbits * e1 + 8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (8 * e2) (pbits + pbits * e1) }
(bn_v b / pow2 (8 * e2)) % pow2 (pbits + pbits * e1 - 8 * e2) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 (bn_v b / pow2 (8 * e2)) 8 (pbits + pbits * e1 - 8 * e2) }
(bn_v b / pow2 (8 * (numb * len - i - 1))) % pow2 8;
}
val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b))
let bn_to_bytes_be_lemma_ #t len b =
let numb = numbytes t in
let lemma_aux (i:nat{i < numb * len}) :
Lemma ((bn_to_bytes_be_ #t len b).[i] == index #uint8 #(numb * len) (nat_to_intseq_be (numb * len) (bn_v b)) i)
=
let rp = nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) in
index_nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) (numb * len - i - 1);
assert (index #uint8 #(numb * len) rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8));
index_bn_to_bytes_be_ len b i;
assert ((bn_to_bytes_be_ #t len b).[i] == uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8));
bn_to_bytes_be_lemma_aux len b i;
() in
Classical.forall_intro lemma_aux;
eq_intro (bn_to_bytes_be_ len b) (nat_to_intseq_be (numb * len) (bn_v b))
val bn_to_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_be #t len b == nat_to_intseq_be #U8 #SEC len (bn_v b))
let bn_to_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
let res = sub tmp (tmpLen - len) len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
bn_to_bytes_be_lemma_ bnLen b;
assert (tmp == nat_to_intseq_be #U8 #SEC tmpLen (bn_v b));
let lemma_aux (i:nat{i < len}) :
Lemma (index (sub #uint8 #tmpLen (nat_to_intseq_be #U8 #SEC tmpLen (bn_v b)) (tmpLen - len) len) i ==
index #uint8 #len (nat_to_intseq_be #U8 #SEC len (bn_v b)) i) =
let rp = nat_to_intseq_be #U8 #SEC len (bn_v b) in
index_nat_to_intseq_be #U8 #SEC len (bn_v b) (len - i - 1);
assert (index #uint8 #len rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
let lp = nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) in
assert (index (sub #uint8 #tmpLen lp (tmpLen - len) len) i == index #uint8 #tmpLen lp (tmpLen - len + i));
index_nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) (len - i - 1);
assert (index #uint8 #tmpLen lp (tmpLen - len + i) == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
() in
Classical.forall_intro lemma_aux;
eq_intro (nat_to_intseq_be #U8 #SEC len (bn_v b)) res
(* Little-endian *)
val bn_v_is_nat_from_intseq_le_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_le b)
let rec bn_v_is_nat_from_intseq_le_lemma #t len b =
if len = 0 then
bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_le_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_le b1);
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v b == nat_from_intseq_le b1 + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_le_slice_lemma b (len - 1);
nat_from_intseq_le_lemma0 (slice b (len - 1) len);
assert (nat_from_intseq_le b == nat_from_intseq_le b1 + pow2 ((len - 1) * bits t) * v b.[len - 1]) end
val lemma_nat_from_bytes_le_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_le b == 0)
let rec lemma_nat_from_bytes_le_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_le_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_le_lemma0 (slice b 0 1);
lemma_nat_from_bytes_le_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_le_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 -> Lemma
(let tmp = create len (u8 0) in
nat_from_intseq_le b == nat_from_intseq_le (update_sub tmp 0 len0 b))
let nat_from_bytes_le_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp 0 len0 b in
assert (slice r 0 len0 == b);
assert (forall (i:nat). i < len - len0 ==> r.[len0 + i] == u8 0);
nat_from_intseq_le_slice_lemma #U8 #SEC #len r len0;
assert (nat_from_intseq_le r == nat_from_intseq_le (slice r 0 len0) + pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
assert (nat_from_intseq_le r == nat_from_intseq_le b + pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
lemma_nat_from_bytes_le_zeroes (len - len0) (Seq.slice r len0 len)
val bn_from_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_le #t len b) == nat_from_bytes_le b)
let bn_from_bytes_le_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
let res = uints_from_bytes_le #t #SEC #bnLen tmp in
uints_from_bytes_le_nat_lemma #t #SEC #bnLen tmp;
bn_v_is_nat_from_intseq_le_lemma bnLen res;
nat_from_bytes_le_eq_lemma len tmpLen b
val bn_to_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_le len b == nat_to_intseq_le #U8 len (bn_v b))
let bn_to_bytes_le_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
let res = sub tmp 0 len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
uints_to_bytes_le_nat_lemma #t #SEC bnLen (bn_v b);
bn_v_is_nat_from_intseq_le_lemma bnLen b;
lemma_nat_from_to_intseq_le_preserves_value bnLen b;
assert (uints_to_bytes_le #t #SEC #bnLen b == nat_to_intseq_le #U8 tmpLen (bn_v b));
let aux (i:nat{i < len}) :
Lemma (index #uint8 #tmpLen (nat_to_intseq_le #U8 tmpLen (bn_v b)) i ==
index #uint8 #len (nat_to_intseq_le #U8 len (bn_v b)) i) =
index_nat_to_intseq_le #U8 #SEC tmpLen (bn_v b) i;
index_nat_to_intseq_le #U8 #SEC len (bn_v b) i in
Classical.forall_intro aux;
eq_intro (nat_to_intseq_le #U8 #SEC len (bn_v b)) res
val bn_from_bytes_le_is_uints_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t /\ len % numbytes t = 0}
-> b:lseq uint8 len ->
Lemma (bn_from_bytes_le #t len b == uints_from_bytes_le b)
let bn_from_bytes_le_is_uints_from_bytes_le #t len b =
let lp = bn_from_bytes_le #t len b in
let rp = uints_from_bytes_le #t #SEC #(len / numbytes t) b in
//uints_from_bytes_le_nat_lemma #t #SEC #(len / numbytes t) b;
//assert (nat_from_intseq_le rp == nat_from_bytes_le b);
//bn_from_bytes_le_lemma #t len b;
//assert (bn_v lp == nat_from_bytes_le b);
//assert (nat_from_intseq_le rp == bn_v lp);
assert (bn_v rp == bn_v lp);
bn_eval_inj (len / numbytes t) rp lp
val bn_from_bytes_be_is_uints_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t /\ len % numbytes t = 0}
-> b:lseq uint8 len ->
Lemma (reverse (bn_from_bytes_be #t len b) == uints_from_bytes_be b) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_from_bytes_be_is_uints_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t /\ len % numbytes t = 0}
-> b:lseq uint8 len ->
Lemma (reverse (bn_from_bytes_be #t len b) == uints_from_bytes_be b) | [] | Hacl.Spec.Bignum.Convert.bn_from_bytes_be_is_uints_from_bytes_be | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len:
Lib.IntTypes.size_pos
{ Lib.IntTypes.numbytes t *
Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <=
Lib.IntTypes.max_size_t /\ len % Lib.IntTypes.numbytes t = 0 } ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 len
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Convert.reverse (Hacl.Spec.Bignum.Convert.bn_from_bytes_be len b) ==
Lib.ByteSequence.uints_from_bytes_be b) | {
"end_col": 40,
"end_line": 499,
"start_col": 54,
"start_line": 487
} |
FStar.Pervasives.Lemma | val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1))) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1))) | val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b = | false | null | true | let lemma_aux (i: nat{i < len - 1})
: Lemma ((slice (reverse b) 1 len).[ i ] == (reverse (slice b 0 (len - 1))).[ i ]) =
()
in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1))) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.Sequence.eq_intro",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.op_Subtraction",
"Lib.Sequence.slice",
"Hacl.Spec.Bignum.Convert.reverse",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.op_String_Access",
"Prims.l_True",
"Prims.squash",
"Lib.Sequence.index",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len -> | false | false | Hacl.Spec.Bignum.Convert.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 reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1))) | [] | Hacl.Spec.Bignum.Convert.reverse_slice1 | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Hacl.Spec.Bignum.Definitions.lbignum t len
-> FStar.Pervasives.Lemma
(ensures
Lib.Sequence.slice (Hacl.Spec.Bignum.Convert.reverse b) 1 len ==
Hacl.Spec.Bignum.Convert.reverse (Lib.Sequence.slice b 0 (len - 1))) | {
"end_col": 68,
"end_line": 155,
"start_col": 30,
"start_line": 150
} |
FStar.Pervasives.Lemma | val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_to_bytes_be_lemma_ #t len b =
let numb = numbytes t in
let lemma_aux (i:nat{i < numb * len}) :
Lemma ((bn_to_bytes_be_ #t len b).[i] == index #uint8 #(numb * len) (nat_to_intseq_be (numb * len) (bn_v b)) i)
=
let rp = nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) in
index_nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) (numb * len - i - 1);
assert (index #uint8 #(numb * len) rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8));
index_bn_to_bytes_be_ len b i;
assert ((bn_to_bytes_be_ #t len b).[i] == uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8));
bn_to_bytes_be_lemma_aux len b i;
() in
Classical.forall_intro lemma_aux;
eq_intro (bn_to_bytes_be_ len b) (nat_to_intseq_be (numb * len) (bn_v b)) | val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b))
let bn_to_bytes_be_lemma_ #t len b = | false | null | true | let numb = numbytes t in
let lemma_aux (i: nat{i < numb * len})
: Lemma
((bn_to_bytes_be_ #t len b).[ i ] ==
index #uint8 #(numb * len) (nat_to_intseq_be (numb * len) (bn_v b)) i) =
let rp = nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) in
index_nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) (numb * len - i - 1);
assert (index #uint8 #(numb * len) rp i ==
uint #U8 #SEC (bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8));
index_bn_to_bytes_be_ len b i;
assert ((bn_to_bytes_be_ #t len b).[ i ] ==
uint #U8 #SEC (v b.[ len - i / numb - 1 ] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8));
bn_to_bytes_be_lemma_aux len b i;
()
in
Classical.forall_intro lemma_aux;
eq_intro (bn_to_bytes_be_ len b) (nat_to_intseq_be (numb * len) (bn_v b)) | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Lib.IntTypes.bits",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.uint8",
"Hacl.Spec.Bignum.Convert.bn_to_bytes_be_",
"Lib.ByteSequence.nat_to_intseq_be",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.eq2",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.op_String_Access",
"Lib.Sequence.index",
"Prims.op_Multiply",
"Prims.l_True",
"Prims.squash",
"Lib.IntTypes.int_t",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma_aux",
"Prims._assert",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v",
"Prims.op_Modulus",
"Prims.op_Division",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.op_Subtraction",
"Lib.IntTypes.uint",
"Hacl.Spec.Bignum.Convert.index_bn_to_bytes_be_",
"Lib.ByteSequence.index_nat_to_intseq_be",
"Lib.Sequence.seq",
"Prims.l_and",
"Lib.Sequence.length",
"Lib.ByteSequence.nat_from_intseq_be"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b
val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
let index_bn_to_bytes_be_ #t len b i =
let numb = numbytes t in
let bi = b.[len - i / numb - 1] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[i] == (uint_to_bytes_be bi).[i % numb]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[i % numb] == uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)
let bn_to_bytes_be_lemma_aux #t len b i =
let pbits = bits t in
let numb = numbytes t in
let e = numb - 1 - i % numb in
let e1 = len - i / numb - 1 in
let e2 = numb * len - 1 - i in
calc (==) {
v b.[e1] / pow2 (8 * e) % pow2 8;
(==) { bn_eval_index b e1 }
(bn_v b / pow2 (pbits * e1) % pow2 (pbits)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (pbits * e1) (pbits + pbits * e1) }
(bn_v b % pow2 (pbits + pbits * e1) / pow2 (pbits * e1)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.division_multiplication_lemma (bn_v b % pow2 (pbits + pbits * e1)) (pow2 (pbits * e1)) (pow2 (8 * e)) }
(bn_v b % pow2 (pbits + pbits * e1)) / (pow2 (pbits * e1) * pow2 (8 * e)) % pow2 8;
(==) { Math.Lemmas.pow2_plus (pbits * e1) (8 * e) }
(bn_v b % pow2 (pbits + pbits * e1)) / pow2 (pbits * e1 + 8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (8 * e2) (pbits + pbits * e1) }
(bn_v b / pow2 (8 * e2)) % pow2 (pbits + pbits * e1 - 8 * e2) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 (bn_v b / pow2 (8 * e2)) 8 (pbits + pbits * e1 - 8 * e2) }
(bn_v b / pow2 (8 * (numb * len - i - 1))) % pow2 8;
}
val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b)) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b)) | [] | Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma_ | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_pos{Lib.IntTypes.numbytes t * len <= Lib.IntTypes.max_size_t} ->
b:
Hacl.Spec.Bignum.Definitions.lbignum t len
{Hacl.Spec.Bignum.Definitions.bn_v b < Prims.pow2 (Lib.IntTypes.bits t * len)}
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Convert.bn_to_bytes_be_ len b ==
Lib.ByteSequence.nat_to_intseq_be (Lib.IntTypes.numbytes t * len)
(Hacl.Spec.Bignum.Definitions.bn_v b)) | {
"end_col": 75,
"end_line": 330,
"start_col": 36,
"start_line": 315
} |
FStar.Pervasives.Lemma | val bn_to_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_le len b == nat_to_intseq_le #U8 len (bn_v b)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_to_bytes_le_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
let res = sub tmp 0 len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
uints_to_bytes_le_nat_lemma #t #SEC bnLen (bn_v b);
bn_v_is_nat_from_intseq_le_lemma bnLen b;
lemma_nat_from_to_intseq_le_preserves_value bnLen b;
assert (uints_to_bytes_le #t #SEC #bnLen b == nat_to_intseq_le #U8 tmpLen (bn_v b));
let aux (i:nat{i < len}) :
Lemma (index #uint8 #tmpLen (nat_to_intseq_le #U8 tmpLen (bn_v b)) i ==
index #uint8 #len (nat_to_intseq_le #U8 len (bn_v b)) i) =
index_nat_to_intseq_le #U8 #SEC tmpLen (bn_v b) i;
index_nat_to_intseq_le #U8 #SEC len (bn_v b) i in
Classical.forall_intro aux;
eq_intro (nat_to_intseq_le #U8 #SEC len (bn_v b)) res | val bn_to_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_le len b == nat_to_intseq_le #U8 len (bn_v b))
let bn_to_bytes_le_lemma #t len b = | false | null | true | let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
let res = sub tmp 0 len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
uints_to_bytes_le_nat_lemma #t #SEC bnLen (bn_v b);
bn_v_is_nat_from_intseq_le_lemma bnLen b;
lemma_nat_from_to_intseq_le_preserves_value bnLen b;
assert (uints_to_bytes_le #t #SEC #bnLen b == nat_to_intseq_le #U8 tmpLen (bn_v b));
let aux (i: nat{i < len})
: Lemma
(index #uint8 #tmpLen (nat_to_intseq_le #U8 tmpLen (bn_v b)) i ==
index #uint8 #len (nat_to_intseq_le #U8 len (bn_v b)) i) =
index_nat_to_intseq_le #U8 #SEC tmpLen (bn_v b) i;
index_nat_to_intseq_le #U8 #SEC len (bn_v b) i
in
Classical.forall_intro aux;
eq_intro (nat_to_intseq_le #U8 #SEC len (bn_v b)) res | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.max_size_t",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.ByteSequence.nat_to_intseq_le",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.eq2",
"Lib.IntTypes.uint8",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Prims.l_True",
"Prims.squash",
"Lib.IntTypes.int_t",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Lib.ByteSequence.index_nat_to_intseq_le",
"Prims._assert",
"Lib.Sequence.seq",
"FStar.Seq.Base.length",
"Prims.l_and",
"Lib.Sequence.length",
"Lib.IntTypes.bits",
"Lib.ByteSequence.nat_from_intseq_le",
"Lib.ByteSequence.uints_to_bytes_le",
"Lib.ByteSequence.lemma_nat_from_to_intseq_le_preserves_value",
"Hacl.Spec.Bignum.Convert.bn_v_is_nat_from_intseq_le_lemma",
"Lib.ByteSequence.uints_to_bytes_le_nat_lemma",
"FStar.Math.Lemmas.pow2_le_compat",
"Lib.Sequence.lseq",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.slice",
"Prims.op_Multiply",
"Prims.op_Addition",
"Prims.l_Forall",
"Lib.Sequence.sub",
"Prims.int",
"Prims.pos",
"Prims.op_Subtraction"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b
val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
let index_bn_to_bytes_be_ #t len b i =
let numb = numbytes t in
let bi = b.[len - i / numb - 1] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[i] == (uint_to_bytes_be bi).[i % numb]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[i % numb] == uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)
let bn_to_bytes_be_lemma_aux #t len b i =
let pbits = bits t in
let numb = numbytes t in
let e = numb - 1 - i % numb in
let e1 = len - i / numb - 1 in
let e2 = numb * len - 1 - i in
calc (==) {
v b.[e1] / pow2 (8 * e) % pow2 8;
(==) { bn_eval_index b e1 }
(bn_v b / pow2 (pbits * e1) % pow2 (pbits)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (pbits * e1) (pbits + pbits * e1) }
(bn_v b % pow2 (pbits + pbits * e1) / pow2 (pbits * e1)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.division_multiplication_lemma (bn_v b % pow2 (pbits + pbits * e1)) (pow2 (pbits * e1)) (pow2 (8 * e)) }
(bn_v b % pow2 (pbits + pbits * e1)) / (pow2 (pbits * e1) * pow2 (8 * e)) % pow2 8;
(==) { Math.Lemmas.pow2_plus (pbits * e1) (8 * e) }
(bn_v b % pow2 (pbits + pbits * e1)) / pow2 (pbits * e1 + 8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (8 * e2) (pbits + pbits * e1) }
(bn_v b / pow2 (8 * e2)) % pow2 (pbits + pbits * e1 - 8 * e2) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 (bn_v b / pow2 (8 * e2)) 8 (pbits + pbits * e1 - 8 * e2) }
(bn_v b / pow2 (8 * (numb * len - i - 1))) % pow2 8;
}
val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b))
let bn_to_bytes_be_lemma_ #t len b =
let numb = numbytes t in
let lemma_aux (i:nat{i < numb * len}) :
Lemma ((bn_to_bytes_be_ #t len b).[i] == index #uint8 #(numb * len) (nat_to_intseq_be (numb * len) (bn_v b)) i)
=
let rp = nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) in
index_nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) (numb * len - i - 1);
assert (index #uint8 #(numb * len) rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8));
index_bn_to_bytes_be_ len b i;
assert ((bn_to_bytes_be_ #t len b).[i] == uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8));
bn_to_bytes_be_lemma_aux len b i;
() in
Classical.forall_intro lemma_aux;
eq_intro (bn_to_bytes_be_ len b) (nat_to_intseq_be (numb * len) (bn_v b))
val bn_to_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_be #t len b == nat_to_intseq_be #U8 #SEC len (bn_v b))
let bn_to_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
let res = sub tmp (tmpLen - len) len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
bn_to_bytes_be_lemma_ bnLen b;
assert (tmp == nat_to_intseq_be #U8 #SEC tmpLen (bn_v b));
let lemma_aux (i:nat{i < len}) :
Lemma (index (sub #uint8 #tmpLen (nat_to_intseq_be #U8 #SEC tmpLen (bn_v b)) (tmpLen - len) len) i ==
index #uint8 #len (nat_to_intseq_be #U8 #SEC len (bn_v b)) i) =
let rp = nat_to_intseq_be #U8 #SEC len (bn_v b) in
index_nat_to_intseq_be #U8 #SEC len (bn_v b) (len - i - 1);
assert (index #uint8 #len rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
let lp = nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) in
assert (index (sub #uint8 #tmpLen lp (tmpLen - len) len) i == index #uint8 #tmpLen lp (tmpLen - len + i));
index_nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) (len - i - 1);
assert (index #uint8 #tmpLen lp (tmpLen - len + i) == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
() in
Classical.forall_intro lemma_aux;
eq_intro (nat_to_intseq_be #U8 #SEC len (bn_v b)) res
(* Little-endian *)
val bn_v_is_nat_from_intseq_le_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_le b)
let rec bn_v_is_nat_from_intseq_le_lemma #t len b =
if len = 0 then
bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_le_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_le b1);
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v b == nat_from_intseq_le b1 + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_le_slice_lemma b (len - 1);
nat_from_intseq_le_lemma0 (slice b (len - 1) len);
assert (nat_from_intseq_le b == nat_from_intseq_le b1 + pow2 ((len - 1) * bits t) * v b.[len - 1]) end
val lemma_nat_from_bytes_le_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_le b == 0)
let rec lemma_nat_from_bytes_le_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_le_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_le_lemma0 (slice b 0 1);
lemma_nat_from_bytes_le_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_le_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 -> Lemma
(let tmp = create len (u8 0) in
nat_from_intseq_le b == nat_from_intseq_le (update_sub tmp 0 len0 b))
let nat_from_bytes_le_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp 0 len0 b in
assert (slice r 0 len0 == b);
assert (forall (i:nat). i < len - len0 ==> r.[len0 + i] == u8 0);
nat_from_intseq_le_slice_lemma #U8 #SEC #len r len0;
assert (nat_from_intseq_le r == nat_from_intseq_le (slice r 0 len0) + pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
assert (nat_from_intseq_le r == nat_from_intseq_le b + pow2 (len0 * 8) * nat_from_intseq_le (Seq.slice r len0 len));
lemma_nat_from_bytes_le_zeroes (len - len0) (Seq.slice r len0 len)
val bn_from_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_le #t len b) == nat_from_bytes_le b)
let bn_from_bytes_le_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
let res = uints_from_bytes_le #t #SEC #bnLen tmp in
uints_from_bytes_le_nat_lemma #t #SEC #bnLen tmp;
bn_v_is_nat_from_intseq_le_lemma bnLen res;
nat_from_bytes_le_eq_lemma len tmpLen b
val bn_to_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_le len b == nat_to_intseq_le #U8 len (bn_v b)) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_to_bytes_le_lemma:
#t:limb_t
-> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_le len b == nat_to_intseq_le #U8 len (bn_v b)) | [] | Hacl.Spec.Bignum.Convert.bn_to_bytes_le_lemma | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len:
Lib.IntTypes.size_pos
{ Lib.IntTypes.numbytes t *
Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <=
Lib.IntTypes.max_size_t } ->
b:
Hacl.Spec.Bignum.Definitions.lbignum t
(Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t))
{Hacl.Spec.Bignum.Definitions.bn_v b < Prims.pow2 (8 * len)}
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Convert.bn_to_bytes_le len b ==
Lib.ByteSequence.nat_to_intseq_le len (Hacl.Spec.Bignum.Definitions.bn_v b)) | {
"end_col": 55,
"end_line": 459,
"start_col": 35,
"start_line": 438
} |
FStar.Pervasives.Lemma | val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_to_bytes_be_lemma_aux #t len b i =
let pbits = bits t in
let numb = numbytes t in
let e = numb - 1 - i % numb in
let e1 = len - i / numb - 1 in
let e2 = numb * len - 1 - i in
calc (==) {
v b.[e1] / pow2 (8 * e) % pow2 8;
(==) { bn_eval_index b e1 }
(bn_v b / pow2 (pbits * e1) % pow2 (pbits)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (pbits * e1) (pbits + pbits * e1) }
(bn_v b % pow2 (pbits + pbits * e1) / pow2 (pbits * e1)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.division_multiplication_lemma (bn_v b % pow2 (pbits + pbits * e1)) (pow2 (pbits * e1)) (pow2 (8 * e)) }
(bn_v b % pow2 (pbits + pbits * e1)) / (pow2 (pbits * e1) * pow2 (8 * e)) % pow2 8;
(==) { Math.Lemmas.pow2_plus (pbits * e1) (8 * e) }
(bn_v b % pow2 (pbits + pbits * e1)) / pow2 (pbits * e1 + 8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (8 * e2) (pbits + pbits * e1) }
(bn_v b / pow2 (8 * e2)) % pow2 (pbits + pbits * e1 - 8 * e2) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 (bn_v b / pow2 (8 * e2)) 8 (pbits + pbits * e1 - 8 * e2) }
(bn_v b / pow2 (8 * (numb * len - i - 1))) % pow2 8;
} | val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)
let bn_to_bytes_be_lemma_aux #t len b i = | false | null | true | let pbits = bits t in
let numb = numbytes t in
let e = numb - 1 - i % numb in
let e1 = len - i / numb - 1 in
let e2 = numb * len - 1 - i in
calc ( == ) {
v b.[ e1 ] / pow2 (8 * e) % pow2 8;
( == ) { bn_eval_index b e1 }
(bn_v b / pow2 (pbits * e1) % pow2 (pbits)) / pow2 (8 * e) % pow2 8;
( == ) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (pbits * e1) (pbits + pbits * e1) }
(bn_v b % pow2 (pbits + pbits * e1) / pow2 (pbits * e1)) / pow2 (8 * e) % pow2 8;
( == ) { Math.Lemmas.division_multiplication_lemma (bn_v b % pow2 (pbits + pbits * e1))
(pow2 (pbits * e1))
(pow2 (8 * e)) }
(bn_v b % pow2 (pbits + pbits * e1)) / (pow2 (pbits * e1) * pow2 (8 * e)) % pow2 8;
( == ) { Math.Lemmas.pow2_plus (pbits * e1) (8 * e) }
(bn_v b % pow2 (pbits + pbits * e1)) / pow2 (pbits * e1 + 8 * e) % pow2 8;
( == ) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (8 * e2) (pbits + pbits * e1) }
(bn_v b / pow2 (8 * e2)) % pow2 (pbits + pbits * e1 - 8 * e2) % pow2 8;
( == ) { Math.Lemmas.pow2_modulo_modulo_lemma_1 (bn_v b / pow2 (8 * e2))
8
(pbits + pbits * e1 - 8 * e2) }
(bn_v b / pow2 (8 * (numb * len - i - 1))) % pow2 8;
} | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Lib.IntTypes.bits",
"Prims.nat",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Modulus",
"Prims.op_Division",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Lib.Sequence.op_String_Access",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.op_Subtraction",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Prims.op_Addition",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Spec.Bignum.Definitions.bn_eval_index",
"Prims.squash",
"FStar.Math.Lemmas.pow2_modulo_division_lemma_1",
"FStar.Math.Lemmas.division_multiplication_lemma",
"FStar.Math.Lemmas.pow2_plus",
"FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b
val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
let index_bn_to_bytes_be_ #t len b i =
let numb = numbytes t in
let bi = b.[len - i / numb - 1] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[i] == (uint_to_bytes_be bi).[i % numb]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[i % numb] == uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8) | [] | Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma_aux | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_pos{Lib.IntTypes.numbytes t * len <= Lib.IntTypes.max_size_t} ->
b:
Hacl.Spec.Bignum.Definitions.lbignum t len
{Hacl.Spec.Bignum.Definitions.bn_v b < Prims.pow2 (Lib.IntTypes.bits t * len)} ->
i: Prims.nat{i < Lib.IntTypes.numbytes t * len}
-> FStar.Pervasives.Lemma
(ensures
(let numb = Lib.IntTypes.numbytes t in
Hacl.Spec.Bignum.Definitions.bn_v b / Prims.pow2 (8 * (numb * len - i - 1)) % Prims.pow2 8 ==
Lib.IntTypes.v b.[ len - i / numb - 1 ] / Prims.pow2 (8 * (numb - 1 - i % numb)) %
Prims.pow2 8)) | {
"end_col": 5,
"end_line": 306,
"start_col": 41,
"start_line": 285
} |
FStar.Pervasives.Lemma | val bn_to_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_be #t len b == nat_to_intseq_be #U8 #SEC len (bn_v b)) | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_to_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
let res = sub tmp (tmpLen - len) len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
bn_to_bytes_be_lemma_ bnLen b;
assert (tmp == nat_to_intseq_be #U8 #SEC tmpLen (bn_v b));
let lemma_aux (i:nat{i < len}) :
Lemma (index (sub #uint8 #tmpLen (nat_to_intseq_be #U8 #SEC tmpLen (bn_v b)) (tmpLen - len) len) i ==
index #uint8 #len (nat_to_intseq_be #U8 #SEC len (bn_v b)) i) =
let rp = nat_to_intseq_be #U8 #SEC len (bn_v b) in
index_nat_to_intseq_be #U8 #SEC len (bn_v b) (len - i - 1);
assert (index #uint8 #len rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
let lp = nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) in
assert (index (sub #uint8 #tmpLen lp (tmpLen - len) len) i == index #uint8 #tmpLen lp (tmpLen - len + i));
index_nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) (len - i - 1);
assert (index #uint8 #tmpLen lp (tmpLen - len + i) == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
() in
Classical.forall_intro lemma_aux;
eq_intro (nat_to_intseq_be #U8 #SEC len (bn_v b)) res | val bn_to_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_be #t len b == nat_to_intseq_be #U8 #SEC len (bn_v b))
let bn_to_bytes_be_lemma #t len b = | false | null | true | let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
let res = sub tmp (tmpLen - len) len in
assert (bn_v b < pow2 (8 * len));
Math.Lemmas.pow2_le_compat (bits t * bnLen) (8 * len);
assert (bn_v b < pow2 (bits t * bnLen));
bn_to_bytes_be_lemma_ bnLen b;
assert (tmp == nat_to_intseq_be #U8 #SEC tmpLen (bn_v b));
let lemma_aux (i: nat{i < len})
: Lemma
(index (sub #uint8 #tmpLen (nat_to_intseq_be #U8 #SEC tmpLen (bn_v b)) (tmpLen - len) len) i ==
index #uint8 #len (nat_to_intseq_be #U8 #SEC len (bn_v b)) i) =
let rp = nat_to_intseq_be #U8 #SEC len (bn_v b) in
index_nat_to_intseq_be #U8 #SEC len (bn_v b) (len - i - 1);
assert (index #uint8 #len rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
let lp = nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) in
assert (index (sub #uint8 #tmpLen lp (tmpLen - len) len) i ==
index #uint8 #tmpLen lp (tmpLen - len + i));
index_nat_to_intseq_be #U8 #SEC tmpLen (bn_v b) (len - i - 1);
assert (index #uint8 #tmpLen lp (tmpLen - len + i) ==
uint #U8 #SEC (bn_v b / pow2 (8 * (len - i - 1)) % pow2 8));
()
in
Classical.forall_intro lemma_aux;
eq_intro (nat_to_intseq_be #U8 #SEC len (bn_v b)) res | {
"checked_file": "Hacl.Spec.Bignum.Convert.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.Convert.fst"
} | [
"lemma"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Hacl.Spec.Bignum.Definitions.blocks",
"Lib.IntTypes.max_size_t",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.ByteSequence.nat_to_intseq_be",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.eq2",
"Lib.IntTypes.uint8",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.sub",
"Prims.op_Subtraction",
"Lib.Sequence.index",
"Prims.l_True",
"Prims.squash",
"Lib.IntTypes.int_t",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims._assert",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v",
"Prims.op_Modulus",
"Prims.op_Division",
"Prims.op_Addition",
"Lib.IntTypes.uint",
"Lib.ByteSequence.index_nat_to_intseq_be",
"Lib.Sequence.seq",
"Prims.l_and",
"Lib.Sequence.length",
"Prims.op_Multiply",
"Lib.ByteSequence.nat_from_intseq_be",
"FStar.Seq.Base.length",
"Lib.IntTypes.bits",
"Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma_",
"FStar.Math.Lemmas.pow2_le_compat",
"Lib.Sequence.lseq",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.slice",
"Prims.l_Forall",
"Hacl.Spec.Bignum.Convert.bn_to_bytes_be_",
"Prims.pos"
] | [] | module Hacl.Spec.Bignum.Convert
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
let bn_from_uint #t len x =
let b = create len (uint #t 0) in
b.[0] <- x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t ->
Lemma (bn_v (bn_from_uint len x) == uint_v x)
let bn_from_uint_lemma #t len x =
let b = create len (uint #t 0) in
let b = b.[0] <- x in
bn_eval_split_i b 1;
assert (bn_v b == bn_v (slice b 0 1) + pow2 (bits t) * bn_v (slice b 1 len));
eq_intro (slice b 1 len) (create (len - 1) (uint #t 0));
bn_eval_zeroes #t (len - 1) (len - 1);
assert (bn_v b == bn_v (slice b 0 1));
bn_eval1 (slice b 0 1)
val bn_from_bytes_be_f:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len)
-> i:nat{i < len} ->
limb t
let bn_from_bytes_be_f #t len b i =
uint_from_bytes_be (sub b ((len - i - 1) * numbytes t) (numbytes t))
val bn_from_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lseq uint8 (numbytes t * len) ->
lbignum t len
let bn_from_bytes_be_ #t len b =
createi len (bn_from_bytes_be_f len b)
val bn_from_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
bn_from_bytes_be_ bnLen tmp
val bn_from_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lseq uint8 len ->
lbignum t (blocks len (numbytes t))
let bn_from_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp 0 len b in
uints_from_bytes_le tmp
val bn_to_bytes_be_f:
#t:limb_t
-> len:size_nat
-> lbignum t len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes t)
let bn_to_bytes_be_f #t len b i () =
(), uint_to_bytes_be b.[len - i - 1]
val bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> lbignum t len ->
lseq uint8 (numbytes t * len)
let bn_to_bytes_be_ #t len b =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes t) len len a_spec
(bn_to_bytes_be_f len b) () in
o
val bn_to_bytes_be:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_be #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = bn_to_bytes_be_ bnLen b in
sub tmp (tmpLen - len) len
val bn_to_bytes_le:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> lbignum t (blocks len (numbytes t)) ->
lseq uint8 len
let bn_to_bytes_le #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = uints_to_bytes_le b in
sub tmp 0 len
///
/// Lemmas
///
val reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> lbignum t len
let reverse #t #len b = createi len (fun i -> b.[len - i - 1])
val twice_reverse: #t:limb_t -> #len:size_nat -> b:lbignum t len -> Lemma (reverse (reverse b) == b)
let twice_reverse #t #len b =
let lemma_aux (i:nat{i < len}) : Lemma ((reverse (reverse b)).[i] == b.[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (reverse (reverse b)) b
val reverse_slice1: #t:limb_t -> #len:size_pos -> b:lbignum t len ->
Lemma (slice (reverse b) 1 len == reverse (slice b 0 (len - 1)))
let reverse_slice1 #t #len b =
let lemma_aux (i:nat{i < len - 1}) :
Lemma ((slice (reverse b) 1 len).[i] == (reverse (slice b 0 (len - 1))).[i]) = () in
Classical.forall_intro lemma_aux;
eq_intro (slice (reverse b) 1 len) (reverse (slice b 0 (len - 1)))
val bn_from_bytes_be_is_uints_from_bytes_be_reverse:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_from_bytes_be_ len b == reverse (uints_from_bytes_be b))
let bn_from_bytes_be_is_uints_from_bytes_be_reverse #t len b =
let lemma_aux (i:nat{i < len}) :
Lemma ((bn_from_bytes_be_ len b).[i] == (reverse #t #len (uints_from_bytes_be b)).[i])
=
index_uints_from_bytes_be #t #SEC #len b (len - i - 1) in
Classical.forall_intro lemma_aux;
eq_intro (bn_from_bytes_be_ len b) (reverse (uints_from_bytes_be b))
val bn_v_is_nat_from_intseq_be_lemma: #t:limb_t -> len:size_nat -> b:lbignum t len ->
Lemma (bn_v b == nat_from_intseq_be (reverse b))
let rec bn_v_is_nat_from_intseq_be_lemma #t len b =
if len = 0 then bn_eval0 b
else begin
let b1 = slice b 0 (len - 1) in
bn_v_is_nat_from_intseq_be_lemma (len - 1) b1;
assert (bn_v b1 == nat_from_intseq_be (reverse b1));
bn_eval_split_i #t #len b (len - 1);
bn_eval_unfold_i #t #1 (slice b (len - 1) len) 1;
bn_eval0 #t #1 (slice b (len - 1) len);
assert (bn_v (slice b (len - 1) len) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b1) + pow2 (bits t * (len - 1)) * v b.[len - 1]);
nat_from_intseq_be_slice_lemma (reverse b) 1;
reverse_slice1 #t #len b;
assert ((reverse b).[0] == b.[len - 1]);
nat_from_intseq_be_lemma0 (slice (reverse b) 0 1);
assert (nat_from_intseq_be (slice (reverse b) 0 1) == v b.[len - 1]);
assert (bn_v b == nat_from_intseq_be (reverse b));
() end
val bn_from_bytes_be_lemma_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lseq uint8 (numbytes t * len) ->
Lemma (bn_v (bn_from_bytes_be_ len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma_ #t len b =
bn_v_is_nat_from_intseq_be_lemma len (bn_from_bytes_be_ len b);
bn_from_bytes_be_is_uints_from_bytes_be_reverse len b;
twice_reverse (uints_from_bytes_be #t #SEC #len b);
assert (bn_v (bn_from_bytes_be_ len b) == nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b));
uints_from_bytes_be_nat_lemma #t #SEC #len b;
assert (nat_from_intseq_be (uints_from_bytes_be #t #SEC #len b) == nat_from_bytes_be b)
val lemma_nat_from_bytes_be_zeroes: len:size_nat -> b:lseq uint8 len -> Lemma
(requires (forall (i:nat). i < len ==> b.[i] == u8 0))
(ensures nat_from_intseq_be b == 0)
let rec lemma_nat_from_bytes_be_zeroes len b =
if len = 0 then ()
else begin
nat_from_intseq_be_slice_lemma #U8 #SEC #len b 1;
nat_from_intseq_be_lemma0 (slice b 0 1);
lemma_nat_from_bytes_be_zeroes (len-1) (slice b 1 len) end
val nat_from_bytes_be_eq_lemma: len0:size_nat -> len:size_nat{len0 <= len} -> b:lseq uint8 len0 ->
Lemma (let tmp = create len (u8 0) in
nat_from_intseq_be b == nat_from_intseq_be (update_sub tmp (len - len0) len0 b))
let nat_from_bytes_be_eq_lemma len0 len b =
let tmp = create len (u8 0) in
let r = update_sub tmp (len - len0) len0 b in
assert (slice r (len - len0) len == b);
assert (forall (i:nat). i < len - len0 ==> r.[i] == u8 0);
nat_from_intseq_be_slice_lemma #U8 #SEC #len r (len - len0);
assert (nat_from_intseq_be r == nat_from_intseq_be (slice r (len - len0) len) + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
assert (nat_from_intseq_be r == nat_from_intseq_be b + pow2 (len0 * 8) * nat_from_intseq_be (Seq.slice r 0 (len - len0)));
lemma_nat_from_bytes_be_zeroes (len - len0) (Seq.slice r 0 (len - len0))
val bn_from_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lseq uint8 len ->
Lemma (bn_v (bn_from_bytes_be #t len b) == nat_from_bytes_be b)
let bn_from_bytes_be_lemma #t len b =
let bnLen = blocks len (numbytes t) in
let tmpLen = numbytes t * bnLen in
let tmp = create tmpLen (u8 0) in
let tmp = update_sub tmp (tmpLen - len) len b in
let res = bn_from_bytes_be_ #t bnLen tmp in
bn_from_bytes_be_lemma_ #t bnLen tmp;
assert (bn_v (bn_from_bytes_be_ #t bnLen tmp) == nat_from_bytes_be tmp);
nat_from_bytes_be_eq_lemma len tmpLen b
val index_bn_to_bytes_be_:
#t:limb_t
-> len:size_nat{numbytes t * len <= max_size_t}
-> b:lbignum t len
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
(bn_to_bytes_be_ #t len b).[i] ==
uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
let index_bn_to_bytes_be_ #t len b i =
let numb = numbytes t in
let bi = b.[len - i / numb - 1] in
index_generate_blocks (numb) len len (bn_to_bytes_be_f len b) i;
assert ((bn_to_bytes_be_ #t len b).[i] == (uint_to_bytes_be bi).[i % numb]);
index_uint_to_bytes_be bi;
assert ((uint_to_bytes_be bi).[i % numb] == uint #U8 #SEC (v bi / pow2 (8 * (numb - 1 - i % numb)) % pow2 8))
val bn_to_bytes_be_lemma_aux:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)}
-> i:nat{i < numbytes t * len} ->
Lemma (let numb = numbytes t in
bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8 ==
v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8)
let bn_to_bytes_be_lemma_aux #t len b i =
let pbits = bits t in
let numb = numbytes t in
let e = numb - 1 - i % numb in
let e1 = len - i / numb - 1 in
let e2 = numb * len - 1 - i in
calc (==) {
v b.[e1] / pow2 (8 * e) % pow2 8;
(==) { bn_eval_index b e1 }
(bn_v b / pow2 (pbits * e1) % pow2 (pbits)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (pbits * e1) (pbits + pbits * e1) }
(bn_v b % pow2 (pbits + pbits * e1) / pow2 (pbits * e1)) / pow2 (8 * e) % pow2 8;
(==) { Math.Lemmas.division_multiplication_lemma (bn_v b % pow2 (pbits + pbits * e1)) (pow2 (pbits * e1)) (pow2 (8 * e)) }
(bn_v b % pow2 (pbits + pbits * e1)) / (pow2 (pbits * e1) * pow2 (8 * e)) % pow2 8;
(==) { Math.Lemmas.pow2_plus (pbits * e1) (8 * e) }
(bn_v b % pow2 (pbits + pbits * e1)) / pow2 (pbits * e1 + 8 * e) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_division_lemma_1 (bn_v b) (8 * e2) (pbits + pbits * e1) }
(bn_v b / pow2 (8 * e2)) % pow2 (pbits + pbits * e1 - 8 * e2) % pow2 8;
(==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 (bn_v b / pow2 (8 * e2)) 8 (pbits + pbits * e1 - 8 * e2) }
(bn_v b / pow2 (8 * (numb * len - i - 1))) % pow2 8;
}
val bn_to_bytes_be_lemma_:
#t:limb_t
-> len:size_pos{numbytes t * len <= max_size_t}
-> b:lbignum t len{bn_v b < pow2 (bits t * len)} ->
Lemma (bn_to_bytes_be_ #t len b == nat_to_intseq_be #U8 #SEC (numbytes t * len) (bn_v b))
let bn_to_bytes_be_lemma_ #t len b =
let numb = numbytes t in
let lemma_aux (i:nat{i < numb * len}) :
Lemma ((bn_to_bytes_be_ #t len b).[i] == index #uint8 #(numb * len) (nat_to_intseq_be (numb * len) (bn_v b)) i)
=
let rp = nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) in
index_nat_to_intseq_be #U8 #SEC (numb * len) (bn_v b) (numb * len - i - 1);
assert (index #uint8 #(numb * len) rp i == uint #U8 #SEC (bn_v b / pow2 (8 * (numb * len - i - 1)) % pow2 8));
index_bn_to_bytes_be_ len b i;
assert ((bn_to_bytes_be_ #t len b).[i] == uint #U8 #SEC (v b.[len - i / numb - 1] / pow2 (8 * (numb - 1 - i % numb)) % pow2 8));
bn_to_bytes_be_lemma_aux len b i;
() in
Classical.forall_intro lemma_aux;
eq_intro (bn_to_bytes_be_ len b) (nat_to_intseq_be (numb * len) (bn_v b))
val bn_to_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_be #t len b == nat_to_intseq_be #U8 #SEC len (bn_v b)) | false | false | Hacl.Spec.Bignum.Convert.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_to_bytes_be_lemma:
#t:limb_t
-> len:size_pos{numbytes t * blocks len (numbytes t) <= max_size_t}
-> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} ->
Lemma (bn_to_bytes_be #t len b == nat_to_intseq_be #U8 #SEC len (bn_v b)) | [] | Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma | {
"file_name": "code/bignum/Hacl.Spec.Bignum.Convert.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len:
Lib.IntTypes.size_pos
{ Lib.IntTypes.numbytes t *
Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <=
Lib.IntTypes.max_size_t } ->
b:
Hacl.Spec.Bignum.Definitions.lbignum t
(Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t))
{Hacl.Spec.Bignum.Definitions.bn_v b < Prims.pow2 (8 * len)}
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.Bignum.Convert.bn_to_bytes_be len b ==
Lib.ByteSequence.nat_to_intseq_be len (Hacl.Spec.Bignum.Definitions.bn_v b)) | {
"end_col": 55,
"end_line": 363,
"start_col": 35,
"start_line": 339
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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_any_fvar = Reflection.is_any_fvar | let is_any_fvar = | false | null | false | Reflection.is_any_fvar | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"FStar.Reflection.V1.Derived.is_any_fvar"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics | false | true | Steel.ST.GenElim.Base.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 is_any_fvar : t: FStar.Reflection.Types.term -> nms: Prims.list Prims.string -> Prims.bool | [] | Steel.ST.GenElim.Base.is_any_fvar | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: FStar.Reflection.Types.term -> nms: Prims.list Prims.string -> Prims.bool | {
"end_col": 40,
"end_line": 7,
"start_col": 18,
"start_line": 7
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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_fvar = Reflection.is_fvar | let is_fvar = | false | null | false | Reflection.is_fvar | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"FStar.Reflection.V1.Derived.is_fvar"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics | false | true | Steel.ST.GenElim.Base.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 is_fvar : t: FStar.Reflection.Types.term -> nm: Prims.string -> Prims.bool | [] | Steel.ST.GenElim.Base.is_fvar | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: FStar.Reflection.Types.term -> nm: Prims.string -> Prims.bool | {
"end_col": 36,
"end_line": 6,
"start_col": 18,
"start_line": 6
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let dsndp #a #b t = dsnd #a #b t | let dsndp #a #b t = | false | null | false | dsnd #a #b t | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Prims.dtuple2",
"FStar.Pervasives.dsnd",
"Prims.__proj__Mkdtuple2__item___1"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t | false | false | Steel.ST.GenElim.Base.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 dsndp : t: Prims.dtuple2 a b -> b (Mkdtuple2?._1 t) | [] | Steel.ST.GenElim.Base.dsndp | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: Prims.dtuple2 a b -> b (Mkdtuple2?._1 t) | {
"end_col": 32,
"end_line": 89,
"start_col": 20,
"start_line": 89
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fstp #a #b t = fst #a #b t | let fstp #a #b t = | false | null | false | fst #a #b t | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.fst"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t | false | false | Steel.ST.GenElim.Base.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 fstp : t: (a * b) -> a | [] | Steel.ST.GenElim.Base.fstp | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: (a * b) -> a | {
"end_col": 30,
"end_line": 91,
"start_col": 19,
"start_line": 91
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let compute_gen_elim_p' = compute_gen_elim_p | let compute_gen_elim_p' = | false | null | false | compute_gen_elim_p | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.compute_gen_elim_p"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x)) | false | true | Steel.ST.GenElim.Base.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 compute_gen_elim_p' : x: Steel.ST.GenElim.Base.gen_elim_i -> Steel.Effect.Common.vprop | [] | Steel.ST.GenElim.Base.compute_gen_elim_p' | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Steel.ST.GenElim.Base.gen_elim_i -> Steel.Effect.Common.vprop | {
"end_col": 44,
"end_line": 71,
"start_col": 26,
"start_line": 71
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sndp #a #b t = snd #a #b t | let sndp #a #b t = | false | null | false | snd #a #b t | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.snd"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t | false | false | Steel.ST.GenElim.Base.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 sndp : t: (a * b) -> b | [] | Steel.ST.GenElim.Base.sndp | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: (a * b) -> b | {
"end_col": 30,
"end_line": 93,
"start_col": 19,
"start_line": 93
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let dfstp #a #b t = dfst #a #b t | let dfstp #a #b t = | false | null | false | dfst #a #b t | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Prims.dtuple2",
"FStar.Pervasives.dfst"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x)) | false | false | Steel.ST.GenElim.Base.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 dfstp : t: Prims.dtuple2 a b -> a | [] | Steel.ST.GenElim.Base.dfstp | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: Prims.dtuple2 a b -> a | {
"end_col": 32,
"end_line": 87,
"start_col": 20,
"start_line": 87
} |
|
FStar.Tactics.Effect.Tac | val is_star_or_vstar (t: T.term) : T.Tac bool | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar] | val is_star_or_vstar (t: T.term) : T.Tac bool
let is_star_or_vstar (t: T.term) : T.Tac bool = | true | null | false | is_any_fvar t [`%star; `%VStar] | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"FStar.Reflection.Types.term",
"Steel.ST.GenElim.Base.is_any_fvar",
"Prims.Cons",
"Prims.string",
"Prims.Nil",
"Prims.bool"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash] | false | false | Steel.ST.GenElim.Base.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 is_star_or_vstar (t: T.term) : T.Tac bool | [] | Steel.ST.GenElim.Base.is_star_or_vstar | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool | {
"end_col": 33,
"end_line": 303,
"start_col": 2,
"start_line": 303
} |
Prims.Tot | val gen_elim_prop_placeholder
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: (Ghost.erased a -> Tot vprop))
(post: (Ghost.erased a -> Tot prop))
: Tot prop | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gen_elim_prop_placeholder
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
= True | val gen_elim_prop_placeholder
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: (Ghost.erased a -> Tot vprop))
(post: (Ghost.erased a -> Tot prop))
: Tot prop
let gen_elim_prop_placeholder
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: (Ghost.erased a -> Tot vprop))
(post: (Ghost.erased a -> Tot prop))
: Tot prop = | false | null | false | True | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Prims.bool",
"Steel.Effect.Common.vprop",
"FStar.Ghost.erased",
"Prims.prop",
"Prims.l_True"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash]
let is_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar]
let rec term_has_head
(t: T.term)
(head: T.term)
: T.Tac bool
= let (hd, tl) = T.collect_app t in
if hd `T.term_eq_old` head
then true
else if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit; td, T.Q_Explicit] ->
if term_has_head tg head
then true
else term_has_head td head
| _ -> false
else false
let rec solve_gen_unit_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`pure))
then T.mk_app (`GUEId) [tl', T.Q_Explicit]
else
let (hd, tl) = T.collect_app tl' in
if hd `is_fvar` (`%pure)
then T.mk_app (`GUEPure) tl
else if is_star_or_vstar hd
then match tl with
| [t1, T.Q_Explicit; t2, T.Q_Explicit] ->
let t1' = solve_gen_unit_elim t1 in
let t2' = solve_gen_unit_elim t2 in
T.mk_app (`GUEStar) [t1', T.Q_Explicit; t2', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GUEId) [tl', T.Q_Explicit]
let abstr_has_exists
(t: T.term)
: T.Tac bool
= match T.inspect t with
| T.Tv_Abs _ body -> term_has_head body (`exists_)
| _ -> false
let rec solve_gen_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`exists_))
then begin
let t' = solve_gen_unit_elim tl' in
T.mk_app (`GEUnit) [t', T.Q_Explicit]
end else
let (hd, lbody) = T.collect_app tl' in
if hd `is_fvar` (`%exists_)
then
let (ty, body) =
match lbody with
| [(ty, T.Q_Implicit); (body, T.Q_Explicit)] -> ([(ty, T.Q_Implicit)], body)
| [(body, T.Q_Explicit)] -> ([], body)
| _ -> T.fail "ill-formed exists_"
in
begin match T.inspect body with
| T.Tv_Abs b abody ->
if not (term_has_head abody (`exists_))
then
let body' = solve_gen_unit_elim abody in
T.mk_app (`GEExistsUnit) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
else
let body' = solve_gen_elim abody in
T.mk_app (`GEExists) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
| _ ->
T.mk_app (`GEExistsNoAbs) lbody
end
else if is_star_or_vstar hd
then
match lbody with
| [(tl, T.Q_Explicit); (tr, T.Q_Explicit)] ->
if term_has_head tl (`exists_)
then
let tl' = solve_gen_elim tl in
if term_has_head tr (`exists_)
then
let tr' = solve_gen_elim tr in
T.mk_app (`GEStar) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else
let tr' = solve_gen_unit_elim tr in
T.mk_app (`GEStarL) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else (* here, term_has_head tr (`exists_) holds, because otherwise we are in case (not (term_has_head tl (`exists_))) above *)
let tl' = solve_gen_unit_elim tl in
let tr' = solve_gen_elim tr in
T.mk_app (`GEStarR) [tl', T.Q_Explicit; tr', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GEUnit) [T.mk_app (`GUEId) lbody, T.Q_Explicit]
[@@ noextract_to "Plugin"]
val gen_elim_prop
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
val gen_elim_prop_intro'
(i: gen_elim_i)
(j: gen_elim_nondep_t)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i j))
(sq_a: squash (a == compute_gen_elim_nondep_a i j))
(sq_q: squash (q == compute_gen_elim_nondep_q i j))
(sq_post: squash (post == compute_gen_elim_nondep_post i j))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
let gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a: squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_q: squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_post: squash (post == compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
= gen_elim_prop_intro' i (mk_gen_elim_nondep ty tvprop q0 tprop post0) enable_nondep_opt p a q post sq_p sq_j sq_a sq_q sq_post
val gen_elim_prop_elim
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Ghost (gen_elim_i & gen_elim_nondep_t)
(requires gen_elim_prop enable_nondep_opt p a q post)
(ensures (fun (i, j) ->
p == compute_gen_elim_p i /\
check_gen_elim_nondep_sem i j /\
a == compute_gen_elim_nondep_a i j /\
q == compute_gen_elim_nondep_q i j /\
post == compute_gen_elim_nondep_post i j
))
[@@noextract_to "Plugin"]
let gen_elim_prop_placeholder
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop) | false | false | Steel.ST.GenElim.Base.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 gen_elim_prop_placeholder
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: (Ghost.erased a -> Tot vprop))
(post: (Ghost.erased a -> Tot prop))
: Tot prop | [] | Steel.ST.GenElim.Base.gen_elim_prop_placeholder | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
enable_nondep_opt: Prims.bool ->
p: Steel.Effect.Common.vprop ->
a: Type0 ->
q: (_: FStar.Ghost.erased a -> Steel.Effect.Common.vprop) ->
post: (_: FStar.Ghost.erased a -> Prims.prop)
-> Prims.prop | {
"end_col": 6,
"end_line": 473,
"start_col": 2,
"start_line": 473
} |
Prims.Tot | val compute_gen_elim_nondep_q
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(x: Ghost.erased (compute_gen_elim_nondep_a i0 i))
: Tot vprop | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x) | val compute_gen_elim_nondep_q
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(x: Ghost.erased (compute_gen_elim_nondep_a i0 i))
: Tot vprop
let compute_gen_elim_nondep_q
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(x: Ghost.erased (compute_gen_elim_nondep_a i0 i))
: Tot vprop = | false | null | false | compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x) | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Steel.ST.GenElim.Base.gen_elim_nondep_t",
"FStar.Ghost.erased",
"Steel.ST.GenElim.Base.compute_gen_elim_nondep_a",
"Steel.ST.GenElim.Base.compute_gen_elim_nondep_q0",
"FStar.Ghost.reveal",
"Steel.Effect.Common.vprop"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce] | false | false | Steel.ST.GenElim.Base.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 compute_gen_elim_nondep_q
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(x: Ghost.erased (compute_gen_elim_nondep_a i0 i))
: Tot vprop | [] | Steel.ST.GenElim.Base.compute_gen_elim_nondep_q | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim.Base.gen_elim_i ->
i: Steel.ST.GenElim.Base.gen_elim_nondep_t ->
x: FStar.Ghost.erased (Steel.ST.GenElim.Base.compute_gen_elim_nondep_a i0 i)
-> Steel.Effect.Common.vprop | {
"end_col": 50,
"end_line": 287,
"start_col": 2,
"start_line": 287
} |
FStar.Tactics.Effect.Tac | val is_squash (t: T.term) : T.Tac bool | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash] | val is_squash (t: T.term) : T.Tac bool
let is_squash (t: T.term) : T.Tac bool = | true | null | false | is_any_fvar t [`%squash; `%auto_squash] | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"FStar.Reflection.Types.term",
"Steel.ST.GenElim.Base.is_any_fvar",
"Prims.Cons",
"Prims.string",
"Prims.Nil",
"Prims.bool"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x) | false | false | Steel.ST.GenElim.Base.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 is_squash (t: T.term) : T.Tac bool | [] | Steel.ST.GenElim.Base.is_squash | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool | {
"end_col": 41,
"end_line": 300,
"start_col": 2,
"start_line": 300
} |
Prims.Tot | val compute_gen_elim_nondep_post
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(x: Ghost.erased (compute_gen_elim_nondep_a i0 i))
: Tot prop | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x) | val compute_gen_elim_nondep_post
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(x: Ghost.erased (compute_gen_elim_nondep_a i0 i))
: Tot prop
let compute_gen_elim_nondep_post
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(x: Ghost.erased (compute_gen_elim_nondep_a i0 i))
: Tot prop = | false | null | false | compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x) | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Steel.ST.GenElim.Base.gen_elim_nondep_t",
"FStar.Ghost.erased",
"Steel.ST.GenElim.Base.compute_gen_elim_nondep_a",
"Steel.ST.GenElim.Base.compute_gen_elim_nondep_post0",
"FStar.Ghost.reveal",
"Prims.prop"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"] | false | false | Steel.ST.GenElim.Base.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 compute_gen_elim_nondep_post
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(x: Ghost.erased (compute_gen_elim_nondep_a i0 i))
: Tot prop | [] | Steel.ST.GenElim.Base.compute_gen_elim_nondep_post | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim.Base.gen_elim_i ->
i: Steel.ST.GenElim.Base.gen_elim_nondep_t ->
x: FStar.Ghost.erased (Steel.ST.GenElim.Base.compute_gen_elim_nondep_a i0 i)
-> Prims.prop | {
"end_col": 53,
"end_line": 297,
"start_col": 2,
"start_line": 297
} |
FStar.Tactics.Effect.Tac | val abstr_has_exists (t: T.term) : T.Tac bool | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let abstr_has_exists
(t: T.term)
: T.Tac bool
= match T.inspect t with
| T.Tv_Abs _ body -> term_has_head body (`exists_)
| _ -> false | val abstr_has_exists (t: T.term) : T.Tac bool
let abstr_has_exists (t: T.term) : T.Tac bool = | true | null | false | match T.inspect t with
| T.Tv_Abs _ body -> term_has_head body (`exists_)
| _ -> false | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.Types.binder",
"Steel.ST.GenElim.Base.term_has_head",
"Prims.bool",
"FStar.Reflection.V1.Data.term_view",
"FStar.Tactics.V1.Builtins.inspect"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash]
let is_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar]
let rec term_has_head
(t: T.term)
(head: T.term)
: T.Tac bool
= let (hd, tl) = T.collect_app t in
if hd `T.term_eq_old` head
then true
else if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit; td, T.Q_Explicit] ->
if term_has_head tg head
then true
else term_has_head td head
| _ -> false
else false
let rec solve_gen_unit_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`pure))
then T.mk_app (`GUEId) [tl', T.Q_Explicit]
else
let (hd, tl) = T.collect_app tl' in
if hd `is_fvar` (`%pure)
then T.mk_app (`GUEPure) tl
else if is_star_or_vstar hd
then match tl with
| [t1, T.Q_Explicit; t2, T.Q_Explicit] ->
let t1' = solve_gen_unit_elim t1 in
let t2' = solve_gen_unit_elim t2 in
T.mk_app (`GUEStar) [t1', T.Q_Explicit; t2', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GUEId) [tl', T.Q_Explicit]
let abstr_has_exists
(t: T.term) | false | false | Steel.ST.GenElim.Base.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 abstr_has_exists (t: T.term) : T.Tac bool | [] | Steel.ST.GenElim.Base.abstr_has_exists | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool | {
"end_col": 14,
"end_line": 347,
"start_col": 2,
"start_line": 345
} |
FStar.Tactics.Effect.Tac | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let init_resolve_tac () = init_resolve_tac'
[(`gen_elim_prop_placeholder), solve_gen_elim_prop_placeholder] | let init_resolve_tac () = | true | null | false | init_resolve_tac' [(`gen_elim_prop_placeholder), solve_gen_elim_prop_placeholder] | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"Prims.unit",
"Steel.Effect.Common.init_resolve_tac'",
"Prims.Cons",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.term",
"Prims.bool",
"FStar.Pervasives.Native.Mktuple2",
"Steel.ST.GenElim.Base.solve_gen_elim_prop_placeholder",
"Prims.Nil"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash]
let is_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar]
let rec term_has_head
(t: T.term)
(head: T.term)
: T.Tac bool
= let (hd, tl) = T.collect_app t in
if hd `T.term_eq_old` head
then true
else if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit; td, T.Q_Explicit] ->
if term_has_head tg head
then true
else term_has_head td head
| _ -> false
else false
let rec solve_gen_unit_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`pure))
then T.mk_app (`GUEId) [tl', T.Q_Explicit]
else
let (hd, tl) = T.collect_app tl' in
if hd `is_fvar` (`%pure)
then T.mk_app (`GUEPure) tl
else if is_star_or_vstar hd
then match tl with
| [t1, T.Q_Explicit; t2, T.Q_Explicit] ->
let t1' = solve_gen_unit_elim t1 in
let t2' = solve_gen_unit_elim t2 in
T.mk_app (`GUEStar) [t1', T.Q_Explicit; t2', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GUEId) [tl', T.Q_Explicit]
let abstr_has_exists
(t: T.term)
: T.Tac bool
= match T.inspect t with
| T.Tv_Abs _ body -> term_has_head body (`exists_)
| _ -> false
let rec solve_gen_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`exists_))
then begin
let t' = solve_gen_unit_elim tl' in
T.mk_app (`GEUnit) [t', T.Q_Explicit]
end else
let (hd, lbody) = T.collect_app tl' in
if hd `is_fvar` (`%exists_)
then
let (ty, body) =
match lbody with
| [(ty, T.Q_Implicit); (body, T.Q_Explicit)] -> ([(ty, T.Q_Implicit)], body)
| [(body, T.Q_Explicit)] -> ([], body)
| _ -> T.fail "ill-formed exists_"
in
begin match T.inspect body with
| T.Tv_Abs b abody ->
if not (term_has_head abody (`exists_))
then
let body' = solve_gen_unit_elim abody in
T.mk_app (`GEExistsUnit) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
else
let body' = solve_gen_elim abody in
T.mk_app (`GEExists) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
| _ ->
T.mk_app (`GEExistsNoAbs) lbody
end
else if is_star_or_vstar hd
then
match lbody with
| [(tl, T.Q_Explicit); (tr, T.Q_Explicit)] ->
if term_has_head tl (`exists_)
then
let tl' = solve_gen_elim tl in
if term_has_head tr (`exists_)
then
let tr' = solve_gen_elim tr in
T.mk_app (`GEStar) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else
let tr' = solve_gen_unit_elim tr in
T.mk_app (`GEStarL) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else (* here, term_has_head tr (`exists_) holds, because otherwise we are in case (not (term_has_head tl (`exists_))) above *)
let tl' = solve_gen_unit_elim tl in
let tr' = solve_gen_elim tr in
T.mk_app (`GEStarR) [tl', T.Q_Explicit; tr', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GEUnit) [T.mk_app (`GUEId) lbody, T.Q_Explicit]
[@@ noextract_to "Plugin"]
val gen_elim_prop
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
val gen_elim_prop_intro'
(i: gen_elim_i)
(j: gen_elim_nondep_t)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i j))
(sq_a: squash (a == compute_gen_elim_nondep_a i j))
(sq_q: squash (q == compute_gen_elim_nondep_q i j))
(sq_post: squash (post == compute_gen_elim_nondep_post i j))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
let gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a: squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_q: squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_post: squash (post == compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
= gen_elim_prop_intro' i (mk_gen_elim_nondep ty tvprop q0 tprop post0) enable_nondep_opt p a q post sq_p sq_j sq_a sq_q sq_post
val gen_elim_prop_elim
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Ghost (gen_elim_i & gen_elim_nondep_t)
(requires gen_elim_prop enable_nondep_opt p a q post)
(ensures (fun (i, j) ->
p == compute_gen_elim_p i /\
check_gen_elim_nondep_sem i j /\
a == compute_gen_elim_nondep_a i j /\
q == compute_gen_elim_nondep_q i j /\
post == compute_gen_elim_nondep_post i j
))
[@@noextract_to "Plugin"]
let gen_elim_prop_placeholder
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
= True
let gen_elim_prop_placeholder_intro
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Lemma (gen_elim_prop_placeholder enable_nondep_opt p a q post)
= ()
let rec solve_gen_elim_nondep' (fuel: nat) (rev_types_and_binders: list (T.term & T.binder)) (t: T.term) : T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) =
if fuel = 0
then None
else
let (hd, tl) = T.collect_app t in
if hd `is_fvar` (`%TRet)
then match tl with
| [(v, T.Q_Explicit); (p, T.Q_Explicit)] ->
let cons_type (accu: (unit -> T.Tac T.term)) (tb: (T.term & T.binder)) () : T.Tac T.term =
let (ty, _) = tb in
let tl = accu () in
T.mk_app (`Cons) [(`Type0), T.Q_Implicit; ty, T.Q_Explicit; tl, T.Q_Explicit]
in
let nil_type () : T.Tac T.term = T.mk_app (`Nil) [(`Type0), T.Q_Implicit] in
let type_list = List.Tot.fold_left cons_type nil_type rev_types_and_binders () in
let type_list_typechecks =
let open T in
try
let env = cur_env () in
let ty = tc env type_list in
ty `term_eq_old` (`(list Type0))
with _ -> false
in
if not type_list_typechecks
then None
else
let binders = List.Tot.map snd (List.Tot.rev rev_types_and_binders) in
let norm_term = T.norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] in
let v' = T.mk_abs binders v in
let tv' = norm_term (T.mk_app (`curried_function_type) [type_list, T.Q_Explicit; (`vprop), T.Q_Explicit]) in
let p' = T.mk_abs binders p in
let tp' = norm_term (T.mk_app (`curried_function_type) [type_list, T.Q_Explicit; (`prop), T.Q_Explicit]) in
Some (Mktuple5
type_list
tv'
v'
tp'
p'
)
| _ -> None
else if hd `is_fvar` (`%TExists)
then match tl with
| [(ty, _); (f, T.Q_Explicit)] ->
begin match T.inspect f with
| T.Tv_Abs bv body -> solve_gen_elim_nondep' (fuel - 1) ((ty, bv) :: rev_types_and_binders) body
| _ -> None
end
| _ -> None
else None
let solve_gen_elim_nondep0 (enable_nondep_opt: bool) (t: T.term) : T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) =
if enable_nondep_opt
then
let open T in
try
let tele = mk_app (`compute_gen_elim_tele) [t, Q_Explicit] in
let t' = norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] tele in
solve_gen_elim_nondep' 15 [] t' // fuel necessary because F* standard tuple types only go from 0 up to 14 elts
with _ -> None
else None
let solve_gen_elim_nondep (enable_nondep_opt: bool) (t: T.term) : T.Tac T.term =
match solve_gen_elim_nondep0 enable_nondep_opt t with
| None -> (`GEDep)
| Some (Mktuple5
type_list
tv'
v'
tp'
p'
) -> T.mk_app (`mk_gen_elim_nondep_by_tac) [
type_list, T.Q_Explicit;
tv', T.Q_Explicit;
v', T.Q_Explicit;
tp', T.Q_Explicit;
p', T.Q_Explicit;
]
let solve_gen_elim_prop
()
: T.Tac unit
=
let (hd, tl) = T.collect_app (T.cur_goal ()) in
if not (is_squash hd)
then T.fail "not a squash goal";
match tl with
| [body1, T.Q_Explicit] ->
let (hd1, tl1) = T.collect_app body1 in
if not (hd1 `is_fvar` (`%gen_elim_prop))
then T.fail "not a gen_elim_prop goal";
begin match List.Tot.filter (fun (_, x) -> T.Q_Explicit? x) tl1 with
| [(enable_nondep_opt_tm, _); (p, _); (a, _); (q, _); (post, _)] ->
let enable_nondep_opt = enable_nondep_opt_tm `T.term_eq_old` (`true) in
let i' = solve_gen_elim p in
let norm () = T.norm [delta_attr [(`%gen_elim_reduce)]; zeta; iota] in
begin match solve_gen_elim_nondep0 enable_nondep_opt i' with
| None ->
T.apply_lemma (T.mk_app (`gen_elim_prop_intro') [
i', T.Q_Explicit;
(`GEDep), T.Q_Explicit;
])
| Some (Mktuple5 type_list tvprop q0 tprop post0) ->
T.apply_lemma (T.mk_app (`gen_elim_prop_intro) [
i', T.Q_Explicit;
type_list, T.Q_Explicit;
tvprop, T.Q_Explicit;
q0, T.Q_Explicit;
tprop, T.Q_Explicit;
post0, T.Q_Explicit;
]);
T.focus (fun _ -> norm (); T.trefl ()); // tvprop
T.focus (fun _ -> norm (); T.trefl ()) // tprop
end;
T.focus (fun _ -> norm (); T.trefl ()); // p
T.focus (fun _ -> norm (); T.trivial (); T.qed ()); // j
T.focus (fun _ -> norm (); T.trefl ()); // a
T.focus (fun _ -> norm (); T.trefl ()); // q
T.focus (fun _ -> norm (); T.trefl ()) // post
| _ -> T.fail "ill formed gen_elim_prop"
end
| _ -> T.fail "ill-formed squash"
let solve_gen_elim_prop_placeholder
()
: T.Tac bool
=
let (hd, tl) = T.collect_app (T.cur_goal ()) in
if not (is_squash hd)
then T.fail "not a squash goal";
match tl with
| [body1, T.Q_Explicit] ->
let (hd1, tl1) = T.collect_app body1 in
if not (hd1 `is_fvar` (`%gen_elim_prop_placeholder))
then T.fail "not a gen_elim_prop_placeholder goal";
begin match List.Tot.filter (fun (_, x) -> T.Q_Explicit? x) tl1 with
| [(enable_nondep_opt_tm, _); (p, _); (a, _); (q, _); (post, _)] ->
if slterm_nbr_uvars p <> 0
then T.fail "pre-resource not solved yet";
let a_is_uvar = T.Tv_Uvar? (T.inspect a) in
let q_is_uvar = T.Tv_Uvar? (T.inspect q) in
let post_is_uvar = T.Tv_Uvar? (T.inspect post) in
if not (a_is_uvar && q_is_uvar && post_is_uvar)
then T.fail "gen_elim_prop_placeholder is already solved";
let enable_nondep_opt = enable_nondep_opt_tm `T.term_eq_old` (`true) in
let i' = solve_gen_elim p in
let j' = solve_gen_elim_nondep enable_nondep_opt i' in
let norm_term = T.norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] in
let a' = norm_term (T.mk_app (`compute_gen_elim_nondep_a) [i', T.Q_Explicit; j', T.Q_Explicit]) in
let q' = norm_term (T.mk_app (`compute_gen_elim_nondep_q) [i', T.Q_Explicit; j', T.Q_Explicit]) in
let post' = norm_term (T.mk_app (`compute_gen_elim_nondep_post) [i', T.Q_Explicit; j', T.Q_Explicit]) in
T.unshelve a;
T.exact a';
T.unshelve q;
T.exact q';
T.unshelve post;
T.exact post';
T.apply_lemma (`gen_elim_prop_placeholder_intro);
true
| _ -> T.fail "ill-formed gen_elim_prop_placeholder"
end
| _ -> T.fail "ill-formed squash"
[@@ resolve_implicits; framing_implicit; plugin; | false | false | Steel.ST.GenElim.Base.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 init_resolve_tac : _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit | [] | Steel.ST.GenElim.Base.init_resolve_tac | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit | {
"end_col": 65,
"end_line": 649,
"start_col": 26,
"start_line": 648
} |
|
FStar.Tactics.Effect.Tac | val solve_gen_elim_nondep0 (enable_nondep_opt: bool) (t: T.term)
: T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let solve_gen_elim_nondep0 (enable_nondep_opt: bool) (t: T.term) : T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) =
if enable_nondep_opt
then
let open T in
try
let tele = mk_app (`compute_gen_elim_tele) [t, Q_Explicit] in
let t' = norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] tele in
solve_gen_elim_nondep' 15 [] t' // fuel necessary because F* standard tuple types only go from 0 up to 14 elts
with _ -> None
else None | val solve_gen_elim_nondep0 (enable_nondep_opt: bool) (t: T.term)
: T.Tac (option (tuple5 T.term T.term T.term T.term T.term))
let solve_gen_elim_nondep0 (enable_nondep_opt: bool) (t: T.term)
: T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) = | true | null | false | if enable_nondep_opt
then
let open T in
try
let tele = mk_app (`compute_gen_elim_tele) [t, Q_Explicit] in
let t' = norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] tele in
solve_gen_elim_nondep' 15 [] t'
with
| _ -> None
else None | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"Prims.bool",
"FStar.Reflection.Types.term",
"FStar.Tactics.V1.Derived.try_with",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple5",
"Prims.unit",
"Steel.ST.GenElim.Base.solve_gen_elim_nondep'",
"Prims.Nil",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.binder",
"FStar.Tactics.V1.Derived.norm_term",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"FStar.Reflection.V1.Derived.mk_app",
"FStar.Reflection.V1.Data.argv",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V1.Data.aqualv",
"FStar.Reflection.V1.Data.Q_Explicit",
"Prims.exn",
"FStar.Pervasives.Native.None"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash]
let is_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar]
let rec term_has_head
(t: T.term)
(head: T.term)
: T.Tac bool
= let (hd, tl) = T.collect_app t in
if hd `T.term_eq_old` head
then true
else if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit; td, T.Q_Explicit] ->
if term_has_head tg head
then true
else term_has_head td head
| _ -> false
else false
let rec solve_gen_unit_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`pure))
then T.mk_app (`GUEId) [tl', T.Q_Explicit]
else
let (hd, tl) = T.collect_app tl' in
if hd `is_fvar` (`%pure)
then T.mk_app (`GUEPure) tl
else if is_star_or_vstar hd
then match tl with
| [t1, T.Q_Explicit; t2, T.Q_Explicit] ->
let t1' = solve_gen_unit_elim t1 in
let t2' = solve_gen_unit_elim t2 in
T.mk_app (`GUEStar) [t1', T.Q_Explicit; t2', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GUEId) [tl', T.Q_Explicit]
let abstr_has_exists
(t: T.term)
: T.Tac bool
= match T.inspect t with
| T.Tv_Abs _ body -> term_has_head body (`exists_)
| _ -> false
let rec solve_gen_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`exists_))
then begin
let t' = solve_gen_unit_elim tl' in
T.mk_app (`GEUnit) [t', T.Q_Explicit]
end else
let (hd, lbody) = T.collect_app tl' in
if hd `is_fvar` (`%exists_)
then
let (ty, body) =
match lbody with
| [(ty, T.Q_Implicit); (body, T.Q_Explicit)] -> ([(ty, T.Q_Implicit)], body)
| [(body, T.Q_Explicit)] -> ([], body)
| _ -> T.fail "ill-formed exists_"
in
begin match T.inspect body with
| T.Tv_Abs b abody ->
if not (term_has_head abody (`exists_))
then
let body' = solve_gen_unit_elim abody in
T.mk_app (`GEExistsUnit) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
else
let body' = solve_gen_elim abody in
T.mk_app (`GEExists) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
| _ ->
T.mk_app (`GEExistsNoAbs) lbody
end
else if is_star_or_vstar hd
then
match lbody with
| [(tl, T.Q_Explicit); (tr, T.Q_Explicit)] ->
if term_has_head tl (`exists_)
then
let tl' = solve_gen_elim tl in
if term_has_head tr (`exists_)
then
let tr' = solve_gen_elim tr in
T.mk_app (`GEStar) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else
let tr' = solve_gen_unit_elim tr in
T.mk_app (`GEStarL) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else (* here, term_has_head tr (`exists_) holds, because otherwise we are in case (not (term_has_head tl (`exists_))) above *)
let tl' = solve_gen_unit_elim tl in
let tr' = solve_gen_elim tr in
T.mk_app (`GEStarR) [tl', T.Q_Explicit; tr', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GEUnit) [T.mk_app (`GUEId) lbody, T.Q_Explicit]
[@@ noextract_to "Plugin"]
val gen_elim_prop
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
val gen_elim_prop_intro'
(i: gen_elim_i)
(j: gen_elim_nondep_t)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i j))
(sq_a: squash (a == compute_gen_elim_nondep_a i j))
(sq_q: squash (q == compute_gen_elim_nondep_q i j))
(sq_post: squash (post == compute_gen_elim_nondep_post i j))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
let gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a: squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_q: squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_post: squash (post == compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
= gen_elim_prop_intro' i (mk_gen_elim_nondep ty tvprop q0 tprop post0) enable_nondep_opt p a q post sq_p sq_j sq_a sq_q sq_post
val gen_elim_prop_elim
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Ghost (gen_elim_i & gen_elim_nondep_t)
(requires gen_elim_prop enable_nondep_opt p a q post)
(ensures (fun (i, j) ->
p == compute_gen_elim_p i /\
check_gen_elim_nondep_sem i j /\
a == compute_gen_elim_nondep_a i j /\
q == compute_gen_elim_nondep_q i j /\
post == compute_gen_elim_nondep_post i j
))
[@@noextract_to "Plugin"]
let gen_elim_prop_placeholder
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
= True
let gen_elim_prop_placeholder_intro
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Lemma (gen_elim_prop_placeholder enable_nondep_opt p a q post)
= ()
let rec solve_gen_elim_nondep' (fuel: nat) (rev_types_and_binders: list (T.term & T.binder)) (t: T.term) : T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) =
if fuel = 0
then None
else
let (hd, tl) = T.collect_app t in
if hd `is_fvar` (`%TRet)
then match tl with
| [(v, T.Q_Explicit); (p, T.Q_Explicit)] ->
let cons_type (accu: (unit -> T.Tac T.term)) (tb: (T.term & T.binder)) () : T.Tac T.term =
let (ty, _) = tb in
let tl = accu () in
T.mk_app (`Cons) [(`Type0), T.Q_Implicit; ty, T.Q_Explicit; tl, T.Q_Explicit]
in
let nil_type () : T.Tac T.term = T.mk_app (`Nil) [(`Type0), T.Q_Implicit] in
let type_list = List.Tot.fold_left cons_type nil_type rev_types_and_binders () in
let type_list_typechecks =
let open T in
try
let env = cur_env () in
let ty = tc env type_list in
ty `term_eq_old` (`(list Type0))
with _ -> false
in
if not type_list_typechecks
then None
else
let binders = List.Tot.map snd (List.Tot.rev rev_types_and_binders) in
let norm_term = T.norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] in
let v' = T.mk_abs binders v in
let tv' = norm_term (T.mk_app (`curried_function_type) [type_list, T.Q_Explicit; (`vprop), T.Q_Explicit]) in
let p' = T.mk_abs binders p in
let tp' = norm_term (T.mk_app (`curried_function_type) [type_list, T.Q_Explicit; (`prop), T.Q_Explicit]) in
Some (Mktuple5
type_list
tv'
v'
tp'
p'
)
| _ -> None
else if hd `is_fvar` (`%TExists)
then match tl with
| [(ty, _); (f, T.Q_Explicit)] ->
begin match T.inspect f with
| T.Tv_Abs bv body -> solve_gen_elim_nondep' (fuel - 1) ((ty, bv) :: rev_types_and_binders) body
| _ -> None
end
| _ -> None
else None | false | false | Steel.ST.GenElim.Base.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 solve_gen_elim_nondep0 (enable_nondep_opt: bool) (t: T.term)
: T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) | [] | Steel.ST.GenElim.Base.solve_gen_elim_nondep0 | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | enable_nondep_opt: Prims.bool -> t: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac
(FStar.Pervasives.Native.option ((((FStar.Reflection.Types.term * FStar.Reflection.Types.term) *
FStar.Reflection.Types.term) *
FStar.Reflection.Types.term) *
FStar.Reflection.Types.term)) | {
"end_col": 11,
"end_line": 543,
"start_col": 2,
"start_line": 535
} |
FStar.Tactics.Effect.Tac | val term_has_head (t head: T.term) : T.Tac bool | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 term_has_head
(t: T.term)
(head: T.term)
: T.Tac bool
= let (hd, tl) = T.collect_app t in
if hd `T.term_eq_old` head
then true
else if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit; td, T.Q_Explicit] ->
if term_has_head tg head
then true
else term_has_head td head
| _ -> false
else false | val term_has_head (t head: T.term) : T.Tac bool
let rec term_has_head (t head: T.term) : T.Tac bool = | true | null | false | let hd, tl = T.collect_app t in
if hd `T.term_eq_old` head
then true
else
if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit ; td, T.Q_Explicit] ->
if term_has_head tg head then true else term_has_head td head
| _ -> false
else false | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Reflection.V1.Data.argv",
"Prims.bool",
"Steel.ST.GenElim.Base.term_has_head",
"Steel.ST.GenElim.Base.is_star_or_vstar",
"FStar.Tactics.V1.Builtins.term_eq_old",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.V1.SyntaxHelpers.collect_app"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash]
let is_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar]
let rec term_has_head
(t: T.term)
(head: T.term) | false | false | Steel.ST.GenElim.Base.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 term_has_head (t head: T.term) : T.Tac bool | [
"recursion"
] | Steel.ST.GenElim.Base.term_has_head | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: FStar.Reflection.Types.term -> head: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac Prims.bool | {
"end_col": 12,
"end_line": 320,
"start_col": 1,
"start_line": 309
} |
FStar.Tactics.Effect.Tac | val solve_gen_unit_elim (tl': T.term) : T.Tac T.term | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 solve_gen_unit_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`pure))
then T.mk_app (`GUEId) [tl', T.Q_Explicit]
else
let (hd, tl) = T.collect_app tl' in
if hd `is_fvar` (`%pure)
then T.mk_app (`GUEPure) tl
else if is_star_or_vstar hd
then match tl with
| [t1, T.Q_Explicit; t2, T.Q_Explicit] ->
let t1' = solve_gen_unit_elim t1 in
let t2' = solve_gen_unit_elim t2 in
T.mk_app (`GUEStar) [t1', T.Q_Explicit; t2', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GUEId) [tl', T.Q_Explicit] | val solve_gen_unit_elim (tl': T.term) : T.Tac T.term
let rec solve_gen_unit_elim (tl': T.term) : T.Tac T.term = | true | null | false | if not (term_has_head tl' (`pure))
then T.mk_app (`GUEId) [tl', T.Q_Explicit]
else
let hd, tl = T.collect_app tl' in
if hd `is_fvar` (`%pure)
then T.mk_app (`GUEPure) tl
else
if is_star_or_vstar hd
then
match tl with
| [t1, T.Q_Explicit ; t2, T.Q_Explicit] ->
let t1' = solve_gen_unit_elim t1 in
let t2' = solve_gen_unit_elim t2 in
T.mk_app (`GUEStar) [t1', T.Q_Explicit; t2', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else T.mk_app (`GUEId) [tl', T.Q_Explicit] | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Derived.mk_app",
"Prims.Cons",
"FStar.Reflection.V1.Data.argv",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V1.Data.aqualv",
"FStar.Reflection.V1.Data.Q_Explicit",
"Prims.Nil",
"Prims.bool",
"Prims.list",
"Steel.ST.GenElim.Base.is_fvar",
"Steel.ST.GenElim.Base.solve_gen_unit_elim",
"FStar.Tactics.V1.Derived.fail",
"Steel.ST.GenElim.Base.is_star_or_vstar",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.V1.SyntaxHelpers.collect_app",
"Prims.op_Negation",
"Steel.ST.GenElim.Base.term_has_head"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash]
let is_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar]
let rec term_has_head
(t: T.term)
(head: T.term)
: T.Tac bool
= let (hd, tl) = T.collect_app t in
if hd `T.term_eq_old` head
then true
else if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit; td, T.Q_Explicit] ->
if term_has_head tg head
then true
else term_has_head td head
| _ -> false
else false
let rec solve_gen_unit_elim
(tl': T.term)
: T.Tac T.term | false | false | Steel.ST.GenElim.Base.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 solve_gen_unit_elim (tl': T.term) : T.Tac T.term | [
"recursion"
] | Steel.ST.GenElim.Base.solve_gen_unit_elim | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | tl': FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 47,
"end_line": 340,
"start_col": 6,
"start_line": 326
} |
FStar.Tactics.Effect.Tac | val solve_gen_elim (tl': T.term) : T.Tac T.term | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 solve_gen_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`exists_))
then begin
let t' = solve_gen_unit_elim tl' in
T.mk_app (`GEUnit) [t', T.Q_Explicit]
end else
let (hd, lbody) = T.collect_app tl' in
if hd `is_fvar` (`%exists_)
then
let (ty, body) =
match lbody with
| [(ty, T.Q_Implicit); (body, T.Q_Explicit)] -> ([(ty, T.Q_Implicit)], body)
| [(body, T.Q_Explicit)] -> ([], body)
| _ -> T.fail "ill-formed exists_"
in
begin match T.inspect body with
| T.Tv_Abs b abody ->
if not (term_has_head abody (`exists_))
then
let body' = solve_gen_unit_elim abody in
T.mk_app (`GEExistsUnit) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
else
let body' = solve_gen_elim abody in
T.mk_app (`GEExists) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
| _ ->
T.mk_app (`GEExistsNoAbs) lbody
end
else if is_star_or_vstar hd
then
match lbody with
| [(tl, T.Q_Explicit); (tr, T.Q_Explicit)] ->
if term_has_head tl (`exists_)
then
let tl' = solve_gen_elim tl in
if term_has_head tr (`exists_)
then
let tr' = solve_gen_elim tr in
T.mk_app (`GEStar) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else
let tr' = solve_gen_unit_elim tr in
T.mk_app (`GEStarL) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else (* here, term_has_head tr (`exists_) holds, because otherwise we are in case (not (term_has_head tl (`exists_))) above *)
let tl' = solve_gen_unit_elim tl in
let tr' = solve_gen_elim tr in
T.mk_app (`GEStarR) [tl', T.Q_Explicit; tr', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GEUnit) [T.mk_app (`GUEId) lbody, T.Q_Explicit] | val solve_gen_elim (tl': T.term) : T.Tac T.term
let rec solve_gen_elim (tl': T.term) : T.Tac T.term = | true | null | false | if not (term_has_head tl' (`exists_))
then
let t' = solve_gen_unit_elim tl' in
T.mk_app (`GEUnit) [t', T.Q_Explicit]
else
let hd, lbody = T.collect_app tl' in
if hd `is_fvar` (`%exists_)
then
let ty, body =
match lbody with
| [ty, T.Q_Implicit ; body, T.Q_Explicit] -> ([(ty, T.Q_Implicit)], body)
| [body, T.Q_Explicit] -> ([], body)
| _ -> T.fail "ill-formed exists_"
in
match T.inspect body with
| T.Tv_Abs b abody ->
if not (term_has_head abody (`exists_))
then
let body' = solve_gen_unit_elim abody in
T.mk_app (`GEExistsUnit) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
else
let body' = solve_gen_elim abody in
T.mk_app (`GEExists) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
| _ -> T.mk_app (`GEExistsNoAbs) lbody
else
if is_star_or_vstar hd
then
match lbody with
| [tl, T.Q_Explicit ; tr, T.Q_Explicit] ->
if term_has_head tl (`exists_)
then
let tl' = solve_gen_elim tl in
if term_has_head tr (`exists_)
then
let tr' = solve_gen_elim tr in
T.mk_app (`GEStar) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else
let tr' = solve_gen_unit_elim tr in
T.mk_app (`GEStarL) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else
let tl' = solve_gen_unit_elim tl in
let tr' = solve_gen_elim tr in
T.mk_app (`GEStarR) [tl', T.Q_Explicit; tr', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else T.mk_app (`GEUnit) [T.mk_app (`GUEId) lbody, T.Q_Explicit] | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Derived.mk_app",
"Prims.Cons",
"FStar.Reflection.V1.Data.argv",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V1.Data.aqualv",
"FStar.Reflection.V1.Data.Q_Explicit",
"Prims.Nil",
"Steel.ST.GenElim.Base.solve_gen_unit_elim",
"Prims.bool",
"Prims.list",
"Steel.ST.GenElim.Base.is_fvar",
"FStar.Reflection.Types.binder",
"FStar.List.Tot.Base.append",
"FStar.Tactics.V1.Derived.mk_abs",
"Steel.ST.GenElim.Base.solve_gen_elim",
"Prims.op_Negation",
"Steel.ST.GenElim.Base.term_has_head",
"FStar.Reflection.V1.Data.term_view",
"FStar.Tactics.V1.Builtins.inspect",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.V1.Data.Q_Implicit",
"FStar.Tactics.V1.Derived.fail",
"Steel.ST.GenElim.Base.is_star_or_vstar",
"FStar.Tactics.V1.SyntaxHelpers.collect_app"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash]
let is_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar]
let rec term_has_head
(t: T.term)
(head: T.term)
: T.Tac bool
= let (hd, tl) = T.collect_app t in
if hd `T.term_eq_old` head
then true
else if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit; td, T.Q_Explicit] ->
if term_has_head tg head
then true
else term_has_head td head
| _ -> false
else false
let rec solve_gen_unit_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`pure))
then T.mk_app (`GUEId) [tl', T.Q_Explicit]
else
let (hd, tl) = T.collect_app tl' in
if hd `is_fvar` (`%pure)
then T.mk_app (`GUEPure) tl
else if is_star_or_vstar hd
then match tl with
| [t1, T.Q_Explicit; t2, T.Q_Explicit] ->
let t1' = solve_gen_unit_elim t1 in
let t2' = solve_gen_unit_elim t2 in
T.mk_app (`GUEStar) [t1', T.Q_Explicit; t2', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GUEId) [tl', T.Q_Explicit]
let abstr_has_exists
(t: T.term)
: T.Tac bool
= match T.inspect t with
| T.Tv_Abs _ body -> term_has_head body (`exists_)
| _ -> false
let rec solve_gen_elim
(tl': T.term)
: T.Tac T.term | false | false | Steel.ST.GenElim.Base.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 solve_gen_elim (tl': T.term) : T.Tac T.term | [
"recursion"
] | Steel.ST.GenElim.Base.solve_gen_elim | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | tl': FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 68,
"end_line": 399,
"start_col": 6,
"start_line": 353
} |
FStar.Tactics.Effect.Tac | val solve_gen_elim_prop_placeholder: Prims.unit -> T.Tac bool | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let solve_gen_elim_prop_placeholder
()
: T.Tac bool
=
let (hd, tl) = T.collect_app (T.cur_goal ()) in
if not (is_squash hd)
then T.fail "not a squash goal";
match tl with
| [body1, T.Q_Explicit] ->
let (hd1, tl1) = T.collect_app body1 in
if not (hd1 `is_fvar` (`%gen_elim_prop_placeholder))
then T.fail "not a gen_elim_prop_placeholder goal";
begin match List.Tot.filter (fun (_, x) -> T.Q_Explicit? x) tl1 with
| [(enable_nondep_opt_tm, _); (p, _); (a, _); (q, _); (post, _)] ->
if slterm_nbr_uvars p <> 0
then T.fail "pre-resource not solved yet";
let a_is_uvar = T.Tv_Uvar? (T.inspect a) in
let q_is_uvar = T.Tv_Uvar? (T.inspect q) in
let post_is_uvar = T.Tv_Uvar? (T.inspect post) in
if not (a_is_uvar && q_is_uvar && post_is_uvar)
then T.fail "gen_elim_prop_placeholder is already solved";
let enable_nondep_opt = enable_nondep_opt_tm `T.term_eq_old` (`true) in
let i' = solve_gen_elim p in
let j' = solve_gen_elim_nondep enable_nondep_opt i' in
let norm_term = T.norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] in
let a' = norm_term (T.mk_app (`compute_gen_elim_nondep_a) [i', T.Q_Explicit; j', T.Q_Explicit]) in
let q' = norm_term (T.mk_app (`compute_gen_elim_nondep_q) [i', T.Q_Explicit; j', T.Q_Explicit]) in
let post' = norm_term (T.mk_app (`compute_gen_elim_nondep_post) [i', T.Q_Explicit; j', T.Q_Explicit]) in
T.unshelve a;
T.exact a';
T.unshelve q;
T.exact q';
T.unshelve post;
T.exact post';
T.apply_lemma (`gen_elim_prop_placeholder_intro);
true
| _ -> T.fail "ill-formed gen_elim_prop_placeholder"
end
| _ -> T.fail "ill-formed squash" | val solve_gen_elim_prop_placeholder: Prims.unit -> T.Tac bool
let solve_gen_elim_prop_placeholder () : T.Tac bool = | true | null | false | let hd, tl = T.collect_app (T.cur_goal ()) in
if not (is_squash hd) then T.fail "not a squash goal";
match tl with
| [body1, T.Q_Explicit] ->
let hd1, tl1 = T.collect_app body1 in
if not (hd1 `is_fvar` (`%gen_elim_prop_placeholder))
then T.fail "not a gen_elim_prop_placeholder goal";
(match List.Tot.filter (fun (_, x) -> T.Q_Explicit? x) tl1 with
| [enable_nondep_opt_tm, _ ; p, _ ; a, _ ; q, _ ; post, _] ->
if slterm_nbr_uvars p <> 0 then T.fail "pre-resource not solved yet";
let a_is_uvar = T.Tv_Uvar? (T.inspect a) in
let q_is_uvar = T.Tv_Uvar? (T.inspect q) in
let post_is_uvar = T.Tv_Uvar? (T.inspect post) in
if not (a_is_uvar && q_is_uvar && post_is_uvar)
then T.fail "gen_elim_prop_placeholder is already solved";
let enable_nondep_opt = enable_nondep_opt_tm `T.term_eq_old` (`true) in
let i' = solve_gen_elim p in
let j' = solve_gen_elim_nondep enable_nondep_opt i' in
let norm_term = T.norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] in
let a' =
norm_term (T.mk_app (`compute_gen_elim_nondep_a) [i', T.Q_Explicit; j', T.Q_Explicit])
in
let q' =
norm_term (T.mk_app (`compute_gen_elim_nondep_q) [i', T.Q_Explicit; j', T.Q_Explicit])
in
let post' =
norm_term (T.mk_app (`compute_gen_elim_nondep_post) [i', T.Q_Explicit; j', T.Q_Explicit])
in
T.unshelve a;
T.exact a';
T.unshelve q;
T.exact q';
T.unshelve post;
T.exact post';
T.apply_lemma (`gen_elim_prop_placeholder_intro);
true
| _ -> T.fail "ill-formed gen_elim_prop_placeholder")
| _ -> T.fail "ill-formed squash" | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"Prims.unit",
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Reflection.V1.Data.argv",
"FStar.List.Tot.Base.filter",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.V1.Data.aqualv",
"FStar.Reflection.V1.Data.uu___is_Q_Explicit",
"Prims.bool",
"FStar.Tactics.V1.Derived.apply_lemma",
"FStar.Tactics.V1.Derived.exact",
"FStar.Tactics.V1.Builtins.unshelve",
"FStar.Reflection.V1.Derived.mk_app",
"Prims.Cons",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V1.Data.Q_Explicit",
"Prims.Nil",
"FStar.Tactics.V1.Derived.norm_term",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"Steel.ST.GenElim.Base.solve_gen_elim_nondep",
"Steel.ST.GenElim.Base.solve_gen_elim",
"FStar.Tactics.V1.Builtins.term_eq_old",
"Prims.op_Negation",
"Prims.op_AmpAmp",
"FStar.Tactics.V1.Derived.fail",
"FStar.Reflection.V1.Data.uu___is_Tv_Uvar",
"FStar.Reflection.V1.Data.term_view",
"FStar.Tactics.V1.Builtins.inspect",
"Prims.op_disEquality",
"Prims.int",
"Steel.Effect.Common.slterm_nbr_uvars",
"Steel.ST.GenElim.Base.is_fvar",
"FStar.Tactics.V1.SyntaxHelpers.collect_app",
"Steel.ST.GenElim.Base.is_squash",
"FStar.Tactics.V1.Derived.cur_goal",
"FStar.Reflection.Types.typ"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash]
let is_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar]
let rec term_has_head
(t: T.term)
(head: T.term)
: T.Tac bool
= let (hd, tl) = T.collect_app t in
if hd `T.term_eq_old` head
then true
else if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit; td, T.Q_Explicit] ->
if term_has_head tg head
then true
else term_has_head td head
| _ -> false
else false
let rec solve_gen_unit_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`pure))
then T.mk_app (`GUEId) [tl', T.Q_Explicit]
else
let (hd, tl) = T.collect_app tl' in
if hd `is_fvar` (`%pure)
then T.mk_app (`GUEPure) tl
else if is_star_or_vstar hd
then match tl with
| [t1, T.Q_Explicit; t2, T.Q_Explicit] ->
let t1' = solve_gen_unit_elim t1 in
let t2' = solve_gen_unit_elim t2 in
T.mk_app (`GUEStar) [t1', T.Q_Explicit; t2', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GUEId) [tl', T.Q_Explicit]
let abstr_has_exists
(t: T.term)
: T.Tac bool
= match T.inspect t with
| T.Tv_Abs _ body -> term_has_head body (`exists_)
| _ -> false
let rec solve_gen_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`exists_))
then begin
let t' = solve_gen_unit_elim tl' in
T.mk_app (`GEUnit) [t', T.Q_Explicit]
end else
let (hd, lbody) = T.collect_app tl' in
if hd `is_fvar` (`%exists_)
then
let (ty, body) =
match lbody with
| [(ty, T.Q_Implicit); (body, T.Q_Explicit)] -> ([(ty, T.Q_Implicit)], body)
| [(body, T.Q_Explicit)] -> ([], body)
| _ -> T.fail "ill-formed exists_"
in
begin match T.inspect body with
| T.Tv_Abs b abody ->
if not (term_has_head abody (`exists_))
then
let body' = solve_gen_unit_elim abody in
T.mk_app (`GEExistsUnit) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
else
let body' = solve_gen_elim abody in
T.mk_app (`GEExists) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
| _ ->
T.mk_app (`GEExistsNoAbs) lbody
end
else if is_star_or_vstar hd
then
match lbody with
| [(tl, T.Q_Explicit); (tr, T.Q_Explicit)] ->
if term_has_head tl (`exists_)
then
let tl' = solve_gen_elim tl in
if term_has_head tr (`exists_)
then
let tr' = solve_gen_elim tr in
T.mk_app (`GEStar) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else
let tr' = solve_gen_unit_elim tr in
T.mk_app (`GEStarL) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else (* here, term_has_head tr (`exists_) holds, because otherwise we are in case (not (term_has_head tl (`exists_))) above *)
let tl' = solve_gen_unit_elim tl in
let tr' = solve_gen_elim tr in
T.mk_app (`GEStarR) [tl', T.Q_Explicit; tr', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GEUnit) [T.mk_app (`GUEId) lbody, T.Q_Explicit]
[@@ noextract_to "Plugin"]
val gen_elim_prop
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
val gen_elim_prop_intro'
(i: gen_elim_i)
(j: gen_elim_nondep_t)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i j))
(sq_a: squash (a == compute_gen_elim_nondep_a i j))
(sq_q: squash (q == compute_gen_elim_nondep_q i j))
(sq_post: squash (post == compute_gen_elim_nondep_post i j))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
let gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a: squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_q: squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_post: squash (post == compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
= gen_elim_prop_intro' i (mk_gen_elim_nondep ty tvprop q0 tprop post0) enable_nondep_opt p a q post sq_p sq_j sq_a sq_q sq_post
val gen_elim_prop_elim
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Ghost (gen_elim_i & gen_elim_nondep_t)
(requires gen_elim_prop enable_nondep_opt p a q post)
(ensures (fun (i, j) ->
p == compute_gen_elim_p i /\
check_gen_elim_nondep_sem i j /\
a == compute_gen_elim_nondep_a i j /\
q == compute_gen_elim_nondep_q i j /\
post == compute_gen_elim_nondep_post i j
))
[@@noextract_to "Plugin"]
let gen_elim_prop_placeholder
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
= True
let gen_elim_prop_placeholder_intro
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Lemma (gen_elim_prop_placeholder enable_nondep_opt p a q post)
= ()
let rec solve_gen_elim_nondep' (fuel: nat) (rev_types_and_binders: list (T.term & T.binder)) (t: T.term) : T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) =
if fuel = 0
then None
else
let (hd, tl) = T.collect_app t in
if hd `is_fvar` (`%TRet)
then match tl with
| [(v, T.Q_Explicit); (p, T.Q_Explicit)] ->
let cons_type (accu: (unit -> T.Tac T.term)) (tb: (T.term & T.binder)) () : T.Tac T.term =
let (ty, _) = tb in
let tl = accu () in
T.mk_app (`Cons) [(`Type0), T.Q_Implicit; ty, T.Q_Explicit; tl, T.Q_Explicit]
in
let nil_type () : T.Tac T.term = T.mk_app (`Nil) [(`Type0), T.Q_Implicit] in
let type_list = List.Tot.fold_left cons_type nil_type rev_types_and_binders () in
let type_list_typechecks =
let open T in
try
let env = cur_env () in
let ty = tc env type_list in
ty `term_eq_old` (`(list Type0))
with _ -> false
in
if not type_list_typechecks
then None
else
let binders = List.Tot.map snd (List.Tot.rev rev_types_and_binders) in
let norm_term = T.norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] in
let v' = T.mk_abs binders v in
let tv' = norm_term (T.mk_app (`curried_function_type) [type_list, T.Q_Explicit; (`vprop), T.Q_Explicit]) in
let p' = T.mk_abs binders p in
let tp' = norm_term (T.mk_app (`curried_function_type) [type_list, T.Q_Explicit; (`prop), T.Q_Explicit]) in
Some (Mktuple5
type_list
tv'
v'
tp'
p'
)
| _ -> None
else if hd `is_fvar` (`%TExists)
then match tl with
| [(ty, _); (f, T.Q_Explicit)] ->
begin match T.inspect f with
| T.Tv_Abs bv body -> solve_gen_elim_nondep' (fuel - 1) ((ty, bv) :: rev_types_and_binders) body
| _ -> None
end
| _ -> None
else None
let solve_gen_elim_nondep0 (enable_nondep_opt: bool) (t: T.term) : T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) =
if enable_nondep_opt
then
let open T in
try
let tele = mk_app (`compute_gen_elim_tele) [t, Q_Explicit] in
let t' = norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] tele in
solve_gen_elim_nondep' 15 [] t' // fuel necessary because F* standard tuple types only go from 0 up to 14 elts
with _ -> None
else None
let solve_gen_elim_nondep (enable_nondep_opt: bool) (t: T.term) : T.Tac T.term =
match solve_gen_elim_nondep0 enable_nondep_opt t with
| None -> (`GEDep)
| Some (Mktuple5
type_list
tv'
v'
tp'
p'
) -> T.mk_app (`mk_gen_elim_nondep_by_tac) [
type_list, T.Q_Explicit;
tv', T.Q_Explicit;
v', T.Q_Explicit;
tp', T.Q_Explicit;
p', T.Q_Explicit;
]
let solve_gen_elim_prop
()
: T.Tac unit
=
let (hd, tl) = T.collect_app (T.cur_goal ()) in
if not (is_squash hd)
then T.fail "not a squash goal";
match tl with
| [body1, T.Q_Explicit] ->
let (hd1, tl1) = T.collect_app body1 in
if not (hd1 `is_fvar` (`%gen_elim_prop))
then T.fail "not a gen_elim_prop goal";
begin match List.Tot.filter (fun (_, x) -> T.Q_Explicit? x) tl1 with
| [(enable_nondep_opt_tm, _); (p, _); (a, _); (q, _); (post, _)] ->
let enable_nondep_opt = enable_nondep_opt_tm `T.term_eq_old` (`true) in
let i' = solve_gen_elim p in
let norm () = T.norm [delta_attr [(`%gen_elim_reduce)]; zeta; iota] in
begin match solve_gen_elim_nondep0 enable_nondep_opt i' with
| None ->
T.apply_lemma (T.mk_app (`gen_elim_prop_intro') [
i', T.Q_Explicit;
(`GEDep), T.Q_Explicit;
])
| Some (Mktuple5 type_list tvprop q0 tprop post0) ->
T.apply_lemma (T.mk_app (`gen_elim_prop_intro) [
i', T.Q_Explicit;
type_list, T.Q_Explicit;
tvprop, T.Q_Explicit;
q0, T.Q_Explicit;
tprop, T.Q_Explicit;
post0, T.Q_Explicit;
]);
T.focus (fun _ -> norm (); T.trefl ()); // tvprop
T.focus (fun _ -> norm (); T.trefl ()) // tprop
end;
T.focus (fun _ -> norm (); T.trefl ()); // p
T.focus (fun _ -> norm (); T.trivial (); T.qed ()); // j
T.focus (fun _ -> norm (); T.trefl ()); // a
T.focus (fun _ -> norm (); T.trefl ()); // q
T.focus (fun _ -> norm (); T.trefl ()) // post
| _ -> T.fail "ill formed gen_elim_prop"
end
| _ -> T.fail "ill-formed squash"
let solve_gen_elim_prop_placeholder
() | false | false | Steel.ST.GenElim.Base.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 solve_gen_elim_prop_placeholder: Prims.unit -> T.Tac bool | [] | Steel.ST.GenElim.Base.solve_gen_elim_prop_placeholder | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.bool | {
"end_col": 35,
"end_line": 644,
"start_col": 1,
"start_line": 609
} |
Prims.Tot | val compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit | val compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 = | false | null | false | match ty with
| [] -> unit
| [t1] -> t1
| [t1 ; t2] -> tuple2 t1 t2
| [t1 ; t2 ; t3] -> tuple3 t1 t2 t3
| [t1 ; t2 ; t3 ; t4] -> tuple4 t1 t2 t3 t4
| [t1 ; t2 ; t3 ; t4 ; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10 ; t11] ->
tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10 ; t11 ; t12] ->
tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10 ; t11 ; t12 ; t13] ->
tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10 ; t11 ; t12 ; t13 ; t14] ->
tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Prims.list",
"Prims.unit",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple4",
"FStar.Pervasives.Native.tuple5",
"FStar.Pervasives.Native.tuple6",
"FStar.Pervasives.Native.tuple7",
"FStar.Pervasives.Native.tuple8",
"FStar.Pervasives.Native.tuple9",
"FStar.Pervasives.Native.tuple10",
"FStar.Pervasives.Native.tuple11",
"FStar.Pervasives.Native.tuple12",
"FStar.Pervasives.Native.tuple13",
"FStar.Pervasives.Native.tuple14"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"] | false | true | Steel.ST.GenElim.Base.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 compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 | [] | Steel.ST.GenElim.Base.compute_gen_elim_nondep_a' | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | ty: Prims.list Type0 -> Type0 | {
"end_col": 15,
"end_line": 250,
"start_col": 4,
"start_line": 234
} |
Prims.Tot | val check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True | val check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop = | false | null | false | match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Steel.ST.GenElim.Base.gen_elim_nondep_t",
"Prims.list",
"Steel.ST.GenElim.Base.curried_function_type",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Prims.eq2",
"Steel.ST.GenElim.Base.gen_elim_tele",
"Steel.ST.GenElim.Base.compute_gen_elim_tele",
"Steel.ST.GenElim.Base.gen_elim_nondep_sem",
"Prims.l_True"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"] | false | true | Steel.ST.GenElim.Base.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 check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop | [] | Steel.ST.GenElim.Base.check_gen_elim_nondep_sem | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i: Steel.ST.GenElim.Base.gen_elim_i -> nd: Steel.ST.GenElim.Base.gen_elim_nondep_t -> Prims.prop | {
"end_col": 17,
"end_line": 230,
"start_col": 2,
"start_line": 228
} |
Prims.Tot | val compute_gen_elim_p (x: gen_elim_i) : Tot vprop | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x)) | val compute_gen_elim_p (x: gen_elim_i) : Tot vprop
let rec compute_gen_elim_p (x: gen_elim_i) : Tot vprop = | false | null | false | match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> (compute_gen_elim_p left) `star` (compute_gen_unit_elim_p right)
| GEStarR left right -> (compute_gen_unit_elim_p left) `star` (compute_gen_elim_p right)
| GEStar left right -> (compute_gen_elim_p left) `star` (compute_gen_elim_p right)
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x)) | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Steel.ST.GenElim.Base.gen_unit_elim_i",
"Steel.ST.GenElim.Base.compute_gen_unit_elim_p",
"Steel.Effect.Common.star",
"Steel.ST.GenElim.Base.compute_gen_elim_p",
"Steel.Effect.Common.vprop",
"Steel.ST.Util.exists_"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i) | false | true | Steel.ST.GenElim.Base.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 compute_gen_elim_p (x: gen_elim_i) : Tot vprop | [
"recursion"
] | Steel.ST.GenElim.Base.compute_gen_elim_p | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Steel.ST.GenElim.Base.gen_elim_i -> Steel.Effect.Common.vprop | {
"end_col": 70,
"end_line": 69,
"start_col": 2,
"start_line": 62
} |
Prims.Tot | val compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0 | val compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 = | false | null | false | match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0 | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Steel.ST.GenElim.Base.gen_elim_nondep_t",
"Prims.list",
"Steel.ST.GenElim.Base.curried_function_type",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim.Base.compute_gen_elim_a"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"] | false | true | Steel.ST.GenElim.Base.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 compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 | [] | Steel.ST.GenElim.Base.compute_gen_elim_nondep_a | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i0: Steel.ST.GenElim.Base.gen_elim_i -> i: Steel.ST.GenElim.Base.gen_elim_nondep_t -> Type0 | {
"end_col": 34,
"end_line": 256,
"start_col": 2,
"start_line": 254
} |
Prims.Tot | val compute_gen_unit_elim_p (x: gen_unit_elim_i) : Tot vprop | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right | val compute_gen_unit_elim_p (x: gen_unit_elim_i) : Tot vprop
let rec compute_gen_unit_elim_p (x: gen_unit_elim_i) : Tot vprop = | false | null | false | match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> (compute_gen_unit_elim_p left) `star` (compute_gen_unit_elim_p right) | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_unit_elim_i",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.Util.pure",
"Steel.Effect.Common.star",
"Steel.ST.GenElim.Base.compute_gen_unit_elim_p"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i) | false | true | Steel.ST.GenElim.Base.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 compute_gen_unit_elim_p (x: gen_unit_elim_i) : Tot vprop | [
"recursion"
] | Steel.ST.GenElim.Base.compute_gen_unit_elim_p | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Steel.ST.GenElim.Base.gen_unit_elim_i -> Steel.Effect.Common.vprop | {
"end_col": 91,
"end_line": 38,
"start_col": 2,
"start_line": 35
} |
Prims.Tot | val compute_gen_unit_elim_post (x: gen_unit_elim_i) : Tot prop | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right | val compute_gen_unit_elim_post (x: gen_unit_elim_i) : Tot prop
let rec compute_gen_unit_elim_post (x: gen_unit_elim_i) : Tot prop = | false | null | false | match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_unit_elim_i",
"Steel.Effect.Common.vprop",
"Prims.l_True",
"Prims.prop",
"Prims.l_and",
"Steel.ST.GenElim.Base.compute_gen_unit_elim_post"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i) | false | true | Steel.ST.GenElim.Base.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 compute_gen_unit_elim_post (x: gen_unit_elim_i) : Tot prop | [
"recursion"
] | Steel.ST.GenElim.Base.compute_gen_unit_elim_post | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Steel.ST.GenElim.Base.gen_unit_elim_i -> Prims.prop | {
"end_col": 93,
"end_line": 56,
"start_col": 2,
"start_line": 53
} |
Prims.Tot | val compute_gen_elim_a (x: gen_elim_i) : Tot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x)) | val compute_gen_elim_a (x: gen_elim_i) : Tot Type0
let rec compute_gen_elim_a (x: gen_elim_i) : Tot Type0 = | false | null | false | match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _ | GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x)) | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Steel.ST.GenElim.Base.gen_unit_elim_i",
"Prims.unit",
"Steel.ST.GenElim.Base.compute_gen_elim_a",
"FStar.Pervasives.Native.tuple2",
"Steel.Effect.Common.vprop",
"Prims.dtuple2"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i) | false | true | Steel.ST.GenElim.Base.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 compute_gen_elim_a (x: gen_elim_i) : Tot Type0 | [
"recursion"
] | Steel.ST.GenElim.Base.compute_gen_elim_a | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Steel.ST.GenElim.Base.gen_elim_i -> Type0 | {
"end_col": 72,
"end_line": 84,
"start_col": 2,
"start_line": 77
} |
Prims.Tot | val tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p) | val tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i)
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) = | false | null | false | match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p) | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total",
""
] | [
"Steel.ST.GenElim.Base.gen_elim_tele",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim.Base.TRet",
"Steel.Effect.Common.star",
"Prims.l_and",
"Steel.ST.GenElim.Base.TExists",
"Steel.ST.GenElim.Base.tele_star_vprop"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce] | false | true | Steel.ST.GenElim.Base.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 tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) | [
"recursion"
] | Steel.ST.GenElim.Base.tele_star_vprop | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i: Steel.ST.GenElim.Base.gen_elim_tele -> v: Steel.Effect.Common.vprop -> p: Prims.prop
-> Prims.Tot Steel.ST.GenElim.Base.gen_elim_tele | {
"end_col": 67,
"end_line": 158,
"start_col": 2,
"start_line": 156
} |
Prims.Tot | val compute_gen_elim_post (x: gen_elim_i) : Tot (compute_gen_elim_a x -> Tot prop) (decreases x) | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v') | val compute_gen_elim_post (x: gen_elim_i) : Tot (compute_gen_elim_a x -> Tot prop) (decreases x)
let rec compute_gen_elim_post (x: gen_elim_i) : Tot (compute_gen_elim_a x -> Tot prop) (decreases x) = | false | null | false | match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right ->
fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right ->
fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v':(tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\
compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v':dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post (body (dfstp #a #dept v')) (dsndp #a #dept v') | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total",
""
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Steel.ST.GenElim.Base.compute_gen_elim_a",
"Prims.prop",
"Steel.ST.GenElim.Base.gen_unit_elim_i",
"Steel.ST.GenElim.Base.GEUnit",
"Steel.ST.GenElim.Base.compute_gen_unit_elim_post",
"Steel.ST.GenElim.Base.GEStarL",
"Prims.l_and",
"Steel.ST.GenElim.Base.compute_gen_elim_post",
"Steel.ST.GenElim.Base.coerce_with_trefl",
"Steel.ST.GenElim.Base.GEStarR",
"Steel.ST.GenElim.Base.GEStar",
"Steel.ST.GenElim.Base.fstp",
"Steel.ST.GenElim.Base.sndp",
"FStar.Pervasives.Native.tuple2",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim.Base.GEExistsNoAbs",
"Prims.l_True",
"Steel.ST.GenElim.Base.GEExistsUnit",
"Steel.ST.GenElim.Base.GEExists",
"Steel.ST.GenElim.Base.dfstp",
"Steel.ST.GenElim.Base.dsndp",
"Prims.dtuple2"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop) | false | false | Steel.ST.GenElim.Base.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 compute_gen_elim_post (x: gen_elim_i) : Tot (compute_gen_elim_a x -> Tot prop) (decreases x) | [
"recursion"
] | Steel.ST.GenElim.Base.compute_gen_elim_post | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Steel.ST.GenElim.Base.gen_elim_i
-> Prims.Tot (_: Steel.ST.GenElim.Base.compute_gen_elim_a x -> Prims.prop) | {
"end_col": 25,
"end_line": 146,
"start_col": 2,
"start_line": 128
} |
Prims.Tot | val compute_gen_elim_q (x: gen_elim_i) : Tot (compute_gen_elim_a x -> Tot vprop) (decreases x) | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v') | val compute_gen_elim_q (x: gen_elim_i) : Tot (compute_gen_elim_a x -> Tot vprop) (decreases x)
let rec compute_gen_elim_q (x: gen_elim_i) : Tot (compute_gen_elim_a x -> Tot vprop) (decreases x) = | false | null | false | match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right ->
fun v -> (compute_gen_elim_q left (coerce_with_trefl v)) `star` (compute_gen_unit_elim_q right)
| GEStarR left right ->
fun v -> (compute_gen_unit_elim_q left) `star` (compute_gen_elim_q right (coerce_with_trefl v))
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v':(tleft & tright) = coerce_with_trefl v in
(compute_gen_elim_q left (fstp #tleft #tright v'))
`star`
(compute_gen_elim_q right (sndp #tleft #tright v'))
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v':dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q (body (dfstp #a #dept v')) (dsndp #a #dept v') | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total",
""
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Steel.ST.GenElim.Base.compute_gen_elim_a",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim.Base.gen_unit_elim_i",
"Steel.ST.GenElim.Base.GEUnit",
"Steel.ST.GenElim.Base.compute_gen_unit_elim_q",
"Steel.ST.GenElim.Base.GEStarL",
"Steel.Effect.Common.star",
"Steel.ST.GenElim.Base.compute_gen_elim_q",
"Steel.ST.GenElim.Base.coerce_with_trefl",
"Steel.ST.GenElim.Base.GEStarR",
"Steel.ST.GenElim.Base.GEStar",
"Steel.ST.GenElim.Base.fstp",
"Steel.ST.GenElim.Base.sndp",
"FStar.Pervasives.Native.tuple2",
"Steel.ST.GenElim.Base.GEExistsUnit",
"Steel.ST.GenElim.Base.GEExists",
"Steel.ST.GenElim.Base.dfstp",
"Steel.ST.GenElim.Base.dsndp",
"Prims.dtuple2"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop) | false | false | Steel.ST.GenElim.Base.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 compute_gen_elim_q (x: gen_elim_i) : Tot (compute_gen_elim_a x -> Tot vprop) (decreases x) | [
"recursion"
] | Steel.ST.GenElim.Base.compute_gen_elim_q | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Steel.ST.GenElim.Base.gen_elim_i
-> Prims.Tot (_: Steel.ST.GenElim.Base.compute_gen_elim_a x -> Steel.Effect.Common.vprop) | {
"end_col": 25,
"end_line": 121,
"start_col": 2,
"start_line": 103
} |
Prims.Tot | val compute_uncurry:
ret_type: Type u#a ->
def: ret_type ->
ty: list Type0 ->
curried_function_type ty ret_type ->
compute_gen_elim_nondep_a' ty
-> ret_type | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def | val compute_uncurry:
ret_type: Type u#a ->
def: ret_type ->
ty: list Type0 ->
curried_function_type ty ret_type ->
compute_gen_elim_nondep_a' ty
-> ret_type
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0)
: curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type = | false | null | false | match
ty
as ty'
returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type)
with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1 ; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1 ; t2 ; t3] -> fun q x -> q x._1 x._2 x._3
| [t1 ; t2 ; t3 ; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1 ; t2 ; t3 ; t4 ; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9] ->
fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10] ->
fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10 ; t11] ->
fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10 ; t11 ; t12] ->
fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10 ; t11 ; t12 ; t13] ->
fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10 ; t11 ; t12 ; t13 ; t14] ->
fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Prims.list",
"Steel.ST.GenElim.Base.curried_function_type",
"Steel.ST.GenElim.Base.compute_gen_elim_nondep_a'",
"Prims.Nil",
"Prims.Cons",
"Steel.ST.GenElim.Base.fstp",
"Steel.ST.GenElim.Base.sndp",
"FStar.Pervasives.Native.__proj__Mktuple3__item___1",
"FStar.Pervasives.Native.__proj__Mktuple3__item___2",
"FStar.Pervasives.Native.__proj__Mktuple3__item___3",
"FStar.Pervasives.Native.__proj__Mktuple4__item___1",
"FStar.Pervasives.Native.__proj__Mktuple4__item___2",
"FStar.Pervasives.Native.__proj__Mktuple4__item___3",
"FStar.Pervasives.Native.__proj__Mktuple4__item___4",
"FStar.Pervasives.Native.__proj__Mktuple5__item___1",
"FStar.Pervasives.Native.__proj__Mktuple5__item___2",
"FStar.Pervasives.Native.__proj__Mktuple5__item___3",
"FStar.Pervasives.Native.__proj__Mktuple5__item___4",
"FStar.Pervasives.Native.__proj__Mktuple5__item___5",
"FStar.Pervasives.Native.__proj__Mktuple6__item___1",
"FStar.Pervasives.Native.__proj__Mktuple6__item___2",
"FStar.Pervasives.Native.__proj__Mktuple6__item___3",
"FStar.Pervasives.Native.__proj__Mktuple6__item___4",
"FStar.Pervasives.Native.__proj__Mktuple6__item___5",
"FStar.Pervasives.Native.__proj__Mktuple6__item___6",
"FStar.Pervasives.Native.__proj__Mktuple7__item___1",
"FStar.Pervasives.Native.__proj__Mktuple7__item___2",
"FStar.Pervasives.Native.__proj__Mktuple7__item___3",
"FStar.Pervasives.Native.__proj__Mktuple7__item___4",
"FStar.Pervasives.Native.__proj__Mktuple7__item___5",
"FStar.Pervasives.Native.__proj__Mktuple7__item___6",
"FStar.Pervasives.Native.__proj__Mktuple7__item___7",
"FStar.Pervasives.Native.__proj__Mktuple8__item___1",
"FStar.Pervasives.Native.__proj__Mktuple8__item___2",
"FStar.Pervasives.Native.__proj__Mktuple8__item___3",
"FStar.Pervasives.Native.__proj__Mktuple8__item___4",
"FStar.Pervasives.Native.__proj__Mktuple8__item___5",
"FStar.Pervasives.Native.__proj__Mktuple8__item___6",
"FStar.Pervasives.Native.__proj__Mktuple8__item___7",
"FStar.Pervasives.Native.__proj__Mktuple8__item___8",
"FStar.Pervasives.Native.__proj__Mktuple9__item___1",
"FStar.Pervasives.Native.__proj__Mktuple9__item___2",
"FStar.Pervasives.Native.__proj__Mktuple9__item___3",
"FStar.Pervasives.Native.__proj__Mktuple9__item___4",
"FStar.Pervasives.Native.__proj__Mktuple9__item___5",
"FStar.Pervasives.Native.__proj__Mktuple9__item___6",
"FStar.Pervasives.Native.__proj__Mktuple9__item___7",
"FStar.Pervasives.Native.__proj__Mktuple9__item___8",
"FStar.Pervasives.Native.__proj__Mktuple9__item___9",
"FStar.Pervasives.Native.__proj__Mktuple10__item___1",
"FStar.Pervasives.Native.__proj__Mktuple10__item___2",
"FStar.Pervasives.Native.__proj__Mktuple10__item___3",
"FStar.Pervasives.Native.__proj__Mktuple10__item___4",
"FStar.Pervasives.Native.__proj__Mktuple10__item___5",
"FStar.Pervasives.Native.__proj__Mktuple10__item___6",
"FStar.Pervasives.Native.__proj__Mktuple10__item___7",
"FStar.Pervasives.Native.__proj__Mktuple10__item___8",
"FStar.Pervasives.Native.__proj__Mktuple10__item___9",
"FStar.Pervasives.Native.__proj__Mktuple10__item___10",
"FStar.Pervasives.Native.__proj__Mktuple11__item___1",
"FStar.Pervasives.Native.__proj__Mktuple11__item___2",
"FStar.Pervasives.Native.__proj__Mktuple11__item___3",
"FStar.Pervasives.Native.__proj__Mktuple11__item___4",
"FStar.Pervasives.Native.__proj__Mktuple11__item___5",
"FStar.Pervasives.Native.__proj__Mktuple11__item___6",
"FStar.Pervasives.Native.__proj__Mktuple11__item___7",
"FStar.Pervasives.Native.__proj__Mktuple11__item___8",
"FStar.Pervasives.Native.__proj__Mktuple11__item___9",
"FStar.Pervasives.Native.__proj__Mktuple11__item___10",
"FStar.Pervasives.Native.__proj__Mktuple11__item___11",
"FStar.Pervasives.Native.__proj__Mktuple12__item___1",
"FStar.Pervasives.Native.__proj__Mktuple12__item___2",
"FStar.Pervasives.Native.__proj__Mktuple12__item___3",
"FStar.Pervasives.Native.__proj__Mktuple12__item___4",
"FStar.Pervasives.Native.__proj__Mktuple12__item___5",
"FStar.Pervasives.Native.__proj__Mktuple12__item___6",
"FStar.Pervasives.Native.__proj__Mktuple12__item___7",
"FStar.Pervasives.Native.__proj__Mktuple12__item___8",
"FStar.Pervasives.Native.__proj__Mktuple12__item___9",
"FStar.Pervasives.Native.__proj__Mktuple12__item___10",
"FStar.Pervasives.Native.__proj__Mktuple12__item___11",
"FStar.Pervasives.Native.__proj__Mktuple12__item___12",
"FStar.Pervasives.Native.__proj__Mktuple13__item___1",
"FStar.Pervasives.Native.__proj__Mktuple13__item___2",
"FStar.Pervasives.Native.__proj__Mktuple13__item___3",
"FStar.Pervasives.Native.__proj__Mktuple13__item___4",
"FStar.Pervasives.Native.__proj__Mktuple13__item___5",
"FStar.Pervasives.Native.__proj__Mktuple13__item___6",
"FStar.Pervasives.Native.__proj__Mktuple13__item___7",
"FStar.Pervasives.Native.__proj__Mktuple13__item___8",
"FStar.Pervasives.Native.__proj__Mktuple13__item___9",
"FStar.Pervasives.Native.__proj__Mktuple13__item___10",
"FStar.Pervasives.Native.__proj__Mktuple13__item___11",
"FStar.Pervasives.Native.__proj__Mktuple13__item___12",
"FStar.Pervasives.Native.__proj__Mktuple13__item___13",
"FStar.Pervasives.Native.__proj__Mktuple14__item___1",
"FStar.Pervasives.Native.__proj__Mktuple14__item___2",
"FStar.Pervasives.Native.__proj__Mktuple14__item___3",
"FStar.Pervasives.Native.__proj__Mktuple14__item___4",
"FStar.Pervasives.Native.__proj__Mktuple14__item___5",
"FStar.Pervasives.Native.__proj__Mktuple14__item___6",
"FStar.Pervasives.Native.__proj__Mktuple14__item___7",
"FStar.Pervasives.Native.__proj__Mktuple14__item___8",
"FStar.Pervasives.Native.__proj__Mktuple14__item___9",
"FStar.Pervasives.Native.__proj__Mktuple14__item___10",
"FStar.Pervasives.Native.__proj__Mktuple14__item___11",
"FStar.Pervasives.Native.__proj__Mktuple14__item___12",
"FStar.Pervasives.Native.__proj__Mktuple14__item___13",
"FStar.Pervasives.Native.__proj__Mktuple14__item___14"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"] | false | false | Steel.ST.GenElim.Base.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 compute_uncurry:
ret_type: Type u#a ->
def: ret_type ->
ty: list Type0 ->
curried_function_type ty ret_type ->
compute_gen_elim_nondep_a' ty
-> ret_type | [] | Steel.ST.GenElim.Base.compute_uncurry | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
ret_type: Type ->
def: ret_type ->
ty: Prims.list Type0 ->
_: Steel.ST.GenElim.Base.curried_function_type ty ret_type ->
_: Steel.ST.GenElim.Base.compute_gen_elim_nondep_a' ty
-> ret_type | {
"end_col": 25,
"end_line": 276,
"start_col": 4,
"start_line": 260
} |
Prims.Tot | val compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x)) | val compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele = | false | null | false | match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru ->
tele_star_vprop (compute_gen_elim_tele l)
(compute_gen_unit_elim_q ru)
(compute_gen_unit_elim_post ru)
| GEStarR lu r ->
tele_star_vprop (compute_gen_elim_tele r)
(compute_gen_unit_elim_q lu)
(compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body ->
TExists ty
(fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x)) | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Steel.ST.GenElim.Base.gen_unit_elim_i",
"Steel.ST.GenElim.Base.TRet",
"Steel.ST.GenElim.Base.compute_gen_unit_elim_q",
"Steel.ST.GenElim.Base.compute_gen_unit_elim_post",
"Steel.ST.GenElim.Base.tele_star_vprop",
"Steel.ST.GenElim.Base.compute_gen_elim_tele",
"Steel.ST.GenElim.Base.tele_star",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim.Base.TExists",
"Prims.l_True",
"Steel.ST.GenElim.Base.gen_elim_tele"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce] | false | true | Steel.ST.GenElim.Base.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 compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele | [
"recursion"
] | Steel.ST.GenElim.Base.compute_gen_elim_tele | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Steel.ST.GenElim.Base.gen_elim_i -> Steel.ST.GenElim.Base.gen_elim_tele | {
"end_col": 71,
"end_line": 176,
"start_col": 2,
"start_line": 169
} |
Prims.Tot | val tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2))) | val tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele = | false | null | false | match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 ->
TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2))) | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_elim_tele",
"FStar.Pervasives.Native.Mktuple2",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim.Base.tele_star_vprop",
"Steel.ST.GenElim.Base.TExists",
"Steel.ST.GenElim.Base.tele_star"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce] | false | true | Steel.ST.GenElim.Base.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 tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele | [
"recursion"
] | Steel.ST.GenElim.Base.tele_star | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i1: Steel.ST.GenElim.Base.gen_elim_tele -> i2: Steel.ST.GenElim.Base.gen_elim_tele
-> Steel.ST.GenElim.Base.gen_elim_tele | {
"end_col": 111,
"end_line": 165,
"start_col": 2,
"start_line": 162
} |
Prims.Tot | val compute_gen_unit_elim_q (x: gen_unit_elim_i) : Tot vprop | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right | val compute_gen_unit_elim_q (x: gen_unit_elim_i) : Tot vprop
let rec compute_gen_unit_elim_q (x: gen_unit_elim_i) : Tot vprop = | false | null | false | match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> (compute_gen_unit_elim_q left) `star` (compute_gen_unit_elim_q right) | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_unit_elim_i",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.Effect.Common.emp",
"Steel.Effect.Common.star",
"Steel.ST.GenElim.Base.compute_gen_unit_elim_q"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i) | false | true | Steel.ST.GenElim.Base.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 compute_gen_unit_elim_q (x: gen_unit_elim_i) : Tot vprop | [
"recursion"
] | Steel.ST.GenElim.Base.compute_gen_unit_elim_q | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Steel.ST.GenElim.Base.gen_unit_elim_i -> Steel.Effect.Common.vprop | {
"end_col": 91,
"end_line": 47,
"start_col": 2,
"start_line": 44
} |
Prims.Pure | val mk_gen_elim_nondep (ty: list Type0) (tvprop: Type) (q: tvprop) (tprop: Type) (post: tprop)
: Pure gen_elim_nondep_t
(requires (tvprop == curried_function_type ty vprop /\ tprop == curried_function_type ty prop)
)
(ensures (fun _ -> True)) | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post | val mk_gen_elim_nondep (ty: list Type0) (tvprop: Type) (q: tvprop) (tprop: Type) (post: tprop)
: Pure gen_elim_nondep_t
(requires (tvprop == curried_function_type ty vprop /\ tprop == curried_function_type ty prop)
)
(ensures (fun _ -> True))
let mk_gen_elim_nondep (ty: list Type0) (tvprop: Type) (q: tvprop) (tprop: Type) (post: tprop)
: Pure gen_elim_nondep_t
(requires (tvprop == curried_function_type ty vprop /\ tprop == curried_function_type ty prop)
)
(ensures (fun _ -> True)) = | false | null | false | GENonDep ty q post | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"Prims.list",
"Steel.ST.GenElim.Base.GENonDep",
"Steel.ST.GenElim.Base.gen_elim_nondep_t",
"Prims.l_and",
"Prims.eq2",
"Steel.ST.GenElim.Base.curried_function_type",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Prims.l_True"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
)) | false | false | Steel.ST.GenElim.Base.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 mk_gen_elim_nondep (ty: list Type0) (tvprop: Type) (q: tvprop) (tprop: Type) (post: tprop)
: Pure gen_elim_nondep_t
(requires (tvprop == curried_function_type ty vprop /\ tprop == curried_function_type ty prop)
)
(ensures (fun _ -> True)) | [] | Steel.ST.GenElim.Base.mk_gen_elim_nondep | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | ty: Prims.list Type0 -> tvprop: Type -> q: tvprop -> tprop: Type -> post: tprop
-> Prims.Pure Steel.ST.GenElim.Base.gen_elim_nondep_t | {
"end_col": 20,
"end_line": 203,
"start_col": 2,
"start_line": 203
} |
Prims.Tot | val compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t)
: Tot (compute_gen_elim_nondep_a i0 i -> vprop) | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0 | val compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t)
: Tot (compute_gen_elim_nondep_a i0 i -> vprop)
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t)
: Tot (compute_gen_elim_nondep_a i0 i -> vprop) = | false | null | false | match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
| GEDep -> compute_gen_elim_q i0 | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Steel.ST.GenElim.Base.gen_elim_nondep_t",
"Prims.list",
"Steel.ST.GenElim.Base.curried_function_type",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim.Base.compute_uncurry",
"Steel.ST.GenElim.Base.compute_gen_elim_p'",
"Steel.ST.GenElim.Base.compute_gen_elim_q",
"Steel.ST.GenElim.Base.compute_gen_elim_nondep_a"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce] | false | false | Steel.ST.GenElim.Base.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 compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t)
: Tot (compute_gen_elim_nondep_a i0 i -> vprop) | [] | Steel.ST.GenElim.Base.compute_gen_elim_nondep_q0 | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim.Base.gen_elim_i ->
i: Steel.ST.GenElim.Base.gen_elim_nondep_t ->
_: Steel.ST.GenElim.Base.compute_gen_elim_nondep_a i0 i
-> Steel.Effect.Common.vprop | {
"end_col": 34,
"end_line": 283,
"start_col": 2,
"start_line": 280
} |
Prims.Tot | val curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t) | val curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b))
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b))
: Tot (Type u#(max a b)) = | false | null | false | match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t) | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Prims.list",
"Steel.ST.GenElim.Base.curried_function_type"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"] | false | true | Steel.ST.GenElim.Base.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 curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) | [
"recursion"
] | Steel.ST.GenElim.Base.curried_function_type | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Prims.list Type -> ret_t: Type -> Type | {
"end_col": 56,
"end_line": 182,
"start_col": 2,
"start_line": 180
} |
Prims.Tot | val compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t)
: Tot (compute_gen_elim_nondep_a i0 i -> prop) | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0 | val compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t)
: Tot (compute_gen_elim_nondep_a i0 i -> prop)
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t)
: Tot (compute_gen_elim_nondep_a i0 i -> prop) = | false | null | false | match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0 | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Steel.ST.GenElim.Base.gen_elim_nondep_t",
"Prims.list",
"Steel.ST.GenElim.Base.curried_function_type",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim.Base.compute_uncurry",
"Prims.l_True",
"Steel.ST.GenElim.Base.compute_gen_elim_post",
"Steel.ST.GenElim.Base.compute_gen_elim_nondep_a"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"] | false | false | Steel.ST.GenElim.Base.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 compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t)
: Tot (compute_gen_elim_nondep_a i0 i -> prop) | [] | Steel.ST.GenElim.Base.compute_gen_elim_nondep_post0 | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim.Base.gen_elim_i ->
i: Steel.ST.GenElim.Base.gen_elim_nondep_t ->
_: Steel.ST.GenElim.Base.compute_gen_elim_nondep_a i0 i
-> Prims.prop | {
"end_col": 37,
"end_line": 293,
"start_col": 2,
"start_line": 291
} |
Prims.Tot | val gen_elim_nondep_sem (ty: list Type0)
: Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x)) | val gen_elim_nondep_sem (ty: list Type0)
: Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele)
let rec gen_elim_nondep_sem (ty: list Type0)
: Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) = | false | null | false | match
ty
as ty'
returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele
with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x)) | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"total"
] | [
"Prims.list",
"Steel.ST.GenElim.Base.curried_function_type",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim.Base.gen_elim_tele",
"Prims.Nil",
"Steel.ST.GenElim.Base.TRet",
"Prims.Cons",
"Steel.ST.GenElim.Base.TExists",
"Steel.ST.GenElim.Base.gen_elim_nondep_sem"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce] | false | false | Steel.ST.GenElim.Base.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 gen_elim_nondep_sem (ty: list Type0)
: Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) | [
"recursion"
] | Steel.ST.GenElim.Base.gen_elim_nondep_sem | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
ty: Prims.list Type0 ->
_: Steel.ST.GenElim.Base.curried_function_type ty Steel.Effect.Common.vprop ->
_: Steel.ST.GenElim.Base.curried_function_type ty Prims.prop
-> Steel.ST.GenElim.Base.gen_elim_tele | {
"end_col": 87,
"end_line": 224,
"start_col": 2,
"start_line": 222
} |
FStar.Tactics.Effect.Tac | val solve_gen_elim_nondep (enable_nondep_opt: bool) (t: T.term) : T.Tac T.term | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let solve_gen_elim_nondep (enable_nondep_opt: bool) (t: T.term) : T.Tac T.term =
match solve_gen_elim_nondep0 enable_nondep_opt t with
| None -> (`GEDep)
| Some (Mktuple5
type_list
tv'
v'
tp'
p'
) -> T.mk_app (`mk_gen_elim_nondep_by_tac) [
type_list, T.Q_Explicit;
tv', T.Q_Explicit;
v', T.Q_Explicit;
tp', T.Q_Explicit;
p', T.Q_Explicit;
] | val solve_gen_elim_nondep (enable_nondep_opt: bool) (t: T.term) : T.Tac T.term
let solve_gen_elim_nondep (enable_nondep_opt: bool) (t: T.term) : T.Tac T.term = | true | null | false | match solve_gen_elim_nondep0 enable_nondep_opt t with
| None -> (`GEDep)
| Some (Mktuple5 type_list tv' v' tp' p') ->
T.mk_app (`mk_gen_elim_nondep_by_tac)
[
type_list, T.Q_Explicit;
tv', T.Q_Explicit;
v', T.Q_Explicit;
tp', T.Q_Explicit;
p', T.Q_Explicit
] | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"Prims.bool",
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Derived.mk_app",
"Prims.Cons",
"FStar.Reflection.V1.Data.argv",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V1.Data.aqualv",
"FStar.Reflection.V1.Data.Q_Explicit",
"Prims.Nil",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple5",
"Steel.ST.GenElim.Base.solve_gen_elim_nondep0"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash]
let is_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar]
let rec term_has_head
(t: T.term)
(head: T.term)
: T.Tac bool
= let (hd, tl) = T.collect_app t in
if hd `T.term_eq_old` head
then true
else if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit; td, T.Q_Explicit] ->
if term_has_head tg head
then true
else term_has_head td head
| _ -> false
else false
let rec solve_gen_unit_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`pure))
then T.mk_app (`GUEId) [tl', T.Q_Explicit]
else
let (hd, tl) = T.collect_app tl' in
if hd `is_fvar` (`%pure)
then T.mk_app (`GUEPure) tl
else if is_star_or_vstar hd
then match tl with
| [t1, T.Q_Explicit; t2, T.Q_Explicit] ->
let t1' = solve_gen_unit_elim t1 in
let t2' = solve_gen_unit_elim t2 in
T.mk_app (`GUEStar) [t1', T.Q_Explicit; t2', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GUEId) [tl', T.Q_Explicit]
let abstr_has_exists
(t: T.term)
: T.Tac bool
= match T.inspect t with
| T.Tv_Abs _ body -> term_has_head body (`exists_)
| _ -> false
let rec solve_gen_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`exists_))
then begin
let t' = solve_gen_unit_elim tl' in
T.mk_app (`GEUnit) [t', T.Q_Explicit]
end else
let (hd, lbody) = T.collect_app tl' in
if hd `is_fvar` (`%exists_)
then
let (ty, body) =
match lbody with
| [(ty, T.Q_Implicit); (body, T.Q_Explicit)] -> ([(ty, T.Q_Implicit)], body)
| [(body, T.Q_Explicit)] -> ([], body)
| _ -> T.fail "ill-formed exists_"
in
begin match T.inspect body with
| T.Tv_Abs b abody ->
if not (term_has_head abody (`exists_))
then
let body' = solve_gen_unit_elim abody in
T.mk_app (`GEExistsUnit) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
else
let body' = solve_gen_elim abody in
T.mk_app (`GEExists) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
| _ ->
T.mk_app (`GEExistsNoAbs) lbody
end
else if is_star_or_vstar hd
then
match lbody with
| [(tl, T.Q_Explicit); (tr, T.Q_Explicit)] ->
if term_has_head tl (`exists_)
then
let tl' = solve_gen_elim tl in
if term_has_head tr (`exists_)
then
let tr' = solve_gen_elim tr in
T.mk_app (`GEStar) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else
let tr' = solve_gen_unit_elim tr in
T.mk_app (`GEStarL) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else (* here, term_has_head tr (`exists_) holds, because otherwise we are in case (not (term_has_head tl (`exists_))) above *)
let tl' = solve_gen_unit_elim tl in
let tr' = solve_gen_elim tr in
T.mk_app (`GEStarR) [tl', T.Q_Explicit; tr', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GEUnit) [T.mk_app (`GUEId) lbody, T.Q_Explicit]
[@@ noextract_to "Plugin"]
val gen_elim_prop
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
val gen_elim_prop_intro'
(i: gen_elim_i)
(j: gen_elim_nondep_t)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i j))
(sq_a: squash (a == compute_gen_elim_nondep_a i j))
(sq_q: squash (q == compute_gen_elim_nondep_q i j))
(sq_post: squash (post == compute_gen_elim_nondep_post i j))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
let gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a: squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_q: squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_post: squash (post == compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
= gen_elim_prop_intro' i (mk_gen_elim_nondep ty tvprop q0 tprop post0) enable_nondep_opt p a q post sq_p sq_j sq_a sq_q sq_post
val gen_elim_prop_elim
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Ghost (gen_elim_i & gen_elim_nondep_t)
(requires gen_elim_prop enable_nondep_opt p a q post)
(ensures (fun (i, j) ->
p == compute_gen_elim_p i /\
check_gen_elim_nondep_sem i j /\
a == compute_gen_elim_nondep_a i j /\
q == compute_gen_elim_nondep_q i j /\
post == compute_gen_elim_nondep_post i j
))
[@@noextract_to "Plugin"]
let gen_elim_prop_placeholder
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
= True
let gen_elim_prop_placeholder_intro
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Lemma (gen_elim_prop_placeholder enable_nondep_opt p a q post)
= ()
let rec solve_gen_elim_nondep' (fuel: nat) (rev_types_and_binders: list (T.term & T.binder)) (t: T.term) : T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) =
if fuel = 0
then None
else
let (hd, tl) = T.collect_app t in
if hd `is_fvar` (`%TRet)
then match tl with
| [(v, T.Q_Explicit); (p, T.Q_Explicit)] ->
let cons_type (accu: (unit -> T.Tac T.term)) (tb: (T.term & T.binder)) () : T.Tac T.term =
let (ty, _) = tb in
let tl = accu () in
T.mk_app (`Cons) [(`Type0), T.Q_Implicit; ty, T.Q_Explicit; tl, T.Q_Explicit]
in
let nil_type () : T.Tac T.term = T.mk_app (`Nil) [(`Type0), T.Q_Implicit] in
let type_list = List.Tot.fold_left cons_type nil_type rev_types_and_binders () in
let type_list_typechecks =
let open T in
try
let env = cur_env () in
let ty = tc env type_list in
ty `term_eq_old` (`(list Type0))
with _ -> false
in
if not type_list_typechecks
then None
else
let binders = List.Tot.map snd (List.Tot.rev rev_types_and_binders) in
let norm_term = T.norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] in
let v' = T.mk_abs binders v in
let tv' = norm_term (T.mk_app (`curried_function_type) [type_list, T.Q_Explicit; (`vprop), T.Q_Explicit]) in
let p' = T.mk_abs binders p in
let tp' = norm_term (T.mk_app (`curried_function_type) [type_list, T.Q_Explicit; (`prop), T.Q_Explicit]) in
Some (Mktuple5
type_list
tv'
v'
tp'
p'
)
| _ -> None
else if hd `is_fvar` (`%TExists)
then match tl with
| [(ty, _); (f, T.Q_Explicit)] ->
begin match T.inspect f with
| T.Tv_Abs bv body -> solve_gen_elim_nondep' (fuel - 1) ((ty, bv) :: rev_types_and_binders) body
| _ -> None
end
| _ -> None
else None
let solve_gen_elim_nondep0 (enable_nondep_opt: bool) (t: T.term) : T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) =
if enable_nondep_opt
then
let open T in
try
let tele = mk_app (`compute_gen_elim_tele) [t, Q_Explicit] in
let t' = norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] tele in
solve_gen_elim_nondep' 15 [] t' // fuel necessary because F* standard tuple types only go from 0 up to 14 elts
with _ -> None
else None | false | false | Steel.ST.GenElim.Base.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 solve_gen_elim_nondep (enable_nondep_opt: bool) (t: T.term) : T.Tac T.term | [] | Steel.ST.GenElim.Base.solve_gen_elim_nondep | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | enable_nondep_opt: Prims.bool -> t: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 9,
"end_line": 560,
"start_col": 2,
"start_line": 546
} |
FStar.Tactics.Effect.Tac | val solve_gen_elim_nondep' (fuel: nat) (rev_types_and_binders: list (T.term & T.binder)) (t: T.term)
: T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_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 solve_gen_elim_nondep' (fuel: nat) (rev_types_and_binders: list (T.term & T.binder)) (t: T.term) : T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) =
if fuel = 0
then None
else
let (hd, tl) = T.collect_app t in
if hd `is_fvar` (`%TRet)
then match tl with
| [(v, T.Q_Explicit); (p, T.Q_Explicit)] ->
let cons_type (accu: (unit -> T.Tac T.term)) (tb: (T.term & T.binder)) () : T.Tac T.term =
let (ty, _) = tb in
let tl = accu () in
T.mk_app (`Cons) [(`Type0), T.Q_Implicit; ty, T.Q_Explicit; tl, T.Q_Explicit]
in
let nil_type () : T.Tac T.term = T.mk_app (`Nil) [(`Type0), T.Q_Implicit] in
let type_list = List.Tot.fold_left cons_type nil_type rev_types_and_binders () in
let type_list_typechecks =
let open T in
try
let env = cur_env () in
let ty = tc env type_list in
ty `term_eq_old` (`(list Type0))
with _ -> false
in
if not type_list_typechecks
then None
else
let binders = List.Tot.map snd (List.Tot.rev rev_types_and_binders) in
let norm_term = T.norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] in
let v' = T.mk_abs binders v in
let tv' = norm_term (T.mk_app (`curried_function_type) [type_list, T.Q_Explicit; (`vprop), T.Q_Explicit]) in
let p' = T.mk_abs binders p in
let tp' = norm_term (T.mk_app (`curried_function_type) [type_list, T.Q_Explicit; (`prop), T.Q_Explicit]) in
Some (Mktuple5
type_list
tv'
v'
tp'
p'
)
| _ -> None
else if hd `is_fvar` (`%TExists)
then match tl with
| [(ty, _); (f, T.Q_Explicit)] ->
begin match T.inspect f with
| T.Tv_Abs bv body -> solve_gen_elim_nondep' (fuel - 1) ((ty, bv) :: rev_types_and_binders) body
| _ -> None
end
| _ -> None
else None | val solve_gen_elim_nondep' (fuel: nat) (rev_types_and_binders: list (T.term & T.binder)) (t: T.term)
: T.Tac (option (tuple5 T.term T.term T.term T.term T.term))
let rec solve_gen_elim_nondep'
(fuel: nat)
(rev_types_and_binders: list (T.term & T.binder))
(t: T.term)
: T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) = | true | null | false | if fuel = 0
then None
else
let hd, tl = T.collect_app t in
if hd `is_fvar` (`%TRet)
then
match tl with
| [v, T.Q_Explicit ; p, T.Q_Explicit] ->
let cons_type (accu: (unit -> T.Tac T.term)) (tb: (T.term & T.binder)) () : T.Tac T.term =
let ty, _ = tb in
let tl = accu () in
T.mk_app (`Cons) [(`Type0), T.Q_Implicit; ty, T.Q_Explicit; tl, T.Q_Explicit]
in
let nil_type () : T.Tac T.term = T.mk_app (`Nil) [(`Type0), T.Q_Implicit] in
let type_list = List.Tot.fold_left cons_type nil_type rev_types_and_binders () in
let type_list_typechecks =
let open T in
try
let env = cur_env () in
let ty = tc env type_list in
ty `term_eq_old` (`(list Type0))
with
| _ -> false
in
if not type_list_typechecks
then None
else
let binders = List.Tot.map snd (List.Tot.rev rev_types_and_binders) in
let norm_term = T.norm_term [delta_attr [(`%gen_elim_reduce)]; zeta; iota] in
let v' = T.mk_abs binders v in
let tv' =
norm_term (T.mk_app (`curried_function_type)
[type_list, T.Q_Explicit; (`vprop), T.Q_Explicit])
in
let p' = T.mk_abs binders p in
let tp' =
norm_term (T.mk_app (`curried_function_type)
[type_list, T.Q_Explicit; (`prop), T.Q_Explicit])
in
Some (Mktuple5 type_list tv' v' tp' p')
| _ -> None
else
if hd `is_fvar` (`%TExists)
then
match tl with
| [ty, _ ; f, T.Q_Explicit] ->
(match T.inspect f with
| T.Tv_Abs bv body ->
solve_gen_elim_nondep' (fuel - 1) ((ty, bv) :: rev_types_and_binders) body
| _ -> None)
| _ -> None
else None | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [] | [
"Prims.nat",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.term",
"FStar.Reflection.Types.binder",
"Prims.op_Equality",
"Prims.int",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple5",
"FStar.Pervasives.Native.option",
"Prims.bool",
"FStar.Reflection.V1.Data.argv",
"Steel.ST.GenElim.Base.is_fvar",
"Prims.op_Negation",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple5",
"FStar.Reflection.V1.Derived.mk_app",
"Prims.Cons",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V1.Data.aqualv",
"FStar.Reflection.V1.Data.Q_Explicit",
"Prims.Nil",
"FStar.Tactics.V1.Derived.mk_abs",
"FStar.Tactics.V1.Derived.norm_term",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"FStar.List.Tot.Base.map",
"FStar.Pervasives.Native.snd",
"FStar.List.Tot.Base.rev",
"FStar.Tactics.V1.Derived.try_with",
"Prims.unit",
"FStar.Tactics.V1.Builtins.term_eq_old",
"FStar.Tactics.V1.Builtins.tc",
"FStar.Reflection.Types.env",
"FStar.Tactics.V1.Derived.cur_env",
"Prims.exn",
"FStar.List.Tot.Base.fold_left",
"FStar.Reflection.V1.Data.Q_Implicit",
"Steel.ST.GenElim.Base.solve_gen_elim_nondep'",
"Prims.op_Subtraction",
"FStar.Reflection.V1.Data.term_view",
"FStar.Tactics.V1.Builtins.inspect",
"FStar.Tactics.V1.SyntaxHelpers.collect_app"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash]
let is_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar]
let rec term_has_head
(t: T.term)
(head: T.term)
: T.Tac bool
= let (hd, tl) = T.collect_app t in
if hd `T.term_eq_old` head
then true
else if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit; td, T.Q_Explicit] ->
if term_has_head tg head
then true
else term_has_head td head
| _ -> false
else false
let rec solve_gen_unit_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`pure))
then T.mk_app (`GUEId) [tl', T.Q_Explicit]
else
let (hd, tl) = T.collect_app tl' in
if hd `is_fvar` (`%pure)
then T.mk_app (`GUEPure) tl
else if is_star_or_vstar hd
then match tl with
| [t1, T.Q_Explicit; t2, T.Q_Explicit] ->
let t1' = solve_gen_unit_elim t1 in
let t2' = solve_gen_unit_elim t2 in
T.mk_app (`GUEStar) [t1', T.Q_Explicit; t2', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GUEId) [tl', T.Q_Explicit]
let abstr_has_exists
(t: T.term)
: T.Tac bool
= match T.inspect t with
| T.Tv_Abs _ body -> term_has_head body (`exists_)
| _ -> false
let rec solve_gen_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`exists_))
then begin
let t' = solve_gen_unit_elim tl' in
T.mk_app (`GEUnit) [t', T.Q_Explicit]
end else
let (hd, lbody) = T.collect_app tl' in
if hd `is_fvar` (`%exists_)
then
let (ty, body) =
match lbody with
| [(ty, T.Q_Implicit); (body, T.Q_Explicit)] -> ([(ty, T.Q_Implicit)], body)
| [(body, T.Q_Explicit)] -> ([], body)
| _ -> T.fail "ill-formed exists_"
in
begin match T.inspect body with
| T.Tv_Abs b abody ->
if not (term_has_head abody (`exists_))
then
let body' = solve_gen_unit_elim abody in
T.mk_app (`GEExistsUnit) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
else
let body' = solve_gen_elim abody in
T.mk_app (`GEExists) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
| _ ->
T.mk_app (`GEExistsNoAbs) lbody
end
else if is_star_or_vstar hd
then
match lbody with
| [(tl, T.Q_Explicit); (tr, T.Q_Explicit)] ->
if term_has_head tl (`exists_)
then
let tl' = solve_gen_elim tl in
if term_has_head tr (`exists_)
then
let tr' = solve_gen_elim tr in
T.mk_app (`GEStar) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else
let tr' = solve_gen_unit_elim tr in
T.mk_app (`GEStarL) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else (* here, term_has_head tr (`exists_) holds, because otherwise we are in case (not (term_has_head tl (`exists_))) above *)
let tl' = solve_gen_unit_elim tl in
let tr' = solve_gen_elim tr in
T.mk_app (`GEStarR) [tl', T.Q_Explicit; tr', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GEUnit) [T.mk_app (`GUEId) lbody, T.Q_Explicit]
[@@ noextract_to "Plugin"]
val gen_elim_prop
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
val gen_elim_prop_intro'
(i: gen_elim_i)
(j: gen_elim_nondep_t)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i j))
(sq_a: squash (a == compute_gen_elim_nondep_a i j))
(sq_q: squash (q == compute_gen_elim_nondep_q i j))
(sq_post: squash (post == compute_gen_elim_nondep_post i j))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
let gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a: squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_q: squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_post: squash (post == compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
= gen_elim_prop_intro' i (mk_gen_elim_nondep ty tvprop q0 tprop post0) enable_nondep_opt p a q post sq_p sq_j sq_a sq_q sq_post
val gen_elim_prop_elim
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Ghost (gen_elim_i & gen_elim_nondep_t)
(requires gen_elim_prop enable_nondep_opt p a q post)
(ensures (fun (i, j) ->
p == compute_gen_elim_p i /\
check_gen_elim_nondep_sem i j /\
a == compute_gen_elim_nondep_a i j /\
q == compute_gen_elim_nondep_q i j /\
post == compute_gen_elim_nondep_post i j
))
[@@noextract_to "Plugin"]
let gen_elim_prop_placeholder
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
= True
let gen_elim_prop_placeholder_intro
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Lemma (gen_elim_prop_placeholder enable_nondep_opt p a q post)
= () | false | false | Steel.ST.GenElim.Base.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 solve_gen_elim_nondep' (fuel: nat) (rev_types_and_binders: list (T.term & T.binder)) (t: T.term)
: T.Tac (option (tuple5 T.term T.term T.term T.term T.term)) | [
"recursion"
] | Steel.ST.GenElim.Base.solve_gen_elim_nondep' | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
fuel: Prims.nat ->
rev_types_and_binders: Prims.list (FStar.Reflection.Types.term * FStar.Reflection.Types.binder) ->
t: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac
(FStar.Pervasives.Native.option ((((FStar.Reflection.Types.term * FStar.Reflection.Types.term) *
FStar.Reflection.Types.term) *
FStar.Reflection.Types.term) *
FStar.Reflection.Types.term)) | {
"end_col": 13,
"end_line": 532,
"start_col": 2,
"start_line": 485
} |
FStar.Pervasives.Lemma | val gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: (Ghost.erased a -> Tot vprop))
(post: (Ghost.erased a -> Tot prop))
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a: squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0))
)
(sq_q: squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0))
)
(sq_post:
squash (post ==
compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma (gen_elim_prop enable_nondep_opt p a q post) | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a: squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_q: squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_post: squash (post == compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
= gen_elim_prop_intro' i (mk_gen_elim_nondep ty tvprop q0 tprop post0) enable_nondep_opt p a q post sq_p sq_j sq_a sq_q sq_post | val gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: (Ghost.erased a -> Tot vprop))
(post: (Ghost.erased a -> Tot prop))
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a: squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0))
)
(sq_q: squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0))
)
(sq_post:
squash (post ==
compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma (gen_elim_prop enable_nondep_opt p a q post)
let gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: (Ghost.erased a -> Tot vprop))
(post: (Ghost.erased a -> Tot prop))
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a:
squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_q:
squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_post:
squash (post ==
compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma (gen_elim_prop enable_nondep_opt p a q post) = | false | null | true | gen_elim_prop_intro' i (mk_gen_elim_nondep ty tvprop q0 tprop post0) enable_nondep_opt p a q post
sq_p sq_j sq_a sq_q sq_post | {
"checked_file": "Steel.ST.GenElim.Base.fsti.checked",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.Effect.Common.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GenElim.Base.fsti"
} | [
"lemma"
] | [
"Steel.ST.GenElim.Base.gen_elim_i",
"Prims.list",
"Prims.bool",
"Steel.Effect.Common.vprop",
"FStar.Ghost.erased",
"Prims.prop",
"Prims.squash",
"Prims.eq2",
"Steel.ST.GenElim.Base.curried_function_type",
"Steel.ST.GenElim.Base.compute_gen_elim_p",
"Steel.ST.GenElim.Base.check_gen_elim_nondep_sem",
"Steel.ST.GenElim.Base.mk_gen_elim_nondep",
"Steel.ST.GenElim.Base.compute_gen_elim_nondep_a",
"Steel.ST.GenElim.Base.compute_gen_elim_nondep_q",
"Steel.ST.GenElim.Base.compute_gen_elim_nondep_post",
"Steel.ST.GenElim.Base.gen_elim_prop_intro'",
"Prims.unit",
"Prims.l_True",
"Steel.ST.GenElim.Base.gen_elim_prop",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Steel.ST.GenElim.Base
include Steel.ST.Util
module T = FStar.Tactics
let is_fvar = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar
/// A tactic to automatically generate a unique binder
[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
| GUEPure: (p: prop) -> gen_unit_elim_i
| GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i
[@@erasable]
noeq
type gen_elim_i =
| GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
| GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
| GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
| GEExistsNoAbs: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
| GEExistsUnit: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
| GEExists: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
val gen_elim_reduce: unit
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure p -> pure p
| GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right
[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
(x: gen_unit_elim_i)
: Tot vprop
= match x with
| GUEId v -> v
| GUEPure _ -> emp
| GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
(x: gen_unit_elim_i)
: Tot prop
= match x with
| GUEId _ -> True
| GUEPure p -> p
| GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right
[@@gen_elim_reduce]
let rec compute_gen_elim_p
(x: gen_elim_i)
: Tot vprop
= match x with
| GEUnit i -> compute_gen_unit_elim_p i
| GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
| GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
| GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
| GEExistsNoAbs #a p -> exists_ p
| GEExistsUnit #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
| GEExists #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
let compute_gen_elim_p' = compute_gen_elim_p
[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
(x: gen_elim_i)
: Tot Type0
= match x with
| GEUnit _ -> unit
| GEStarL left _ -> compute_gen_elim_a left
| GEStarR _ right -> compute_gen_elim_a right
| GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
| GEExistsNoAbs #a _
| GEExistsUnit #a _ -> a
| GEExists #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t
[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
[@@gen_elim_reduce]
let rec compute_gen_elim_q
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
| GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> p
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_q
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_elim_post
(x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot prop)
(decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot prop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_post u
| GEStarL left right -> fun v -> compute_gen_elim_post left (coerce_with_trefl v) /\ compute_gen_unit_elim_post right
| GEStarR left right -> fun v -> compute_gen_unit_elim_post left /\ compute_gen_elim_post right (coerce_with_trefl v)
| GEStar left right ->
let tleft = compute_gen_elim_a left in
let tright = compute_gen_elim_a right in
fun v ->
let v' : (tleft & tright) = coerce_with_trefl v in
compute_gen_elim_post left (fstp #tleft #tright v') /\ compute_gen_elim_post right (sndp #tleft #tright v')
| GEExistsNoAbs #a p -> fun _ -> True
| GEExistsUnit #a p -> fun v -> compute_gen_unit_elim_post (p v)
| GEExists #a body ->
let dept = (fun x -> compute_gen_elim_a (body x)) in
fun v ->
let v' : dtuple2 a dept = coerce_with_trefl v in
compute_gen_elim_post
(body (dfstp #a #dept v'))
(dsndp #a #dept v')
[@@erasable]
noeq
type gen_elim_tele =
| TRet: vprop -> prop -> gen_elim_tele
| TExists: (ty: Type u#0) -> (ty -> gen_elim_tele) -> gen_elim_tele
[@@gen_elim_reduce]
let rec tele_star_vprop (i: gen_elim_tele) (v: vprop) (p: prop) : Tot gen_elim_tele (decreases i) =
match i with
| TRet v' p' -> TRet (v `star` v') (p /\ p')
| TExists ty f -> TExists ty (fun x -> tele_star_vprop (f x) v p)
[@@gen_elim_reduce]
let rec tele_star (i1 i2: gen_elim_tele) : Tot gen_elim_tele =
match i1, i2 with
| TRet v1 p1, _ -> tele_star_vprop i2 v1 p1
| _, TRet v2 p2 -> tele_star_vprop i1 v2 p2
| TExists ty1 f1, TExists ty2 f2 -> TExists ty1 (fun x1 -> TExists ty2 (fun x2 -> tele_star (f1 x1) (f2 x2)))
[@@gen_elim_reduce]
let rec compute_gen_elim_tele (x: gen_elim_i) : Tot gen_elim_tele =
match x with
| GEUnit v -> TRet (compute_gen_unit_elim_q v) (compute_gen_unit_elim_post v)
| GEStarL l ru -> tele_star_vprop (compute_gen_elim_tele l) (compute_gen_unit_elim_q ru) (compute_gen_unit_elim_post ru)
| GEStarR lu r -> tele_star_vprop (compute_gen_elim_tele r) (compute_gen_unit_elim_q lu) (compute_gen_unit_elim_post lu)
| GEStar l r -> tele_star (compute_gen_elim_tele l) (compute_gen_elim_tele r)
| GEExistsNoAbs #ty body -> TExists ty (fun x -> TRet (body x) True)
| GEExistsUnit #ty body -> TExists ty (fun x -> TRet (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_post (body x)))
| GEExists #ty f -> TExists ty (fun x -> compute_gen_elim_tele (f x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let rec curried_function_type (x: list (Type u#a)) (ret_t: Type u#(max a b)) : Tot (Type u#(max a b)) =
match x with
| [] -> ret_t
| t1 :: q -> t1 -> Tot (curried_function_type q ret_t)
[@@erasable]
noeq
type gen_elim_nondep_t =
| GENonDep: (ty: list Type0) -> curried_function_type ty vprop -> curried_function_type ty prop -> gen_elim_nondep_t
| GEDep
[@@gen_elim_reduce]
let mk_gen_elim_nondep
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
tvprop == curried_function_type ty vprop /\
tprop == curried_function_type ty prop
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let mk_gen_elim_nondep_by_tac
(ty: list Type0)
(tvprop: Type)
(q: tvprop)
(tprop: Type)
(post: tprop)
: Pure gen_elim_nondep_t
(requires (
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tvprop == curried_function_type ty vprop) /\
T.with_tactic (fun _ -> T.norm [delta_attr [(`%gen_elim_reduce)]; iota; zeta]) (tprop == curried_function_type ty prop)
))
(ensures (fun _ -> True))
= GENonDep ty q post
[@@gen_elim_reduce]
let rec gen_elim_nondep_sem (ty: list Type0) : Tot (curried_function_type ty vprop -> curried_function_type ty prop -> Tot gen_elim_tele) =
match ty as ty' returns curried_function_type ty' vprop -> curried_function_type ty' prop -> Tot gen_elim_tele with
| [] -> fun q post -> TRet q post
| t :: tq -> fun q post -> TExists t (fun x -> gen_elim_nondep_sem tq (q x) (post x))
[@@gen_elim_reduce; noextract_to "Plugin"]
let check_gen_elim_nondep_sem (i: gen_elim_i) (nd: gen_elim_nondep_t) : Tot prop =
match nd with
| GENonDep ty q post -> compute_gen_elim_tele i == gen_elim_nondep_sem ty q post
| GEDep -> True
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a' (ty: list Type0) : Tot Type0 =
match ty with
| [] -> unit
| [t1] -> t1
| [t1; t2] -> tuple2 t1 t2
| [t1; t2; t3] -> tuple3 t1 t2 t3
| [t1; t2; t3; t4] -> tuple4 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> tuple5 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> tuple6 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> tuple7 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> tuple8 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> tuple9 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> tuple10 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> tuple11 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> tuple12 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> tuple13 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> tuple14 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| _ -> unit // unsupported
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_a (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot Type0 =
match i with
| GENonDep ty q post -> compute_gen_elim_nondep_a' ty
| GEDep -> compute_gen_elim_a i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_uncurry (ret_type: Type u#a) (def: ret_type) (ty: list Type0) : curried_function_type ty ret_type -> compute_gen_elim_nondep_a' ty -> ret_type =
match ty as ty' returns (curried_function_type ty' ret_type -> compute_gen_elim_nondep_a' ty' -> ret_type) with
| [] -> fun q _ -> q
| [t1] -> fun q -> q
| [t1; t2] -> fun q x -> q (fstp x) (sndp x)
| [t1; t2; t3] -> fun q x -> q x._1 x._2 x._3
| [t1; t2; t3; t4] -> fun q x -> q x._1 x._2 x._3 x._4
| [t1; t2; t3; t4; t5] -> fun q x -> q x._1 x._2 x._3 x._4 x._5
| [t1; t2; t3; t4; t5; t6] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6
| [t1; t2; t3; t4; t5; t6; t7] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] -> fun q x -> q x._1 x._2 x._3 x._4 x._5 x._6 x._7 x._8 x._9 x._10 x._11 x._12 x._13 x._14
| _ -> fun _ _ -> def
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> vprop) =
match i with
| GENonDep ty q post -> compute_uncurry vprop (compute_gen_elim_p' i0) ty q
// that default value does not reduce, on purpose, to make the tactic fail if the type list is too long
| GEDep -> compute_gen_elim_q i0
[@@gen_elim_reduce]
let compute_gen_elim_nondep_q (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot vprop =
compute_gen_elim_nondep_q0 i0 i (Ghost.reveal x)
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post0 (i0: gen_elim_i) (i: gen_elim_nondep_t) : Tot (compute_gen_elim_nondep_a i0 i -> prop) =
match i with
| GENonDep ty q post -> compute_uncurry prop True ty post
| GEDep -> compute_gen_elim_post i0
[@@gen_elim_reduce; noextract_to "Plugin"]
let compute_gen_elim_nondep_post (i0: gen_elim_i) (i: gen_elim_nondep_t) (x: Ghost.erased (compute_gen_elim_nondep_a i0 i)) : Tot prop =
compute_gen_elim_nondep_post0 i0 i (Ghost.reveal x)
let is_squash (t:T.term) : T.Tac bool =
is_any_fvar t [`%squash; `%auto_squash]
let is_star_or_vstar (t:T.term) : T.Tac bool =
is_any_fvar t [`%star; `%VStar]
let rec term_has_head
(t: T.term)
(head: T.term)
: T.Tac bool
= let (hd, tl) = T.collect_app t in
if hd `T.term_eq_old` head
then true
else if is_star_or_vstar hd
then
match tl with
| [tg, T.Q_Explicit; td, T.Q_Explicit] ->
if term_has_head tg head
then true
else term_has_head td head
| _ -> false
else false
let rec solve_gen_unit_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`pure))
then T.mk_app (`GUEId) [tl', T.Q_Explicit]
else
let (hd, tl) = T.collect_app tl' in
if hd `is_fvar` (`%pure)
then T.mk_app (`GUEPure) tl
else if is_star_or_vstar hd
then match tl with
| [t1, T.Q_Explicit; t2, T.Q_Explicit] ->
let t1' = solve_gen_unit_elim t1 in
let t2' = solve_gen_unit_elim t2 in
T.mk_app (`GUEStar) [t1', T.Q_Explicit; t2', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GUEId) [tl', T.Q_Explicit]
let abstr_has_exists
(t: T.term)
: T.Tac bool
= match T.inspect t with
| T.Tv_Abs _ body -> term_has_head body (`exists_)
| _ -> false
let rec solve_gen_elim
(tl': T.term)
: T.Tac T.term
=
if not (term_has_head tl' (`exists_))
then begin
let t' = solve_gen_unit_elim tl' in
T.mk_app (`GEUnit) [t', T.Q_Explicit]
end else
let (hd, lbody) = T.collect_app tl' in
if hd `is_fvar` (`%exists_)
then
let (ty, body) =
match lbody with
| [(ty, T.Q_Implicit); (body, T.Q_Explicit)] -> ([(ty, T.Q_Implicit)], body)
| [(body, T.Q_Explicit)] -> ([], body)
| _ -> T.fail "ill-formed exists_"
in
begin match T.inspect body with
| T.Tv_Abs b abody ->
if not (term_has_head abody (`exists_))
then
let body' = solve_gen_unit_elim abody in
T.mk_app (`GEExistsUnit) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
else
let body' = solve_gen_elim abody in
T.mk_app (`GEExists) (ty `List.Tot.append` [T.mk_abs [b] body', T.Q_Explicit])
| _ ->
T.mk_app (`GEExistsNoAbs) lbody
end
else if is_star_or_vstar hd
then
match lbody with
| [(tl, T.Q_Explicit); (tr, T.Q_Explicit)] ->
if term_has_head tl (`exists_)
then
let tl' = solve_gen_elim tl in
if term_has_head tr (`exists_)
then
let tr' = solve_gen_elim tr in
T.mk_app (`GEStar) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else
let tr' = solve_gen_unit_elim tr in
T.mk_app (`GEStarL) [tl', T.Q_Explicit; tr', T.Q_Explicit]
else (* here, term_has_head tr (`exists_) holds, because otherwise we are in case (not (term_has_head tl (`exists_))) above *)
let tl' = solve_gen_unit_elim tl in
let tr' = solve_gen_elim tr in
T.mk_app (`GEStarR) [tl', T.Q_Explicit; tr', T.Q_Explicit]
| _ -> T.fail "ill-formed star"
else
T.mk_app (`GEUnit) [T.mk_app (`GUEId) lbody, T.Q_Explicit]
[@@ noextract_to "Plugin"]
val gen_elim_prop
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
: Tot prop
val gen_elim_prop_intro'
(i: gen_elim_i)
(j: gen_elim_nondep_t)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i j))
(sq_a: squash (a == compute_gen_elim_nondep_a i j))
(sq_q: squash (q == compute_gen_elim_nondep_q i j))
(sq_post: squash (post == compute_gen_elim_nondep_post i j))
: Lemma
(gen_elim_prop enable_nondep_opt p a q post)
let gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a: squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_q: squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_post: squash (post == compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma | false | false | Steel.ST.GenElim.Base.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 gen_elim_prop_intro
(i: gen_elim_i)
(ty: list Type0)
(tvprop: Type)
(q0: tvprop)
(tprop: Type)
(post0: tprop)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type0)
(q: (Ghost.erased a -> Tot vprop))
(post: (Ghost.erased a -> Tot prop))
(sq_tvprop: squash (tvprop == curried_function_type ty vprop))
(sq_tprop: squash (tprop == curried_function_type ty prop))
(sq_p: squash (p == compute_gen_elim_p i))
(sq_j: squash (check_gen_elim_nondep_sem i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
(sq_a: squash (a == compute_gen_elim_nondep_a i (mk_gen_elim_nondep ty tvprop q0 tprop post0))
)
(sq_q: squash (q == compute_gen_elim_nondep_q i (mk_gen_elim_nondep ty tvprop q0 tprop post0))
)
(sq_post:
squash (post ==
compute_gen_elim_nondep_post i (mk_gen_elim_nondep ty tvprop q0 tprop post0)))
: Lemma (gen_elim_prop enable_nondep_opt p a q post) | [] | Steel.ST.GenElim.Base.gen_elim_prop_intro | {
"file_name": "lib/steel/Steel.ST.GenElim.Base.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i: Steel.ST.GenElim.Base.gen_elim_i ->
ty: Prims.list Type0 ->
tvprop: Type ->
q0: tvprop ->
tprop: Type ->
post0: tprop ->
enable_nondep_opt: Prims.bool ->
p: Steel.Effect.Common.vprop ->
a: Type0 ->
q: (_: FStar.Ghost.erased a -> Steel.Effect.Common.vprop) ->
post: (_: FStar.Ghost.erased a -> Prims.prop) ->
sq_tvprop:
Prims.squash (tvprop ==
Steel.ST.GenElim.Base.curried_function_type ty Steel.Effect.Common.vprop) ->
sq_tprop: Prims.squash (tprop == Steel.ST.GenElim.Base.curried_function_type ty Prims.prop) ->
sq_p: Prims.squash (p == Steel.ST.GenElim.Base.compute_gen_elim_p i) ->
sq_j:
Prims.squash (Steel.ST.GenElim.Base.check_gen_elim_nondep_sem i
(Steel.ST.GenElim.Base.mk_gen_elim_nondep ty tvprop q0 tprop post0)) ->
sq_a:
Prims.squash (a ==
Steel.ST.GenElim.Base.compute_gen_elim_nondep_a i
(Steel.ST.GenElim.Base.mk_gen_elim_nondep ty tvprop q0 tprop post0)) ->
sq_q:
Prims.squash (q ==
Steel.ST.GenElim.Base.compute_gen_elim_nondep_q i
(Steel.ST.GenElim.Base.mk_gen_elim_nondep ty tvprop q0 tprop post0)) ->
sq_post:
Prims.squash (post ==
Steel.ST.GenElim.Base.compute_gen_elim_nondep_post i
(Steel.ST.GenElim.Base.mk_gen_elim_nondep ty tvprop q0 tprop post0))
-> FStar.Pervasives.Lemma
(ensures Steel.ST.GenElim.Base.gen_elim_prop enable_nondep_opt p a q post) | {
"end_col": 127,
"end_line": 447,
"start_col": 2,
"start_line": 447
} |
Subsets and Splits