effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FStar.All.ML | val lookup_output_type (ge: global_env) (i: ident) : ML out_typ | [
{
"abbrev": false,
"full_module": "GlobalEnv",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hashtable",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Ast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "GlobalEnv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Ast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lookup_output_type (ge:global_env) (i:ident) : ML out_typ =
match H.try_find ge.ge_out_t i.v with
| Some ({d_decl={v=OutputType out_t}}) -> out_t
| _ -> error (Printf.sprintf "Cannot find output type %s" (ident_to_string i)) i.range | val lookup_output_type (ge: global_env) (i: ident) : ML out_typ
let lookup_output_type (ge: global_env) (i: ident) : ML out_typ = | true | null | false | match H.try_find ge.ge_out_t i.v with
| Some { d_decl = { v = OutputType out_t } } -> out_t
| _ -> error (Printf.sprintf "Cannot find output type %s" (ident_to_string i)) i.range | {
"checked_file": "Binding.fst.checked",
"dependencies": [
"prims.fst.checked",
"Options.fsti.checked",
"Hashtable.fsti.checked",
"GlobalEnv.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked",
"Desugar.fst.checked",
"Deps.fsti.checked",
"Ast.fst.checked"
],
"interface_file": true,
"source_file": "Binding.fst"
} | [
"ml"
] | [
"GlobalEnv.global_env",
"Ast.ident",
"Ast.out_typ",
"Ast.range",
"Ast.comments",
"Prims.bool",
"FStar.Pervasives.Native.option",
"Ast.decl",
"Ast.error",
"FStar.Printf.sprintf",
"Ast.ident_to_string",
"Ast.__proj__Mkwith_meta_t__item__range",
"Ast.ident'",
"Hashtable.try_find",
"GlobalEnv.__proj__Mkglobal_env__item__ge_out_t",
"Ast.__proj__Mkwith_meta_t__item__v"
] | [] | (*
Copyright 2019 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 as 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 Binding
(*
This module implements a pass over the source AST
-- checking that all names are properly bound
-- well-typed
-- computing the size of types
-- computing which fields are dependent on others
*)
open FStar.Mul
open FStar.List.Tot
open Ast
open FStar.All
module H = Hashtable
include GlobalEnv
/// Maps locally bound names, i.e., a field name to its type
/// -- the bool signifies that this identifier has been used, and is
/// therefore marked as a dependent field
///
/// The modul_name in these ident' must be None -- TODO: add a refinement?
let local_env = H.t ident' (ident' & typ & bool)
/// `env` includes both a global and local env, together with a
/// binding for the `this` variable (bound to the name of a type) in
/// the current scope
noeq
type env = {
this: option ident;
locals: local_env;
globals: global_env;
}
let mk_env (g:global_env) =
{ this = None;
locals = H.create 10;
globals = g }
let copy_env (e:env) =
let locals = H.create 10 in
H.iter (fun k v -> H.insert locals k v) e.locals;
{
this = e.this;
globals = e.globals;
locals = locals
}
let env_of_global_env
: global_env -> env
= let locals = H.create 1 in
fun g -> { this = None; locals; globals = g }
let global_env_of_env e = e.globals
let params_of_decl (d:decl) : list param =
match d.d_decl.v with
| ModuleAbbrev _ _
| Define _ _ _
| TypeAbbrev _ _
| Enum _ _ _ -> []
| Record _ params _ _
| CaseType _ params _ -> params
| OutputType _ -> []
| ExternType _ -> []
| ExternFn _ _ ps -> ps
let check_shadow (e:H.t ident' 'a) (i:ident) (r:range) =
match H.try_find e i.v with
| Some j ->
let msg = Printf.sprintf "Declaration %s clashes with previous declaration" (ident_to_string i) in
error msg i.range
| _ -> ()
let typedef_names (d:decl) : option typedef_names =
match d.d_decl.v with
| Record td _ _ _
| CaseType td _ _ -> Some td
| _ -> None
let format_identifier (e:env) (i:ident) : ML ident =
let j =
match String.list_of_string i.v.name with
| [] ->
failwith "Impossible: empty identifier"
| c0::cs ->
if FStar.Char.lowercase c0 = c0
then i //it starts with a lowercase symbol; that's ok
else //otherwise, add an underscore
{i with v = {i.v with name=Ast.reserved_prefix ^ i.v.name}}
in
match H.try_find e.globals.ge_h j.v, H.try_find e.locals j.v with
| None, None -> j
| _ ->
let msg = Printf.sprintf
"This name (%s) starts will clash with another name in scope (%s) as it is translated. \
Please rename it"
(ident_to_string i) (ident_to_string j) in
error msg i.range
let add_global (e:global_env) (i:ident) (d:decl) (t:either decl_attributes macro_signature) : ML unit =
let insert k v = H.insert e.ge_h k v in
check_shadow e.ge_h i d.d_decl.range;
let env = mk_env e in
let i' = format_identifier env i in
insert i.v (d, t);
insert i'.v (d, t);
match typedef_names d with
| None -> ()
| Some td ->
if td.typedef_abbrev.v <> i.v
then begin
check_shadow e.ge_h td.typedef_abbrev d.d_decl.range;
let abbrev = format_identifier env td.typedef_abbrev in
insert td.typedef_abbrev.v (d, t);
insert abbrev.v (d, t)
end
let add_local (e:env) (i:ident) (t:typ) : ML unit =
check_shadow e.globals.ge_h i t.range;
check_shadow e.locals i t.range;
let i' = format_identifier e i in
H.insert e.locals i.v (i'.v, t, false);
H.insert e.locals i'.v (i'.v, t, false)
let try_lookup (e:env) (i:ident) : ML (option (either typ (decl & either decl_attributes macro_signature))) =
match H.try_find e.locals i.v with
| Some (_, t, true) ->
Some (Inl t)
| Some (j, t, false) -> //mark it as used
H.remove e.locals i.v;
H.insert e.locals i.v (j, t, true);
Some (Inl t)
| None ->
match H.try_find e.globals.ge_h i.v with
| Some d -> Some (Inr d)
| None -> None
let lookup (e:env) (i:ident) : ML (either typ (decl & either decl_attributes macro_signature)) =
match try_lookup e i with
| None -> error (Printf.sprintf "Variable %s not found" (ident_to_string i)) i.range
| Some v -> v
let remove_local (e:env) (i:ident) : ML unit =
match H.try_find e.locals i.v with
| Some (j, _, _) ->
H.remove e.locals i.v;
H.remove e.locals j
| _ -> ()
let resolve_record_case_output_extern_type_name (env:env) (i:ident) =
match H.try_find (global_env_of_env env).ge_out_t i.v with
| Some ({d_decl={v=OutputType ({out_typ_names=names})}}) -> names.typedef_abbrev
| _ ->
(match H.try_find (global_env_of_env env).ge_extern_t i.v with
| Some ({d_decl={v=ExternType td_names}}) -> td_names.typedef_abbrev
| _ ->
(match lookup env i with
| Inr ({d_decl={v=Record names _ _ _}}, _)
| Inr ({d_decl={v=CaseType names _ _}}, _) ->
names.typedef_name
| _ -> i))
let lookup_expr_name (e:env) (i:ident) : ML typ =
match lookup e i with
| Inl t -> t
| Inr (_, Inr ({ macro_arguments_t=[]; macro_result_t=t })) -> t
| Inr _ ->
error (Printf.sprintf "Variable %s is not an expression identifier" (ident_to_string i)) i.range
let lookup_macro_name (e:env) (i:ident) : ML macro_signature =
match lookup e i with
| Inr (_, Inr m) -> m
| _ -> error (Printf.sprintf "%s is an unknown operator" (ident_to_string i)) i.range
let lookup_macro_definition (e:env) (i:ident) =
try
let m = lookup_macro_name e i in
m.macro_defn_t
with
| _ -> None
let try_lookup_enum_cases (e:env) (i:ident)
: ML (option (list ident & typ))
= match lookup e i with
| Inr ({d_decl={v=Enum t _ tags}}, _) ->
Some (Desugar.check_desugared_enum_cases tags, t)
| _ -> None
let lookup_enum_cases (e:env) (i:ident)
: ML (list ident & typ)
= match try_lookup_enum_cases e i with
| Some (tags, t) -> tags, t
| _ -> error (Printf.sprintf "Type %s is not an enumeration" (ident_to_string i)) i.range
let is_enum (e:env) (t:typ) =
match t.v with
| Type_app i KindSpec [] ->
Some? (try_lookup_enum_cases e i)
| _ -> false
let is_used (e:env) (i:ident) : ML bool =
match H.try_find e.locals i.v with
| Some (_, t, b) -> b
| _ -> error (Printf.sprintf "Variable %s not found" (ident_to_string i)) i.range
let type_of_integer_type = function
| UInt8 -> tuint8
| UInt16 -> tuint16
| UInt32 -> tuint32
| UInt64 -> tuint64
let check_integer_bounds t i =
match t with
| UInt8 -> FStar.UInt.fits i 8
| UInt16 -> FStar.UInt.fits i 16
| UInt32 -> FStar.UInt.fits i 32
| UInt64 -> FStar.UInt.fits i 64
let type_of_constant rng (c:constant) : ML typ =
match c with
| Unit -> tunit
| Int tag i ->
if check_integer_bounds tag i
then type_of_integer_type tag
else error (Printf.sprintf "Constant %d is too large for its type %s" i (Ast.print_integer_type tag)) rng
| XInt tag _ -> //bounds checked by the syntax
type_of_integer_type tag
| Bool _ -> tbool
let parser_may_fail (env:env) (t:typ) : ML bool =
match t.v with
| Pointer _ -> true
| Type_app hd _ _ ->
match lookup env hd with
| Inr (d, Inl attrs) -> attrs.may_fail
| _ -> false
let typ_is_integral env (t:typ) : ML bool =
match t.v with
| Pointer _ -> false
| Type_app hd _ _ ->
match lookup env hd with
| Inr (d, Inl attrs) -> Some? attrs.integral
| _ -> false
let tag_of_integral_typ env (t:typ) : ML (option _) =
match t.v with
| Pointer _ -> None
| Type_app hd _ _ ->
match lookup env hd with
| Inr (_, Inl attrs) -> attrs.integral
| _ -> None
let tag_and_bit_order_of_integral_typ env (t:typ) : ML (tag_and_bit_order: (option integer_type & option bitfield_bit_order) { Some? (snd tag_and_bit_order) ==> Some? (fst tag_and_bit_order) }) =
match t.v with
| Pointer _ -> None, None
| Type_app hd _ _ ->
match lookup env hd with
| Inr (_, Inl attrs) -> attrs.integral, attrs.bit_order
| _ -> None, None
let has_reader (env:global_env) (id:ident) : ML bool =
match H.try_find env.ge_h id.v with
| Some (_, Inl attrs) -> attrs.has_reader
| _ -> false
let parser_kind_nz (env:global_env) (id:ident) : ML (option bool) =
match H.try_find env.ge_h id.v with
| Some (_, Inl attrs) -> attrs.parser_kind_nz
| _ -> None
let parser_weak_kind (env:global_env) (id:ident) : ML (option _) =
match H.try_find env.ge_h id.v with
| Some (_, Inl attrs) -> Some attrs.parser_weak_kind
| _ -> None
let typ_weak_kind env (t:typ) : ML (option weak_kind) =
match t.v with
| Pointer _ -> None
| Type_app hd _ _ -> parser_weak_kind env.globals hd
let typ_has_reader env (t:typ) : ML bool =
match t.v with
| Pointer _ -> false
| Type_app hd _ _ ->
has_reader env.globals hd
let rec unfold_typ_abbrev_only (env:env) (t:typ) : ML typ =
match t.v with
| Type_app hd _ [] -> //type abbreviations are not parameterized
begin
match try_lookup env hd with
| Some (Inr (d, _)) ->
begin
match d.d_decl.v with
| TypeAbbrev t _ -> unfold_typ_abbrev_only env t
| _ -> t
end
| _ -> t
end
| _ -> t
let update_typ_abbrev (env:env) (i:ident) (t:typ)
: ML unit
= match H.try_find env.globals.ge_h i.v with
| Some (d, ms) ->
let d_decl =
match d.d_decl.v with
| TypeAbbrev _ _ -> {d.d_decl with v = TypeAbbrev t i }
| _ -> failwith "Expected a type abbreviation"
in
let d = {d with d_decl = d_decl } in
let entry = (d, ms) in
H.insert env.globals.ge_h i.v entry
| _ ->
failwith "Type abbreviation not found"
let rec unfold_typ_abbrev_and_enum (env:env) (t:typ) : ML typ =
match t.v with
| Type_app hd _ [] -> //type abbreviations are not parameterized
begin
match lookup env hd with
| Inr (d, _) ->
begin
match d.d_decl.v with
| TypeAbbrev t _ -> unfold_typ_abbrev_and_enum env t
| Enum t _ _ -> unfold_typ_abbrev_and_enum env t
| _ -> t
end
| _ -> t
end
| _ -> t
let size_of_integral_typ (env:env) (t:typ) r
: ML int
= let t = unfold_typ_abbrev_and_enum env t in
if not (typ_is_integral env t)
then error (Printf.sprintf "Expected and integral type, got %s"
(print_typ t))
r;
match tag_of_integral_typ env t with
| None -> failwith "Impossible"
| Some UInt8 -> 1
| Some UInt16 -> 2
| Some UInt32 -> 4
| Some UInt64 -> 8
let bit_order_of_integral_typ (env:env) (t:typ) r
: ML bitfield_bit_order
= let t = unfold_typ_abbrev_and_enum env t in
if not (typ_is_integral env t)
then error (Printf.sprintf "Expected and integral type, got %s"
(print_typ t))
r;
match tag_and_bit_order_of_integral_typ env t with
| _, None -> failwith "Impossible"
| _, Some order -> order
let eq_typ env t1 t2 =
if Ast.eq_typ t1 t2 then true
else Ast.eq_typ (unfold_typ_abbrev_and_enum env t1) (unfold_typ_abbrev_and_enum env t2)
let eq_typs env ts =
List.for_all (fun (t1, t2) -> eq_typ env t1 t2) ts
let cast e t t' = { e with v = App (Cast (Some t) t') [e] }
let try_cast_integer env et to : ML (option expr) =
let e, from = et in
let i_to = typ_is_integral env to in
let i_from = typ_is_integral env from in
if i_from && i_to
then
let i_from = typ_as_integer_type (unfold_typ_abbrev_and_enum env from) in
let i_to = typ_as_integer_type (unfold_typ_abbrev_and_enum env to) in
if i_from = i_to
then Some e
else if integer_type_leq i_from i_to
then Some (cast e i_from i_to)
else None
else None
let _or_ b1 b2 = b1 || b2
let _and_ b1 b2 = b1 && b2
let try_retype_arith_exprs (env:env) e1 e2 rng : ML (option (expr & expr & typ))=
let e1, t1 = e1 in
let e2, t2 = e2 in
let fail #a i : ML a = raise (Error (Printf.sprintf "(%d) Failed to retype exprs (%s : %s) and (%s : %s)"
i
(print_expr e1)
(print_typ t1)
(print_expr e2)
(print_typ t2))) in
try
let t1, t2 = unfold_typ_abbrev_and_enum env t1, unfold_typ_abbrev_and_enum env t2 in
if not (typ_is_integral env t1 `_and_`
typ_is_integral env t2)
then fail 1;
let tt1 = typ_as_integer_type t1 in
let tt2 = typ_as_integer_type t2 in
let cast e t t' = { e with v = App (Cast (Some t) t') [e] } in
let e1, e2, t =
if integer_type_leq tt1 tt2
then cast e1 tt1 tt2,
e2,
t2
else if integer_type_leq tt2 tt1
then e1,
cast e2 tt2 tt1,
t1
else fail 0
in
// FStar.IO.print_string
// (Printf.sprintf "Retyped to (%s, %s, %s)\n"
// (print_expr e1)
// (print_expr e2)
// (print_typ t));
Some (e1, e2, t)
with
| Error msg ->
FStar.IO.print_string msg;
None
| _ -> None
(*
* Add output type to the environment
*
* TODO: check_shadow
*)
let add_output_type (ge:global_env) (i:ident) (d:decl{OutputType? d.d_decl.v}) : ML unit =
let insert i = H.insert ge.ge_out_t i d in
insert i.v;
let td_abbrev = (OutputType?._0 d.d_decl.v).out_typ_names.typedef_abbrev in
insert td_abbrev.v
(*
* Add extern type to the environment
*
* TODO: check shadow
*)
let add_extern_type (ge:global_env) (i:ident) (d:decl{ExternType? d.d_decl.v}) : ML unit =
let insert i = H.insert ge.ge_extern_t i d in
insert i.v;
let td_abbrev = (ExternType?._0 d.d_decl.v).typedef_abbrev in
insert td_abbrev.v
(*
* Add extern function to the environment
*
* TODO: check shadow
*)
let add_extern_fn (ge:global_env) (i:ident) (d:decl{ExternFn? d.d_decl.v}) : ML unit =
H.insert ge.ge_extern_fn i.v d | false | false | Binding.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lookup_output_type (ge: global_env) (i: ident) : ML out_typ | [] | Binding.lookup_output_type | {
"file_name": "src/3d/Binding.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | ge: GlobalEnv.global_env -> i: Ast.ident -> FStar.All.ML Ast.out_typ | {
"end_col": 88,
"end_line": 476,
"start_col": 2,
"start_line": 474
} |
FStar.All.ML | val update_typ_abbrev (_:env) (id:ident) (t:typ) : ML unit | [
{
"abbrev": false,
"full_module": "GlobalEnv",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hashtable",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Ast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "GlobalEnv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Ast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_typ_abbrev (env:env) (i:ident) (t:typ)
: ML unit
= match H.try_find env.globals.ge_h i.v with
| Some (d, ms) ->
let d_decl =
match d.d_decl.v with
| TypeAbbrev _ _ -> {d.d_decl with v = TypeAbbrev t i }
| _ -> failwith "Expected a type abbreviation"
in
let d = {d with d_decl = d_decl } in
let entry = (d, ms) in
H.insert env.globals.ge_h i.v entry
| _ ->
failwith "Type abbreviation not found" | val update_typ_abbrev (_:env) (id:ident) (t:typ) : ML unit
let update_typ_abbrev (env: env) (i: ident) (t: typ) : ML unit = | true | null | false | match H.try_find env.globals.ge_h i.v with
| Some (d, ms) ->
let d_decl =
match d.d_decl.v with
| TypeAbbrev _ _ -> { d.d_decl with v = TypeAbbrev t i }
| _ -> failwith "Expected a type abbreviation"
in
let d = { d with d_decl = d_decl } in
let entry = (d, ms) in
H.insert env.globals.ge_h i.v entry
| _ -> failwith "Type abbreviation not found" | {
"checked_file": "Binding.fst.checked",
"dependencies": [
"prims.fst.checked",
"Options.fsti.checked",
"Hashtable.fsti.checked",
"GlobalEnv.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked",
"Desugar.fst.checked",
"Deps.fsti.checked",
"Ast.fst.checked"
],
"interface_file": true,
"source_file": "Binding.fst"
} | [
"ml"
] | [
"Binding.env",
"Ast.ident",
"Ast.typ",
"Ast.decl",
"Ast.either",
"GlobalEnv.decl_attributes",
"GlobalEnv.macro_signature",
"Hashtable.insert",
"Ast.ident'",
"FStar.Pervasives.Native.tuple2",
"GlobalEnv.__proj__Mkglobal_env__item__ge_h",
"Binding.__proj__Mkenv__item__globals",
"Ast.__proj__Mkwith_meta_t__item__v",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Ast.Mkdecl",
"Ast.__proj__Mkdecl__item__d_exported",
"Ast.with_meta_t",
"Ast.decl'",
"Ast.__proj__Mkdecl__item__d_decl",
"Ast.Mkwith_meta_t",
"Ast.TypeAbbrev",
"Ast.__proj__Mkwith_meta_t__item__range",
"Ast.__proj__Mkwith_meta_t__item__comments",
"FStar.All.failwith",
"FStar.Pervasives.Native.option",
"Hashtable.try_find"
] | [] | (*
Copyright 2019 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 as 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 Binding
(*
This module implements a pass over the source AST
-- checking that all names are properly bound
-- well-typed
-- computing the size of types
-- computing which fields are dependent on others
*)
open FStar.Mul
open FStar.List.Tot
open Ast
open FStar.All
module H = Hashtable
include GlobalEnv
/// Maps locally bound names, i.e., a field name to its type
/// -- the bool signifies that this identifier has been used, and is
/// therefore marked as a dependent field
///
/// The modul_name in these ident' must be None -- TODO: add a refinement?
let local_env = H.t ident' (ident' & typ & bool)
/// `env` includes both a global and local env, together with a
/// binding for the `this` variable (bound to the name of a type) in
/// the current scope
noeq
type env = {
this: option ident;
locals: local_env;
globals: global_env;
}
let mk_env (g:global_env) =
{ this = None;
locals = H.create 10;
globals = g }
let copy_env (e:env) =
let locals = H.create 10 in
H.iter (fun k v -> H.insert locals k v) e.locals;
{
this = e.this;
globals = e.globals;
locals = locals
}
let env_of_global_env
: global_env -> env
= let locals = H.create 1 in
fun g -> { this = None; locals; globals = g }
let global_env_of_env e = e.globals
let params_of_decl (d:decl) : list param =
match d.d_decl.v with
| ModuleAbbrev _ _
| Define _ _ _
| TypeAbbrev _ _
| Enum _ _ _ -> []
| Record _ params _ _
| CaseType _ params _ -> params
| OutputType _ -> []
| ExternType _ -> []
| ExternFn _ _ ps -> ps
let check_shadow (e:H.t ident' 'a) (i:ident) (r:range) =
match H.try_find e i.v with
| Some j ->
let msg = Printf.sprintf "Declaration %s clashes with previous declaration" (ident_to_string i) in
error msg i.range
| _ -> ()
let typedef_names (d:decl) : option typedef_names =
match d.d_decl.v with
| Record td _ _ _
| CaseType td _ _ -> Some td
| _ -> None
let format_identifier (e:env) (i:ident) : ML ident =
let j =
match String.list_of_string i.v.name with
| [] ->
failwith "Impossible: empty identifier"
| c0::cs ->
if FStar.Char.lowercase c0 = c0
then i //it starts with a lowercase symbol; that's ok
else //otherwise, add an underscore
{i with v = {i.v with name=Ast.reserved_prefix ^ i.v.name}}
in
match H.try_find e.globals.ge_h j.v, H.try_find e.locals j.v with
| None, None -> j
| _ ->
let msg = Printf.sprintf
"This name (%s) starts will clash with another name in scope (%s) as it is translated. \
Please rename it"
(ident_to_string i) (ident_to_string j) in
error msg i.range
let add_global (e:global_env) (i:ident) (d:decl) (t:either decl_attributes macro_signature) : ML unit =
let insert k v = H.insert e.ge_h k v in
check_shadow e.ge_h i d.d_decl.range;
let env = mk_env e in
let i' = format_identifier env i in
insert i.v (d, t);
insert i'.v (d, t);
match typedef_names d with
| None -> ()
| Some td ->
if td.typedef_abbrev.v <> i.v
then begin
check_shadow e.ge_h td.typedef_abbrev d.d_decl.range;
let abbrev = format_identifier env td.typedef_abbrev in
insert td.typedef_abbrev.v (d, t);
insert abbrev.v (d, t)
end
let add_local (e:env) (i:ident) (t:typ) : ML unit =
check_shadow e.globals.ge_h i t.range;
check_shadow e.locals i t.range;
let i' = format_identifier e i in
H.insert e.locals i.v (i'.v, t, false);
H.insert e.locals i'.v (i'.v, t, false)
let try_lookup (e:env) (i:ident) : ML (option (either typ (decl & either decl_attributes macro_signature))) =
match H.try_find e.locals i.v with
| Some (_, t, true) ->
Some (Inl t)
| Some (j, t, false) -> //mark it as used
H.remove e.locals i.v;
H.insert e.locals i.v (j, t, true);
Some (Inl t)
| None ->
match H.try_find e.globals.ge_h i.v with
| Some d -> Some (Inr d)
| None -> None
let lookup (e:env) (i:ident) : ML (either typ (decl & either decl_attributes macro_signature)) =
match try_lookup e i with
| None -> error (Printf.sprintf "Variable %s not found" (ident_to_string i)) i.range
| Some v -> v
let remove_local (e:env) (i:ident) : ML unit =
match H.try_find e.locals i.v with
| Some (j, _, _) ->
H.remove e.locals i.v;
H.remove e.locals j
| _ -> ()
let resolve_record_case_output_extern_type_name (env:env) (i:ident) =
match H.try_find (global_env_of_env env).ge_out_t i.v with
| Some ({d_decl={v=OutputType ({out_typ_names=names})}}) -> names.typedef_abbrev
| _ ->
(match H.try_find (global_env_of_env env).ge_extern_t i.v with
| Some ({d_decl={v=ExternType td_names}}) -> td_names.typedef_abbrev
| _ ->
(match lookup env i with
| Inr ({d_decl={v=Record names _ _ _}}, _)
| Inr ({d_decl={v=CaseType names _ _}}, _) ->
names.typedef_name
| _ -> i))
let lookup_expr_name (e:env) (i:ident) : ML typ =
match lookup e i with
| Inl t -> t
| Inr (_, Inr ({ macro_arguments_t=[]; macro_result_t=t })) -> t
| Inr _ ->
error (Printf.sprintf "Variable %s is not an expression identifier" (ident_to_string i)) i.range
let lookup_macro_name (e:env) (i:ident) : ML macro_signature =
match lookup e i with
| Inr (_, Inr m) -> m
| _ -> error (Printf.sprintf "%s is an unknown operator" (ident_to_string i)) i.range
let lookup_macro_definition (e:env) (i:ident) =
try
let m = lookup_macro_name e i in
m.macro_defn_t
with
| _ -> None
let try_lookup_enum_cases (e:env) (i:ident)
: ML (option (list ident & typ))
= match lookup e i with
| Inr ({d_decl={v=Enum t _ tags}}, _) ->
Some (Desugar.check_desugared_enum_cases tags, t)
| _ -> None
let lookup_enum_cases (e:env) (i:ident)
: ML (list ident & typ)
= match try_lookup_enum_cases e i with
| Some (tags, t) -> tags, t
| _ -> error (Printf.sprintf "Type %s is not an enumeration" (ident_to_string i)) i.range
let is_enum (e:env) (t:typ) =
match t.v with
| Type_app i KindSpec [] ->
Some? (try_lookup_enum_cases e i)
| _ -> false
let is_used (e:env) (i:ident) : ML bool =
match H.try_find e.locals i.v with
| Some (_, t, b) -> b
| _ -> error (Printf.sprintf "Variable %s not found" (ident_to_string i)) i.range
let type_of_integer_type = function
| UInt8 -> tuint8
| UInt16 -> tuint16
| UInt32 -> tuint32
| UInt64 -> tuint64
let check_integer_bounds t i =
match t with
| UInt8 -> FStar.UInt.fits i 8
| UInt16 -> FStar.UInt.fits i 16
| UInt32 -> FStar.UInt.fits i 32
| UInt64 -> FStar.UInt.fits i 64
let type_of_constant rng (c:constant) : ML typ =
match c with
| Unit -> tunit
| Int tag i ->
if check_integer_bounds tag i
then type_of_integer_type tag
else error (Printf.sprintf "Constant %d is too large for its type %s" i (Ast.print_integer_type tag)) rng
| XInt tag _ -> //bounds checked by the syntax
type_of_integer_type tag
| Bool _ -> tbool
let parser_may_fail (env:env) (t:typ) : ML bool =
match t.v with
| Pointer _ -> true
| Type_app hd _ _ ->
match lookup env hd with
| Inr (d, Inl attrs) -> attrs.may_fail
| _ -> false
let typ_is_integral env (t:typ) : ML bool =
match t.v with
| Pointer _ -> false
| Type_app hd _ _ ->
match lookup env hd with
| Inr (d, Inl attrs) -> Some? attrs.integral
| _ -> false
let tag_of_integral_typ env (t:typ) : ML (option _) =
match t.v with
| Pointer _ -> None
| Type_app hd _ _ ->
match lookup env hd with
| Inr (_, Inl attrs) -> attrs.integral
| _ -> None
let tag_and_bit_order_of_integral_typ env (t:typ) : ML (tag_and_bit_order: (option integer_type & option bitfield_bit_order) { Some? (snd tag_and_bit_order) ==> Some? (fst tag_and_bit_order) }) =
match t.v with
| Pointer _ -> None, None
| Type_app hd _ _ ->
match lookup env hd with
| Inr (_, Inl attrs) -> attrs.integral, attrs.bit_order
| _ -> None, None
let has_reader (env:global_env) (id:ident) : ML bool =
match H.try_find env.ge_h id.v with
| Some (_, Inl attrs) -> attrs.has_reader
| _ -> false
let parser_kind_nz (env:global_env) (id:ident) : ML (option bool) =
match H.try_find env.ge_h id.v with
| Some (_, Inl attrs) -> attrs.parser_kind_nz
| _ -> None
let parser_weak_kind (env:global_env) (id:ident) : ML (option _) =
match H.try_find env.ge_h id.v with
| Some (_, Inl attrs) -> Some attrs.parser_weak_kind
| _ -> None
let typ_weak_kind env (t:typ) : ML (option weak_kind) =
match t.v with
| Pointer _ -> None
| Type_app hd _ _ -> parser_weak_kind env.globals hd
let typ_has_reader env (t:typ) : ML bool =
match t.v with
| Pointer _ -> false
| Type_app hd _ _ ->
has_reader env.globals hd
let rec unfold_typ_abbrev_only (env:env) (t:typ) : ML typ =
match t.v with
| Type_app hd _ [] -> //type abbreviations are not parameterized
begin
match try_lookup env hd with
| Some (Inr (d, _)) ->
begin
match d.d_decl.v with
| TypeAbbrev t _ -> unfold_typ_abbrev_only env t
| _ -> t
end
| _ -> t
end
| _ -> t
let update_typ_abbrev (env:env) (i:ident) (t:typ) | false | false | Binding.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_typ_abbrev (_:env) (id:ident) (t:typ) : ML unit | [] | Binding.update_typ_abbrev | {
"file_name": "src/3d/Binding.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | env: Binding.env -> id: Ast.ident -> t: Ast.typ -> FStar.All.ML Prims.unit | {
"end_col": 43,
"end_line": 334,
"start_col": 4,
"start_line": 322
} |
FStar.All.ML | val lookup_output_type_field (ge: global_env) (i f: ident) : ML (typ & option int) | [
{
"abbrev": false,
"full_module": "GlobalEnv",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hashtable",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Ast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "GlobalEnv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Ast",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lookup_output_type_field (ge:global_env) (i f:ident) : ML (typ & option int) =
let out_t = lookup_output_type ge i in
let rec find (flds:list out_field) : (option (typ & option int)) =
match flds with
| [] -> None
| (Out_field_named f' t n)::tl ->
if eq_idents f f' then Some (t, n)
else find tl
| (Out_field_anon l _)::tl ->
(match find l with
| None -> find tl
| Some t -> Some t) in
match find out_t.out_typ_fields with
| Some t -> t
| None ->
error (Printf.sprintf "Cannot find output field %s:%s" (ident_to_string i) (ident_to_string f)) f.range | val lookup_output_type_field (ge: global_env) (i f: ident) : ML (typ & option int)
let lookup_output_type_field (ge: global_env) (i f: ident) : ML (typ & option int) = | true | null | false | let out_t = lookup_output_type ge i in
let rec find (flds: list out_field) : (option (typ & option int)) =
match flds with
| [] -> None
| Out_field_named f' t n :: tl -> if eq_idents f f' then Some (t, n) else find tl
| Out_field_anon l _ :: tl ->
(match find l with
| None -> find tl
| Some t -> Some t)
in
match find out_t.out_typ_fields with
| Some t -> t
| None ->
error (Printf.sprintf "Cannot find output field %s:%s" (ident_to_string i) (ident_to_string f))
f.range | {
"checked_file": "Binding.fst.checked",
"dependencies": [
"prims.fst.checked",
"Options.fsti.checked",
"Hashtable.fsti.checked",
"GlobalEnv.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.String.fsti.checked",
"FStar.ST.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.IO.fst.checked",
"FStar.Char.fsti.checked",
"FStar.All.fst.checked",
"Desugar.fst.checked",
"Deps.fsti.checked",
"Ast.fst.checked"
],
"interface_file": true,
"source_file": "Binding.fst"
} | [
"ml"
] | [
"GlobalEnv.global_env",
"Ast.ident",
"Ast.__proj__Mkout_typ__item__out_typ_fields",
"FStar.Pervasives.Native.tuple2",
"Ast.typ",
"FStar.Pervasives.Native.option",
"Prims.int",
"Ast.error",
"FStar.Printf.sprintf",
"Ast.ident_to_string",
"Ast.__proj__Mkwith_meta_t__item__range",
"Ast.ident'",
"Prims.list",
"Ast.out_field",
"FStar.Pervasives.Native.None",
"Ast.eq_idents",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"Ast.out_typ",
"Binding.lookup_output_type"
] | [] | (*
Copyright 2019 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 as 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 Binding
(*
This module implements a pass over the source AST
-- checking that all names are properly bound
-- well-typed
-- computing the size of types
-- computing which fields are dependent on others
*)
open FStar.Mul
open FStar.List.Tot
open Ast
open FStar.All
module H = Hashtable
include GlobalEnv
/// Maps locally bound names, i.e., a field name to its type
/// -- the bool signifies that this identifier has been used, and is
/// therefore marked as a dependent field
///
/// The modul_name in these ident' must be None -- TODO: add a refinement?
let local_env = H.t ident' (ident' & typ & bool)
/// `env` includes both a global and local env, together with a
/// binding for the `this` variable (bound to the name of a type) in
/// the current scope
noeq
type env = {
this: option ident;
locals: local_env;
globals: global_env;
}
let mk_env (g:global_env) =
{ this = None;
locals = H.create 10;
globals = g }
let copy_env (e:env) =
let locals = H.create 10 in
H.iter (fun k v -> H.insert locals k v) e.locals;
{
this = e.this;
globals = e.globals;
locals = locals
}
let env_of_global_env
: global_env -> env
= let locals = H.create 1 in
fun g -> { this = None; locals; globals = g }
let global_env_of_env e = e.globals
let params_of_decl (d:decl) : list param =
match d.d_decl.v with
| ModuleAbbrev _ _
| Define _ _ _
| TypeAbbrev _ _
| Enum _ _ _ -> []
| Record _ params _ _
| CaseType _ params _ -> params
| OutputType _ -> []
| ExternType _ -> []
| ExternFn _ _ ps -> ps
let check_shadow (e:H.t ident' 'a) (i:ident) (r:range) =
match H.try_find e i.v with
| Some j ->
let msg = Printf.sprintf "Declaration %s clashes with previous declaration" (ident_to_string i) in
error msg i.range
| _ -> ()
let typedef_names (d:decl) : option typedef_names =
match d.d_decl.v with
| Record td _ _ _
| CaseType td _ _ -> Some td
| _ -> None
let format_identifier (e:env) (i:ident) : ML ident =
let j =
match String.list_of_string i.v.name with
| [] ->
failwith "Impossible: empty identifier"
| c0::cs ->
if FStar.Char.lowercase c0 = c0
then i //it starts with a lowercase symbol; that's ok
else //otherwise, add an underscore
{i with v = {i.v with name=Ast.reserved_prefix ^ i.v.name}}
in
match H.try_find e.globals.ge_h j.v, H.try_find e.locals j.v with
| None, None -> j
| _ ->
let msg = Printf.sprintf
"This name (%s) starts will clash with another name in scope (%s) as it is translated. \
Please rename it"
(ident_to_string i) (ident_to_string j) in
error msg i.range
let add_global (e:global_env) (i:ident) (d:decl) (t:either decl_attributes macro_signature) : ML unit =
let insert k v = H.insert e.ge_h k v in
check_shadow e.ge_h i d.d_decl.range;
let env = mk_env e in
let i' = format_identifier env i in
insert i.v (d, t);
insert i'.v (d, t);
match typedef_names d with
| None -> ()
| Some td ->
if td.typedef_abbrev.v <> i.v
then begin
check_shadow e.ge_h td.typedef_abbrev d.d_decl.range;
let abbrev = format_identifier env td.typedef_abbrev in
insert td.typedef_abbrev.v (d, t);
insert abbrev.v (d, t)
end
let add_local (e:env) (i:ident) (t:typ) : ML unit =
check_shadow e.globals.ge_h i t.range;
check_shadow e.locals i t.range;
let i' = format_identifier e i in
H.insert e.locals i.v (i'.v, t, false);
H.insert e.locals i'.v (i'.v, t, false)
let try_lookup (e:env) (i:ident) : ML (option (either typ (decl & either decl_attributes macro_signature))) =
match H.try_find e.locals i.v with
| Some (_, t, true) ->
Some (Inl t)
| Some (j, t, false) -> //mark it as used
H.remove e.locals i.v;
H.insert e.locals i.v (j, t, true);
Some (Inl t)
| None ->
match H.try_find e.globals.ge_h i.v with
| Some d -> Some (Inr d)
| None -> None
let lookup (e:env) (i:ident) : ML (either typ (decl & either decl_attributes macro_signature)) =
match try_lookup e i with
| None -> error (Printf.sprintf "Variable %s not found" (ident_to_string i)) i.range
| Some v -> v
let remove_local (e:env) (i:ident) : ML unit =
match H.try_find e.locals i.v with
| Some (j, _, _) ->
H.remove e.locals i.v;
H.remove e.locals j
| _ -> ()
let resolve_record_case_output_extern_type_name (env:env) (i:ident) =
match H.try_find (global_env_of_env env).ge_out_t i.v with
| Some ({d_decl={v=OutputType ({out_typ_names=names})}}) -> names.typedef_abbrev
| _ ->
(match H.try_find (global_env_of_env env).ge_extern_t i.v with
| Some ({d_decl={v=ExternType td_names}}) -> td_names.typedef_abbrev
| _ ->
(match lookup env i with
| Inr ({d_decl={v=Record names _ _ _}}, _)
| Inr ({d_decl={v=CaseType names _ _}}, _) ->
names.typedef_name
| _ -> i))
let lookup_expr_name (e:env) (i:ident) : ML typ =
match lookup e i with
| Inl t -> t
| Inr (_, Inr ({ macro_arguments_t=[]; macro_result_t=t })) -> t
| Inr _ ->
error (Printf.sprintf "Variable %s is not an expression identifier" (ident_to_string i)) i.range
let lookup_macro_name (e:env) (i:ident) : ML macro_signature =
match lookup e i with
| Inr (_, Inr m) -> m
| _ -> error (Printf.sprintf "%s is an unknown operator" (ident_to_string i)) i.range
let lookup_macro_definition (e:env) (i:ident) =
try
let m = lookup_macro_name e i in
m.macro_defn_t
with
| _ -> None
let try_lookup_enum_cases (e:env) (i:ident)
: ML (option (list ident & typ))
= match lookup e i with
| Inr ({d_decl={v=Enum t _ tags}}, _) ->
Some (Desugar.check_desugared_enum_cases tags, t)
| _ -> None
let lookup_enum_cases (e:env) (i:ident)
: ML (list ident & typ)
= match try_lookup_enum_cases e i with
| Some (tags, t) -> tags, t
| _ -> error (Printf.sprintf "Type %s is not an enumeration" (ident_to_string i)) i.range
let is_enum (e:env) (t:typ) =
match t.v with
| Type_app i KindSpec [] ->
Some? (try_lookup_enum_cases e i)
| _ -> false
let is_used (e:env) (i:ident) : ML bool =
match H.try_find e.locals i.v with
| Some (_, t, b) -> b
| _ -> error (Printf.sprintf "Variable %s not found" (ident_to_string i)) i.range
let type_of_integer_type = function
| UInt8 -> tuint8
| UInt16 -> tuint16
| UInt32 -> tuint32
| UInt64 -> tuint64
let check_integer_bounds t i =
match t with
| UInt8 -> FStar.UInt.fits i 8
| UInt16 -> FStar.UInt.fits i 16
| UInt32 -> FStar.UInt.fits i 32
| UInt64 -> FStar.UInt.fits i 64
let type_of_constant rng (c:constant) : ML typ =
match c with
| Unit -> tunit
| Int tag i ->
if check_integer_bounds tag i
then type_of_integer_type tag
else error (Printf.sprintf "Constant %d is too large for its type %s" i (Ast.print_integer_type tag)) rng
| XInt tag _ -> //bounds checked by the syntax
type_of_integer_type tag
| Bool _ -> tbool
let parser_may_fail (env:env) (t:typ) : ML bool =
match t.v with
| Pointer _ -> true
| Type_app hd _ _ ->
match lookup env hd with
| Inr (d, Inl attrs) -> attrs.may_fail
| _ -> false
let typ_is_integral env (t:typ) : ML bool =
match t.v with
| Pointer _ -> false
| Type_app hd _ _ ->
match lookup env hd with
| Inr (d, Inl attrs) -> Some? attrs.integral
| _ -> false
let tag_of_integral_typ env (t:typ) : ML (option _) =
match t.v with
| Pointer _ -> None
| Type_app hd _ _ ->
match lookup env hd with
| Inr (_, Inl attrs) -> attrs.integral
| _ -> None
let tag_and_bit_order_of_integral_typ env (t:typ) : ML (tag_and_bit_order: (option integer_type & option bitfield_bit_order) { Some? (snd tag_and_bit_order) ==> Some? (fst tag_and_bit_order) }) =
match t.v with
| Pointer _ -> None, None
| Type_app hd _ _ ->
match lookup env hd with
| Inr (_, Inl attrs) -> attrs.integral, attrs.bit_order
| _ -> None, None
let has_reader (env:global_env) (id:ident) : ML bool =
match H.try_find env.ge_h id.v with
| Some (_, Inl attrs) -> attrs.has_reader
| _ -> false
let parser_kind_nz (env:global_env) (id:ident) : ML (option bool) =
match H.try_find env.ge_h id.v with
| Some (_, Inl attrs) -> attrs.parser_kind_nz
| _ -> None
let parser_weak_kind (env:global_env) (id:ident) : ML (option _) =
match H.try_find env.ge_h id.v with
| Some (_, Inl attrs) -> Some attrs.parser_weak_kind
| _ -> None
let typ_weak_kind env (t:typ) : ML (option weak_kind) =
match t.v with
| Pointer _ -> None
| Type_app hd _ _ -> parser_weak_kind env.globals hd
let typ_has_reader env (t:typ) : ML bool =
match t.v with
| Pointer _ -> false
| Type_app hd _ _ ->
has_reader env.globals hd
let rec unfold_typ_abbrev_only (env:env) (t:typ) : ML typ =
match t.v with
| Type_app hd _ [] -> //type abbreviations are not parameterized
begin
match try_lookup env hd with
| Some (Inr (d, _)) ->
begin
match d.d_decl.v with
| TypeAbbrev t _ -> unfold_typ_abbrev_only env t
| _ -> t
end
| _ -> t
end
| _ -> t
let update_typ_abbrev (env:env) (i:ident) (t:typ)
: ML unit
= match H.try_find env.globals.ge_h i.v with
| Some (d, ms) ->
let d_decl =
match d.d_decl.v with
| TypeAbbrev _ _ -> {d.d_decl with v = TypeAbbrev t i }
| _ -> failwith "Expected a type abbreviation"
in
let d = {d with d_decl = d_decl } in
let entry = (d, ms) in
H.insert env.globals.ge_h i.v entry
| _ ->
failwith "Type abbreviation not found"
let rec unfold_typ_abbrev_and_enum (env:env) (t:typ) : ML typ =
match t.v with
| Type_app hd _ [] -> //type abbreviations are not parameterized
begin
match lookup env hd with
| Inr (d, _) ->
begin
match d.d_decl.v with
| TypeAbbrev t _ -> unfold_typ_abbrev_and_enum env t
| Enum t _ _ -> unfold_typ_abbrev_and_enum env t
| _ -> t
end
| _ -> t
end
| _ -> t
let size_of_integral_typ (env:env) (t:typ) r
: ML int
= let t = unfold_typ_abbrev_and_enum env t in
if not (typ_is_integral env t)
then error (Printf.sprintf "Expected and integral type, got %s"
(print_typ t))
r;
match tag_of_integral_typ env t with
| None -> failwith "Impossible"
| Some UInt8 -> 1
| Some UInt16 -> 2
| Some UInt32 -> 4
| Some UInt64 -> 8
let bit_order_of_integral_typ (env:env) (t:typ) r
: ML bitfield_bit_order
= let t = unfold_typ_abbrev_and_enum env t in
if not (typ_is_integral env t)
then error (Printf.sprintf "Expected and integral type, got %s"
(print_typ t))
r;
match tag_and_bit_order_of_integral_typ env t with
| _, None -> failwith "Impossible"
| _, Some order -> order
let eq_typ env t1 t2 =
if Ast.eq_typ t1 t2 then true
else Ast.eq_typ (unfold_typ_abbrev_and_enum env t1) (unfold_typ_abbrev_and_enum env t2)
let eq_typs env ts =
List.for_all (fun (t1, t2) -> eq_typ env t1 t2) ts
let cast e t t' = { e with v = App (Cast (Some t) t') [e] }
let try_cast_integer env et to : ML (option expr) =
let e, from = et in
let i_to = typ_is_integral env to in
let i_from = typ_is_integral env from in
if i_from && i_to
then
let i_from = typ_as_integer_type (unfold_typ_abbrev_and_enum env from) in
let i_to = typ_as_integer_type (unfold_typ_abbrev_and_enum env to) in
if i_from = i_to
then Some e
else if integer_type_leq i_from i_to
then Some (cast e i_from i_to)
else None
else None
let _or_ b1 b2 = b1 || b2
let _and_ b1 b2 = b1 && b2
let try_retype_arith_exprs (env:env) e1 e2 rng : ML (option (expr & expr & typ))=
let e1, t1 = e1 in
let e2, t2 = e2 in
let fail #a i : ML a = raise (Error (Printf.sprintf "(%d) Failed to retype exprs (%s : %s) and (%s : %s)"
i
(print_expr e1)
(print_typ t1)
(print_expr e2)
(print_typ t2))) in
try
let t1, t2 = unfold_typ_abbrev_and_enum env t1, unfold_typ_abbrev_and_enum env t2 in
if not (typ_is_integral env t1 `_and_`
typ_is_integral env t2)
then fail 1;
let tt1 = typ_as_integer_type t1 in
let tt2 = typ_as_integer_type t2 in
let cast e t t' = { e with v = App (Cast (Some t) t') [e] } in
let e1, e2, t =
if integer_type_leq tt1 tt2
then cast e1 tt1 tt2,
e2,
t2
else if integer_type_leq tt2 tt1
then e1,
cast e2 tt2 tt1,
t1
else fail 0
in
// FStar.IO.print_string
// (Printf.sprintf "Retyped to (%s, %s, %s)\n"
// (print_expr e1)
// (print_expr e2)
// (print_typ t));
Some (e1, e2, t)
with
| Error msg ->
FStar.IO.print_string msg;
None
| _ -> None
(*
* Add output type to the environment
*
* TODO: check_shadow
*)
let add_output_type (ge:global_env) (i:ident) (d:decl{OutputType? d.d_decl.v}) : ML unit =
let insert i = H.insert ge.ge_out_t i d in
insert i.v;
let td_abbrev = (OutputType?._0 d.d_decl.v).out_typ_names.typedef_abbrev in
insert td_abbrev.v
(*
* Add extern type to the environment
*
* TODO: check shadow
*)
let add_extern_type (ge:global_env) (i:ident) (d:decl{ExternType? d.d_decl.v}) : ML unit =
let insert i = H.insert ge.ge_extern_t i d in
insert i.v;
let td_abbrev = (ExternType?._0 d.d_decl.v).typedef_abbrev in
insert td_abbrev.v
(*
* Add extern function to the environment
*
* TODO: check shadow
*)
let add_extern_fn (ge:global_env) (i:ident) (d:decl{ExternFn? d.d_decl.v}) : ML unit =
H.insert ge.ge_extern_fn i.v d
let lookup_output_type (ge:global_env) (i:ident) : ML out_typ =
match H.try_find ge.ge_out_t i.v with
| Some ({d_decl={v=OutputType out_t}}) -> out_t
| _ -> error (Printf.sprintf "Cannot find output type %s" (ident_to_string i)) i.range
(*
* Returns the type of the field, with optional bitwidth if the field is a bitfield | false | false | Binding.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lookup_output_type_field (ge: global_env) (i f: ident) : ML (typ & option int) | [] | Binding.lookup_output_type_field | {
"file_name": "src/3d/Binding.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | ge: GlobalEnv.global_env -> i: Ast.ident -> f: Ast.ident
-> FStar.All.ML (Ast.typ * FStar.Pervasives.Native.option Prims.int) | {
"end_col": 107,
"end_line": 496,
"start_col": 82,
"start_line": 481
} |
Prims.Tot | val validate_int32le:validator parse_int32le | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int32le",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let validate_int32le : validator parse_int32le
= validate_total_constant_size parse_int32le 4uL () | val validate_int32le:validator parse_int32le
let validate_int32le:validator parse_int32le = | false | null | false | validate_total_constant_size parse_int32le 4uL () | {
"checked_file": "LowParse.Low.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.Int32le.fst.checked",
"LowParse.Low.Combinators.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.Int32le.fst"
} | [
"total"
] | [
"LowParse.Low.Base.validate_total_constant_size",
"LowParse.Spec.Base.total_constant_size_parser_kind",
"FStar.UInt32.t",
"LowParse.Spec.Int32le.parse_int32le",
"FStar.UInt64.__uint_to_t"
] | [] | module LowParse.Low.Int32le
(* LowParse implementation module for 32 bits little endian integers *)
include LowParse.Low.Combinators
include LowParse.Spec.Int32le
module U32 = FStar.UInt32
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
inline_for_extraction
let read_int32le : leaf_reader parse_int32le
= make_total_constant_size_reader 4 4ul decode_int32le (decode_int32le_total_constant ()) (fun #rrel #rel b pos ->
let h = HST.get () in
[@inline_let] let _ = decode_int32le_eq (Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + 4)) in
let r0 = B.index b pos in
let r1 = B.index b (pos `U32.add` 1ul) in
let r2 = B.index b (pos `U32.add` 2ul) in
let r3 = B.index b (pos `U32.add` 3ul) in
Cast.uint8_to_uint32 r0 `U32.add` (256ul `U32.mul` (Cast.uint8_to_uint32 r1 `U32.add` (256ul `U32.mul` (Cast.uint8_to_uint32 r2 `U32.add` (256ul `U32.mul` Cast.uint8_to_uint32 r3)))))
)
inline_for_extraction | false | false | LowParse.Low.Int32le.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_int32le:validator parse_int32le | [] | LowParse.Low.Int32le.validate_int32le | {
"file_name": "src/lowparse/LowParse.Low.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Low.Base.validator LowParse.Spec.Int32le.parse_int32le | {
"end_col": 51,
"end_line": 28,
"start_col": 2,
"start_line": 28
} |
Prims.Tot | val read_int32le:leaf_reader parse_int32le | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int32le",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let read_int32le : leaf_reader parse_int32le
= make_total_constant_size_reader 4 4ul decode_int32le (decode_int32le_total_constant ()) (fun #rrel #rel b pos ->
let h = HST.get () in
[@inline_let] let _ = decode_int32le_eq (Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + 4)) in
let r0 = B.index b pos in
let r1 = B.index b (pos `U32.add` 1ul) in
let r2 = B.index b (pos `U32.add` 2ul) in
let r3 = B.index b (pos `U32.add` 3ul) in
Cast.uint8_to_uint32 r0 `U32.add` (256ul `U32.mul` (Cast.uint8_to_uint32 r1 `U32.add` (256ul `U32.mul` (Cast.uint8_to_uint32 r2 `U32.add` (256ul `U32.mul` Cast.uint8_to_uint32 r3)))))
) | val read_int32le:leaf_reader parse_int32le
let read_int32le:leaf_reader parse_int32le = | false | null | false | make_total_constant_size_reader 4
4ul
decode_int32le
(decode_int32le_total_constant ())
(fun #rrel #rel b pos ->
let h = HST.get () in
[@@ inline_let ]let _ =
decode_int32le_eq (Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + 4))
in
let r0 = B.index b pos in
let r1 = B.index b (pos `U32.add` 1ul) in
let r2 = B.index b (pos `U32.add` 2ul) in
let r3 = B.index b (pos `U32.add` 3ul) in
(Cast.uint8_to_uint32 r0)
`U32.add`
(256ul
`U32.mul`
((Cast.uint8_to_uint32 r1)
`U32.add`
(256ul
`U32.mul`
((Cast.uint8_to_uint32 r2) `U32.add` (256ul `U32.mul` (Cast.uint8_to_uint32 r3))))))) | {
"checked_file": "LowParse.Low.Int32le.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.Int32le.fst.checked",
"LowParse.Low.Combinators.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.Int32le.fst"
} | [
"total"
] | [
"LowParse.Low.Combinators.make_total_constant_size_reader",
"FStar.UInt32.__uint_to_t",
"FStar.UInt32.t",
"LowParse.Spec.Int32le.decode_int32le",
"LowParse.Spec.Int32le.decode_int32le_total_constant",
"LowStar.Monotonic.Buffer.srel",
"LowParse.Bytes.byte",
"LowStar.Monotonic.Buffer.mbuffer",
"FStar.UInt32.add",
"FStar.Int.Cast.uint8_to_uint32",
"FStar.UInt32.mul",
"LowStar.Monotonic.Buffer.index",
"Prims.unit",
"LowParse.Spec.Int32le.decode_int32le_eq",
"FStar.Seq.Base.slice",
"LowStar.Monotonic.Buffer.as_seq",
"FStar.UInt32.v",
"Prims.op_Addition",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module LowParse.Low.Int32le
(* LowParse implementation module for 32 bits little endian integers *)
include LowParse.Low.Combinators
include LowParse.Spec.Int32le
module U32 = FStar.UInt32
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
inline_for_extraction | false | false | LowParse.Low.Int32le.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val read_int32le:leaf_reader parse_int32le | [] | LowParse.Low.Int32le.read_int32le | {
"file_name": "src/lowparse/LowParse.Low.Int32le.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Low.Base.leaf_reader LowParse.Spec.Int32le.parse_int32le | {
"end_col": 3,
"end_line": 24,
"start_col": 2,
"start_line": 16
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let elem = uint16 | let elem = | false | null | false | uint16 | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint16"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences | false | true | Spec.Matrix.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 elem : Type0 | [] | Spec.Matrix.elem | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 17,
"end_line": 80,
"start_col": 11,
"start_line": 80
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j | let op_Array_Access #n1 #n2 (m: matrix n1 n2) (i, j) = | false | null | false | mget m i j | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.matrix",
"FStar.Pervasives.Native.tuple2",
"Prims.op_LessThan",
"Spec.Matrix.mget",
"Spec.Matrix.elem"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j] | false | false | Spec.Matrix.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 op_Array_Access : m: Spec.Matrix.matrix n1 n2 ->
_: (i: Lib.IntTypes.size_nat{i < n1} * j: Lib.IntTypes.size_nat{j < n2})
-> Spec.Matrix.elem | [] | Spec.Matrix.op_Array_Access | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
m: Spec.Matrix.matrix n1 n2 ->
_: (i: Lib.IntTypes.size_nat{i < n1} * j: Lib.IntTypes.size_nat{j < n2})
-> Spec.Matrix.elem | {
"end_col": 63,
"end_line": 103,
"start_col": 53,
"start_line": 103
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x | let op_Array_Assignment #n1 #n2 (m: matrix n1 n2) (i, j) x = | false | null | false | mset m i j x | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.matrix",
"FStar.Pervasives.Native.tuple2",
"Prims.op_LessThan",
"Spec.Matrix.elem",
"Spec.Matrix.mset"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v | false | false | Spec.Matrix.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 op_Array_Assignment : m: Spec.Matrix.matrix n1 n2 ->
_: (i: Lib.IntTypes.size_nat{i < n1} * j: Lib.IntTypes.size_nat{j < n2}) ->
x: Spec.Matrix.elem
-> Spec.Matrix.matrix n1 n2 | [] | Spec.Matrix.op_Array_Assignment | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
m: Spec.Matrix.matrix n1 n2 ->
_: (i: Lib.IntTypes.size_nat{i < n1} * j: Lib.IntTypes.size_nat{j < n2}) ->
x: Spec.Matrix.elem
-> Spec.Matrix.matrix n1 n2 | {
"end_col": 71,
"end_line": 125,
"start_col": 59,
"start_line": 125
} |
|
Prims.Tot | val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let create n1 n2 = LSeq.create (n1 * n2) (u16 0) | val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = | false | null | false | LSeq.create (n1 * n2) (u16 0) | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.create",
"Spec.Matrix.elem",
"Lib.IntTypes.u16",
"Spec.Matrix.matrix"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2) | false | false | Spec.Matrix.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 create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2 | [] | Spec.Matrix.create | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n1: Lib.IntTypes.size_nat -> n2: Lib.IntTypes.size_nat{n1 * n2 <= Lib.IntTypes.max_size_t}
-> Spec.Matrix.matrix n1 n2 | {
"end_col": 48,
"end_line": 86,
"start_col": 19,
"start_line": 86
} |
FStar.Pervasives.Lemma | val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_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_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
} | val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j = | false | null | true | calc ( <= ) {
i * n2 + j;
( <= ) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
( == ) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
( <= ) { () }
n1 * n2 - 1;
} | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.op_Subtraction",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.eq2",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.lemma_mult_le_right",
"Prims.squash",
"FStar.Math.Lemmas.distributivity_sub_left"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2) | false | false | Spec.Matrix.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_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2) | [] | Spec.Matrix.index_lt | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n1: Lib.IntTypes.size_nat ->
n2: Lib.IntTypes.size_nat ->
i: Lib.IntTypes.size_nat{i < n1} ->
j: Lib.IntTypes.size_nat{j < n2}
-> FStar.Pervasives.Lemma (ensures i * n2 + j < n1 * n2) | {
"end_col": 5,
"end_line": 33,
"start_col": 2,
"start_line": 25
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2) | let matrix (n1: size_nat) (n2: size_nat{n1 * n2 <= max_size_t}) = | false | null | false | LSeq.lseq elem (n1 * n2) | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Spec.Matrix.elem"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16 | false | false | Spec.Matrix.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 matrix : n1: Lib.IntTypes.size_nat -> n2: Lib.IntTypes.size_nat{n1 * n2 <= Lib.IntTypes.max_size_t} -> Type0 | [] | Spec.Matrix.matrix | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n1: Lib.IntTypes.size_nat -> n2: Lib.IntTypes.size_nat{n1 * n2 <= Lib.IntTypes.max_size_t} -> Type0 | {
"end_col": 88,
"end_line": 83,
"start_col": 64,
"start_line": 83
} |
|
Prims.Tot | val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) } | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add #n1 #n2 a b =
map2 add_mod a b | val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b = | false | null | false | map2 add_mod a b | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.matrix",
"Spec.Matrix.map2",
"Lib.IntTypes.add_mod",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Prims.l_Forall",
"Prims.l_and",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.IntTypes.int_t",
"Spec.Matrix.op_Array_Access",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.op_Plus_Dot"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) } | false | false | Spec.Matrix.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 add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) } | [] | Spec.Matrix.add | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Matrix.matrix n1 n2 -> b: Spec.Matrix.matrix n1 n2
-> c:
Spec.Matrix.matrix n1 n2
{ forall (i: Lib.IntTypes.size_nat{i < n1 /\ i < n1 /\ i < n1})
(j: Lib.IntTypes.size_nat{j < n2 /\ j < n2 /\ j < n2}).
c.(i, j) == a.(i, j) +. b.(i, j) } | {
"end_col": 18,
"end_line": 241,
"start_col": 2,
"start_line": 241
} |
Prims.Tot | val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) } | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub #n1 #n2 a b =
map2 sub_mod a b | val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b = | false | null | false | map2 sub_mod a b | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.matrix",
"Spec.Matrix.map2",
"Lib.IntTypes.sub_mod",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Prims.l_Forall",
"Prims.l_and",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.IntTypes.int_t",
"Spec.Matrix.op_Array_Access",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.op_Subtraction_Dot"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) } | false | false | Spec.Matrix.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 sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) } | [] | Spec.Matrix.sub | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Matrix.matrix n1 n2 -> b: Spec.Matrix.matrix n1 n2
-> c:
Spec.Matrix.matrix n1 n2
{ forall (i: Lib.IntTypes.size_nat{i < n1 /\ i < n1 /\ i < n1})
(j: Lib.IntTypes.size_nat{j < n2 /\ j < n2 /\ j < n2}).
c.(i, j) == a.(i, j) -. b.(i, j) } | {
"end_col": 18,
"end_line": 252,
"start_col": 2,
"start_line": 252
} |
Prims.Tot | val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j] | val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j = | false | null | false | index_lt n1 n2 i j;
a.[ i * n2 + j ] | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.matrix",
"Prims.op_LessThan",
"Lib.Sequence.op_String_Access",
"Spec.Matrix.elem",
"Prims.op_Addition",
"Prims.unit",
"Spec.Matrix.index_lt"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem | false | false | Spec.Matrix.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 mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem | [] | Spec.Matrix.mget | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Matrix.matrix n1 n2 -> i: Lib.IntTypes.size_nat{i < n1} -> j: Lib.IntTypes.size_nat{j < n2}
-> Spec.Matrix.elem | {
"end_col": 16,
"end_line": 99,
"start_col": 2,
"start_line": 98
} |
Prims.GTot | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sum #n f = sum_ #n f n | let sum #n f = | false | null | false | sum_ #n f n | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"sometrivial"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.uint16",
"Spec.Matrix.sum_"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1) | false | false | Spec.Matrix.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 sum : f: (j: Lib.IntTypes.size_nat{j < n} -> Prims.GTot Lib.IntTypes.uint16)
-> Prims.GTot Lib.IntTypes.uint16 | [] | Spec.Matrix.sum | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: (j: Lib.IntTypes.size_nat{j < n} -> Prims.GTot Lib.IntTypes.uint16)
-> Prims.GTot Lib.IntTypes.uint16 | {
"end_col": 26,
"end_line": 266,
"start_col": 15,
"start_line": 266
} |
|
Prims.GTot | val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_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 sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1) | val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i = | false | null | false | if i = 0 then u16 0 else sum_ #n f (i - 1) +. f (i - 1) | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"sometrivial",
""
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.uint16",
"Prims.op_LessThanOrEqual",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.u16",
"Prims.bool",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Spec.Matrix.sum_",
"Prims.op_Subtraction"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i) | false | false | Spec.Matrix.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 sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i) | [
"recursion"
] | Spec.Matrix.sum_ | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f: (j: Lib.IntTypes.size_nat{j < n} -> Prims.GTot Lib.IntTypes.uint16) ->
i: Lib.IntTypes.size_nat{i <= n}
-> Prims.GTot Lib.IntTypes.uint16 | {
"end_col": 37,
"end_line": 264,
"start_col": 2,
"start_line": 263
} |
Prims.Tot | val mget_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mget_s #n1 #n2 a i j =
index_lt n2 n1 j i;
a.[j * n1 + i] | val mget_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget_s #n1 #n2 a i j = | false | null | false | index_lt n2 n1 j i;
a.[ j * n1 + i ] | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.matrix",
"Prims.op_LessThan",
"Lib.Sequence.op_String_Access",
"Spec.Matrix.elem",
"Prims.op_Addition",
"Prims.unit",
"Spec.Matrix.index_lt"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1)
let sum #n f = sum_ #n f n
#push-options "--fuel 1"
val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i)
let rec sum_extensionality n f g i =
if i = 0 then ()
else sum_extensionality n f g (i - 1)
val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul_inner #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. b.(l, k) in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. b.(j, k)
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. b.(l, k)) n2;
res
#pop-options
val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. b.(l, k)))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. b.(l, k1))) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner #n1 #n2 #n3 a b i k
) c
) c
val mget_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem | false | false | Spec.Matrix.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 mget_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem | [] | Spec.Matrix.mget_s | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Matrix.matrix n1 n2 -> i: Lib.IntTypes.size_nat{i < n1} -> j: Lib.IntTypes.size_nat{j < n2}
-> Spec.Matrix.elem | {
"end_col": 16,
"end_line": 340,
"start_col": 2,
"start_line": 339
} |
FStar.Pervasives.Lemma | val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_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 sum_extensionality n f g i =
if i = 0 then ()
else sum_extensionality n f g (i - 1) | val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i)
let rec sum_extensionality n f g i = | false | null | true | if i = 0 then () else sum_extensionality n f g (i - 1) | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"lemma",
""
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.uint16",
"Prims.op_LessThanOrEqual",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Spec.Matrix.sum_extensionality",
"Prims.op_Subtraction",
"Prims.unit"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1)
let sum #n f = sum_ #n f n
#push-options "--fuel 1"
val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i) | false | false | Spec.Matrix.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i) | [
"recursion"
] | Spec.Matrix.sum_extensionality | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n: Lib.IntTypes.size_nat ->
f: (i: Lib.IntTypes.size_nat{i < n} -> Prims.GTot Lib.IntTypes.uint16) ->
g: (i: Lib.IntTypes.size_nat{i < n} -> Prims.GTot Lib.IntTypes.uint16) ->
i: Lib.IntTypes.size_nat{i <= n}
-> FStar.Pervasives.Lemma (requires forall (i: Lib.IntTypes.size_nat{i < n}). f i == g i)
(ensures Spec.Matrix.sum_ f i == Spec.Matrix.sum_ g i)
(decreases i) | {
"end_col": 39,
"end_line": 282,
"start_col": 2,
"start_line": 281
} |
Prims.Pure | val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j'))) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v | val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v = | false | null | false | Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[ i * n2 + j ] <- v | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.matrix",
"Prims.op_LessThan",
"Spec.Matrix.elem",
"Lib.Sequence.op_String_Assignment",
"Prims.op_Addition",
"Prims.unit",
"Spec.Matrix.index_lt",
"FStar.Classical.forall_intro_2",
"Prims.nat",
"Prims.l_imp",
"Prims.op_disEquality",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Prims.l_and",
"Prims.int",
"Spec.Matrix.index_neq"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j'))) | false | false | Spec.Matrix.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 mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j'))) | [] | Spec.Matrix.mset | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Matrix.matrix n1 n2 ->
i: Lib.IntTypes.size_nat{i < n1} ->
j: Lib.IntTypes.size_nat{j < n2} ->
v: Spec.Matrix.elem
-> Prims.Pure (Spec.Matrix.matrix n1 n2) | {
"end_col": 21,
"end_line": 121,
"start_col": 2,
"start_line": 119
} |
Prims.Pure | val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1) | val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a = | false | null | false | Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1) | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [] | [
"Lib.IntTypes.size_pos",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.Matrix.elem",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.op_Less_Less_Dot",
"Lib.IntTypes.u16",
"Lib.IntTypes.size",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.IntTypes.range_t",
"Lib.IntTypes.v",
"Lib.IntTypes.mod_mask",
"Lib.IntTypes.mod_mask_lemma",
"FStar.Math.Lemmas.pow2_lt_compat"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq) | false | false | Spec.Matrix.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 mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq) | [] | Spec.Matrix.mod_pow2_felem | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | logq: Lib.IntTypes.size_pos{logq < 16} -> a: Spec.Matrix.elem -> Prims.Pure Spec.Matrix.elem | {
"end_col": 39,
"end_line": 195,
"start_col": 2,
"start_line": 192
} |
FStar.Pervasives.Lemma | val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2)) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_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_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
} | val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' = | false | null | true | index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i
then
calc ( < ) {
i' * n2 + j';
( < ) { () }
i' * n2 + n2;
( == ) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
( <= ) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
( <= ) { () }
i * n2 + j;
}
else
if i = i'
then ()
else
calc ( < ) {
i * n2 + j;
( < ) { () }
i * n2 + n2;
( == ) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
( <= ) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
( <= ) { () }
i' * n2 + j';
} | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Prims.op_LessThan",
"Prims.nat",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.op_Addition",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.eq2",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Math.Lemmas.distributivity_add_left",
"FStar.Math.Lemmas.lemma_mult_le_right",
"Prims.bool",
"Prims.op_Equality",
"Prims.l_or",
"Prims.l_and",
"Prims._assert",
"Spec.Matrix.index_lt"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2)) | false | false | Spec.Matrix.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_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2)) | [] | Spec.Matrix.index_neq | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
i: Lib.IntTypes.size_nat{i < n1} ->
j: Prims.nat{j < n2} ->
i': Prims.nat{i' < n1} ->
j': Prims.nat{j' < n2}
-> FStar.Pervasives.Lemma
(ensures
FStar.Pervasives.Native.Mktuple2 i' j' <> FStar.Pervasives.Native.Mktuple2 i j ==>
i' * n2 + j' <> i * n2 + j /\ i' * n2 + j' < n1 * n2) | {
"end_col": 7,
"end_line": 74,
"start_col": 2,
"start_line": 47
} |
Prims.Pure | val matrix_eq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Pure uint16
(requires True)
(ensures fun r ->
(a == b ==> v r == v (ones U16 SEC)) /\
(a =!= b ==> v r == 0)) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let matrix_eq #n1 #n2 a b =
seq_eq_mask a b (n1 * n2) | val matrix_eq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Pure uint16
(requires True)
(ensures fun r ->
(a == b ==> v r == v (ones U16 SEC)) /\
(a =!= b ==> v r == 0))
let matrix_eq #n1 #n2 a b = | false | null | false | seq_eq_mask a b (n1 * n2) | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.matrix",
"Lib.ByteSequence.seq_eq_mask",
"Lib.IntTypes.U16",
"Lib.IntTypes.uint16"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1)
let sum #n f = sum_ #n f n
#push-options "--fuel 1"
val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i)
let rec sum_extensionality n f g i =
if i = 0 then ()
else sum_extensionality n f g (i - 1)
val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul_inner #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. b.(l, k) in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. b.(j, k)
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. b.(l, k)) n2;
res
#pop-options
val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. b.(l, k)))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. b.(l, k1))) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner #n1 #n2 #n3 a b i k
) c
) c
val mget_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget_s #n1 #n2 a i j =
index_lt n2 n1 j i;
a.[j * n1 + i]
#push-options "--fuel 1"
val mul_inner_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_inner_s #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. mget_s b l k in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. mget_s b j k
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. mget_s b l k) n2;
res
#pop-options
val mul_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_s #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. mget_s b l k))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k1)) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner_s #n1 #n2 #n3 a b i k
) c
) c
val matrix_eq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Pure uint16
(requires True)
(ensures fun r ->
(a == b ==> v r == v (ones U16 SEC)) /\
(a =!= b ==> v r == 0)) | false | false | Spec.Matrix.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 matrix_eq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Pure uint16
(requires True)
(ensures fun r ->
(a == b ==> v r == v (ones U16 SEC)) /\
(a =!= b ==> v r == 0)) | [] | Spec.Matrix.matrix_eq | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Matrix.matrix n1 n2 -> b: Spec.Matrix.matrix n1 n2 -> Prims.Pure Lib.IntTypes.uint16 | {
"end_col": 27,
"end_line": 401,
"start_col": 2,
"start_line": 401
} |
Prims.Tot | val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq } | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a | val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a = | false | null | false | if logq < 16 then map (mod_pow2_felem logq) a else a | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.size_pos",
"Spec.Matrix.matrix",
"Prims.op_LessThan",
"Spec.Matrix.map",
"Spec.Matrix.mod_pow2_felem",
"Prims.bool",
"Prims.l_Forall",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.v",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Spec.Matrix.op_Array_Access",
"FStar.Pervasives.Native.Mktuple2",
"Prims.op_Modulus",
"Prims.pow2"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq } | false | false | Spec.Matrix.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 mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq } | [] | Spec.Matrix.mod_pow2 | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | logq: Lib.IntTypes.size_pos{logq <= 16} -> a: Spec.Matrix.matrix n1 n2
-> c:
Spec.Matrix.matrix n1 n2
{ forall (i: Lib.IntTypes.size_nat{i < n1 /\ i < n1})
(j: Lib.IntTypes.size_nat{j < n2 /\ j < n2}).
Lib.IntTypes.v c.(i, j) == Lib.IntTypes.v a.(i, j) % Prims.pow2 logq } | {
"end_col": 8,
"end_line": 208,
"start_col": 2,
"start_line": 206
} |
Prims.Tot | val matrix_from_lbytes_f:
n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> b:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1 * n2}
-> elem | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let matrix_from_lbytes_f n1 n2 b i =
uint_from_bytes_le (LSeq.sub b (2 * i) 2) | val matrix_from_lbytes_f:
n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> b:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1 * n2}
-> elem
let matrix_from_lbytes_f n1 n2 b i = | false | null | false | uint_from_bytes_le (LSeq.sub b (2 * i) 2) | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.ByteSequence.lbytes",
"Prims.op_LessThan",
"Lib.ByteSequence.uint_from_bytes_le",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.Sequence.sub",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Spec.Matrix.elem"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1)
let sum #n f = sum_ #n f n
#push-options "--fuel 1"
val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i)
let rec sum_extensionality n f g i =
if i = 0 then ()
else sum_extensionality n f g (i - 1)
val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul_inner #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. b.(l, k) in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. b.(j, k)
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. b.(l, k)) n2;
res
#pop-options
val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. b.(l, k)))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. b.(l, k1))) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner #n1 #n2 #n3 a b i k
) c
) c
val mget_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget_s #n1 #n2 a i j =
index_lt n2 n1 j i;
a.[j * n1 + i]
#push-options "--fuel 1"
val mul_inner_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_inner_s #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. mget_s b l k in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. mget_s b j k
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. mget_s b l k) n2;
res
#pop-options
val mul_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_s #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. mget_s b l k))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k1)) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner_s #n1 #n2 #n3 a b i k
) c
) c
val matrix_eq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Pure uint16
(requires True)
(ensures fun r ->
(a == b ==> v r == v (ones U16 SEC)) /\
(a =!= b ==> v r == 0))
let matrix_eq #n1 #n2 a b =
seq_eq_mask a b (n1 * n2)
val matrix_to_lbytes_f:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> i:size_nat{i < n1 * n2}
-> lbytes 2
let matrix_to_lbytes_f #n1 #n2 m i =
uint_to_bytes_le m.[i]
val matrix_to_lbytes:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> lbytes (2 * n1 * n2)
let matrix_to_lbytes #n1 #n2 m =
generate_blocks_simple 2 (n1 * n2) (n1 * n2) (matrix_to_lbytes_f m)
val matrix_from_lbytes_f:
n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> b:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1 * n2}
-> elem | false | false | Spec.Matrix.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 matrix_from_lbytes_f:
n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> b:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1 * n2}
-> elem | [] | Spec.Matrix.matrix_from_lbytes_f | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n1: Lib.IntTypes.size_nat ->
n2: Lib.IntTypes.size_nat{(2 * n1) * n2 <= Lib.IntTypes.max_size_t} ->
b: Lib.ByteSequence.lbytes ((2 * n1) * n2) ->
i: Lib.IntTypes.size_nat{i < n1 * n2}
-> Spec.Matrix.elem | {
"end_col": 43,
"end_line": 433,
"start_col": 2,
"start_line": 433
} |
Prims.Tot | val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_inner #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. b.(l, k) in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. b.(j, k)
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. b.(l, k)) n2;
res | val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul_inner #n1 #n2 #n3 a b i k = | false | null | false | let f l = a.(i, l) *. b.(l, k) in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res -> res +. a.(i, j) *. b.(j, k))
(u16 0)
in
sum_extensionality n2 f (fun l -> a.(i, l) *. b.(l, k)) n2;
res | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Prims.l_and",
"Spec.Matrix.matrix",
"Prims.op_LessThan",
"Prims.unit",
"Spec.Matrix.sum_extensionality",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Spec.Matrix.op_Array_Access",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.uint16",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Spec.Matrix.sum_",
"Lib.LoopCombinators.repeati_inductive",
"Prims.nat",
"Lib.IntTypes.op_Plus_Dot",
"Prims.op_Addition",
"Lib.IntTypes.u16",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.Matrix.sum"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1)
let sum #n f = sum_ #n f n
#push-options "--fuel 1"
val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i)
let rec sum_extensionality n f g i =
if i = 0 then ()
else sum_extensionality n f g (i - 1)
val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))} | false | false | Spec.Matrix.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))} | [] | Spec.Matrix.mul_inner | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Matrix.matrix n1 n2 ->
b: Spec.Matrix.matrix n2 n3 ->
i: Lib.IntTypes.size_nat{i < n1} ->
k: Lib.IntTypes.size_nat{k < n3}
-> res: Lib.IntTypes.uint16{res == Spec.Matrix.sum (fun l -> a.(i, l) *. b.(l, k))} | {
"end_col": 5,
"end_line": 304,
"start_col": 35,
"start_line": 295
} |
Prims.Tot | val matrix_from_lbytes:
n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> b:lbytes (2 * n1 * n2)
-> matrix n1 n2 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let matrix_from_lbytes n1 n2 b =
createi (n1 * n2) (matrix_from_lbytes_f n1 n2 b) | val matrix_from_lbytes:
n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> b:lbytes (2 * n1 * n2)
-> matrix n1 n2
let matrix_from_lbytes n1 n2 b = | false | null | false | createi (n1 * n2) (matrix_from_lbytes_f n1 n2 b) | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.ByteSequence.lbytes",
"Lib.Sequence.createi",
"Spec.Matrix.elem",
"Spec.Matrix.matrix_from_lbytes_f",
"Spec.Matrix.matrix"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1)
let sum #n f = sum_ #n f n
#push-options "--fuel 1"
val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i)
let rec sum_extensionality n f g i =
if i = 0 then ()
else sum_extensionality n f g (i - 1)
val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul_inner #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. b.(l, k) in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. b.(j, k)
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. b.(l, k)) n2;
res
#pop-options
val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. b.(l, k)))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. b.(l, k1))) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner #n1 #n2 #n3 a b i k
) c
) c
val mget_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget_s #n1 #n2 a i j =
index_lt n2 n1 j i;
a.[j * n1 + i]
#push-options "--fuel 1"
val mul_inner_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_inner_s #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. mget_s b l k in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. mget_s b j k
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. mget_s b l k) n2;
res
#pop-options
val mul_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_s #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. mget_s b l k))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k1)) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner_s #n1 #n2 #n3 a b i k
) c
) c
val matrix_eq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Pure uint16
(requires True)
(ensures fun r ->
(a == b ==> v r == v (ones U16 SEC)) /\
(a =!= b ==> v r == 0))
let matrix_eq #n1 #n2 a b =
seq_eq_mask a b (n1 * n2)
val matrix_to_lbytes_f:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> i:size_nat{i < n1 * n2}
-> lbytes 2
let matrix_to_lbytes_f #n1 #n2 m i =
uint_to_bytes_le m.[i]
val matrix_to_lbytes:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> lbytes (2 * n1 * n2)
let matrix_to_lbytes #n1 #n2 m =
generate_blocks_simple 2 (n1 * n2) (n1 * n2) (matrix_to_lbytes_f m)
val matrix_from_lbytes_f:
n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> b:lbytes (2 * n1 * n2)
-> i:size_nat{i < n1 * n2}
-> elem
let matrix_from_lbytes_f n1 n2 b i =
uint_from_bytes_le (LSeq.sub b (2 * i) 2)
val matrix_from_lbytes:
n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> b:lbytes (2 * n1 * n2)
-> matrix n1 n2 | false | false | Spec.Matrix.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 matrix_from_lbytes:
n1:size_nat
-> n2:size_nat{2 * n1 * n2 <= max_size_t}
-> b:lbytes (2 * n1 * n2)
-> matrix n1 n2 | [] | Spec.Matrix.matrix_from_lbytes | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n1: Lib.IntTypes.size_nat ->
n2: Lib.IntTypes.size_nat{(2 * n1) * n2 <= Lib.IntTypes.max_size_t} ->
b: Lib.ByteSequence.lbytes ((2 * n1) * n2)
-> Spec.Matrix.matrix n1 n2 | {
"end_col": 50,
"end_line": 443,
"start_col": 2,
"start_line": 443
} |
Prims.Tot | val mul_inner_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_inner_s #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. mget_s b l k in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. mget_s b j k
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. mget_s b l k) n2;
res | val mul_inner_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_inner_s #n1 #n2 #n3 a b i k = | false | null | false | let f l = a.(i, l) *. mget_s b l k in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res -> res +. a.(i, j) *. mget_s b j k)
(u16 0)
in
sum_extensionality n2 f (fun l -> a.(i, l) *. mget_s b l k) n2;
res | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Prims.l_and",
"Spec.Matrix.matrix",
"Prims.op_LessThan",
"Prims.unit",
"Spec.Matrix.sum_extensionality",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Spec.Matrix.op_Array_Access",
"FStar.Pervasives.Native.Mktuple2",
"Spec.Matrix.mget_s",
"Lib.IntTypes.uint16",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Spec.Matrix.sum_",
"Lib.LoopCombinators.repeati_inductive",
"Prims.nat",
"Lib.IntTypes.op_Plus_Dot",
"Prims.op_Addition",
"Lib.IntTypes.u16",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.Matrix.sum"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1)
let sum #n f = sum_ #n f n
#push-options "--fuel 1"
val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i)
let rec sum_extensionality n f g i =
if i = 0 then ()
else sum_extensionality n f g (i - 1)
val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul_inner #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. b.(l, k) in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. b.(j, k)
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. b.(l, k)) n2;
res
#pop-options
val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. b.(l, k)))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. b.(l, k1))) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner #n1 #n2 #n3 a b i k
) c
) c
val mget_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget_s #n1 #n2 a i j =
index_lt n2 n1 j i;
a.[j * n1 + i]
#push-options "--fuel 1"
val mul_inner_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)} | false | false | Spec.Matrix.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_inner_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)} | [] | Spec.Matrix.mul_inner_s | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Matrix.matrix n1 n2 ->
b: Spec.Matrix.matrix n2 n3 ->
i: Lib.IntTypes.size_nat{i < n1} ->
k: Lib.IntTypes.size_nat{k < n3}
-> res:
Lib.IntTypes.uint16{res == Spec.Matrix.sum (fun l -> a.(i, l) *. Spec.Matrix.mget_s b l k)} | {
"end_col": 5,
"end_line": 363,
"start_col": 37,
"start_line": 354
} |
Prims.Tot | val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) } | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_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 #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c | val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a = | false | null | false | let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0: size_nat{i0 < i}) (j: size_nat{j < n2}). c.(i0, j) == f a.(i0, j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0: size_nat{i0 < i}) (j: size_nat{j < n2}). c0.(i0, j) == c.(i0, j)) /\
(forall (j0: size_nat{j0 < j}). c0.(i, j0) == f a.(i, j0)))
(fun j c' -> c'.(i, j) <- f a.(i, j))
c)
c | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.elem",
"Spec.Matrix.matrix",
"Lib.LoopCombinators.repeati_inductive",
"Prims.nat",
"Prims.l_Forall",
"Prims.op_LessThan",
"Prims.eq2",
"Spec.Matrix.op_Array_Access",
"FStar.Pervasives.Native.Mktuple2",
"Prims.l_and",
"Spec.Matrix.op_Array_Assignment",
"Prims.op_Addition",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Spec.Matrix.create"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) } | false | false | Spec.Matrix.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 map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) } | [] | Spec.Matrix.map | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: (_: Spec.Matrix.elem -> Spec.Matrix.elem) -> a: Spec.Matrix.matrix n1 n2
-> c:
Spec.Matrix.matrix n1 n2
{ forall (i: Lib.IntTypes.size_nat{i < n1 /\ i < n1})
(j: Lib.IntTypes.size_nat{j < n2 /\ j < n2}).
c.(i, j) == f a.(i, j) } | {
"end_col": 5,
"end_line": 183,
"start_col": 21,
"start_line": 172
} |
Prims.Tot | val matrix_to_lbytes_f:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> i:size_nat{i < n1 * n2}
-> lbytes 2 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let matrix_to_lbytes_f #n1 #n2 m i =
uint_to_bytes_le m.[i] | val matrix_to_lbytes_f:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> i:size_nat{i < n1 * n2}
-> lbytes 2
let matrix_to_lbytes_f #n1 #n2 m i = | false | null | false | uint_to_bytes_le m.[ i ] | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.matrix",
"Prims.op_LessThan",
"Lib.ByteSequence.uint_to_bytes_le",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.Sequence.op_String_Access",
"Spec.Matrix.elem",
"Lib.ByteSequence.lbytes"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1)
let sum #n f = sum_ #n f n
#push-options "--fuel 1"
val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i)
let rec sum_extensionality n f g i =
if i = 0 then ()
else sum_extensionality n f g (i - 1)
val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul_inner #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. b.(l, k) in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. b.(j, k)
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. b.(l, k)) n2;
res
#pop-options
val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. b.(l, k)))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. b.(l, k1))) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner #n1 #n2 #n3 a b i k
) c
) c
val mget_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget_s #n1 #n2 a i j =
index_lt n2 n1 j i;
a.[j * n1 + i]
#push-options "--fuel 1"
val mul_inner_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_inner_s #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. mget_s b l k in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. mget_s b j k
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. mget_s b l k) n2;
res
#pop-options
val mul_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_s #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. mget_s b l k))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k1)) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner_s #n1 #n2 #n3 a b i k
) c
) c
val matrix_eq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Pure uint16
(requires True)
(ensures fun r ->
(a == b ==> v r == v (ones U16 SEC)) /\
(a =!= b ==> v r == 0))
let matrix_eq #n1 #n2 a b =
seq_eq_mask a b (n1 * n2)
val matrix_to_lbytes_f:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> i:size_nat{i < n1 * n2}
-> lbytes 2 | false | false | Spec.Matrix.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 matrix_to_lbytes_f:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> i:size_nat{i < n1 * n2}
-> lbytes 2 | [] | Spec.Matrix.matrix_to_lbytes_f | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Spec.Matrix.matrix n1 n2 -> i: Lib.IntTypes.size_nat{i < n1 * n2} -> Lib.ByteSequence.lbytes 2 | {
"end_col": 24,
"end_line": 412,
"start_col": 2,
"start_line": 412
} |
Prims.Tot | val matrix_to_lbytes:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> lbytes (2 * n1 * n2) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let matrix_to_lbytes #n1 #n2 m =
generate_blocks_simple 2 (n1 * n2) (n1 * n2) (matrix_to_lbytes_f m) | val matrix_to_lbytes:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> lbytes (2 * n1 * n2)
let matrix_to_lbytes #n1 #n2 m = | false | null | false | generate_blocks_simple 2 (n1 * n2) (n1 * n2) (matrix_to_lbytes_f m) | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.matrix",
"Lib.Sequence.generate_blocks_simple",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Matrix.matrix_to_lbytes_f",
"Lib.ByteSequence.lbytes"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1)
let sum #n f = sum_ #n f n
#push-options "--fuel 1"
val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i)
let rec sum_extensionality n f g i =
if i = 0 then ()
else sum_extensionality n f g (i - 1)
val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul_inner #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. b.(l, k) in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. b.(j, k)
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. b.(l, k)) n2;
res
#pop-options
val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. b.(l, k)))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. b.(l, k1))) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner #n1 #n2 #n3 a b i k
) c
) c
val mget_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget_s #n1 #n2 a i j =
index_lt n2 n1 j i;
a.[j * n1 + i]
#push-options "--fuel 1"
val mul_inner_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_inner_s #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. mget_s b l k in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. mget_s b j k
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. mget_s b l k) n2;
res
#pop-options
val mul_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_s #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. mget_s b l k))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k1)) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner_s #n1 #n2 #n3 a b i k
) c
) c
val matrix_eq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Pure uint16
(requires True)
(ensures fun r ->
(a == b ==> v r == v (ones U16 SEC)) /\
(a =!= b ==> v r == 0))
let matrix_eq #n1 #n2 a b =
seq_eq_mask a b (n1 * n2)
val matrix_to_lbytes_f:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> i:size_nat{i < n1 * n2}
-> lbytes 2
let matrix_to_lbytes_f #n1 #n2 m i =
uint_to_bytes_le m.[i]
val matrix_to_lbytes:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> lbytes (2 * n1 * n2) | false | false | Spec.Matrix.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 matrix_to_lbytes:
#n1:size_nat
-> #n2:size_nat{2 * n1 * n2 <= max_size_t}
-> m:matrix n1 n2
-> lbytes (2 * n1 * n2) | [] | Spec.Matrix.matrix_to_lbytes | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Spec.Matrix.matrix n1 n2 -> Lib.ByteSequence.lbytes ((2 * n1) * n2) | {
"end_col": 69,
"end_line": 422,
"start_col": 2,
"start_line": 422
} |
Prims.Tot | val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) } | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c | val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b = | false | null | false | let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c ->
forall (i0: size_nat{i0 < i}) (j: size_nat{j < n2}). c.(i0, j) == f a.(i0, j) b.(i0, j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0: size_nat{i0 < i}) (j: size_nat{j < n2}). c0.(i0, j) == c.(i0, j)) /\
(forall (j0: size_nat{j0 < j}). c0.(i, j0) == f a.(i, j0) b.(i, j0)))
(fun j c' -> c'.(i, j) <- f a.(i, j) b.(i, j))
c)
c | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.elem",
"Spec.Matrix.matrix",
"Lib.LoopCombinators.repeati_inductive",
"Prims.nat",
"Prims.l_Forall",
"Prims.op_LessThan",
"Prims.eq2",
"Spec.Matrix.op_Array_Access",
"FStar.Pervasives.Native.Mktuple2",
"Prims.l_and",
"Spec.Matrix.op_Array_Assignment",
"Prims.op_Addition",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Spec.Matrix.create"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) } | false | false | Spec.Matrix.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 map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) } | [] | Spec.Matrix.map2 | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f: (_: Spec.Matrix.elem -> _: Spec.Matrix.elem -> Spec.Matrix.elem) ->
a: Spec.Matrix.matrix n1 n2 ->
b: Spec.Matrix.matrix n1 n2
-> c:
Spec.Matrix.matrix n1 n2
{ forall (i: Lib.IntTypes.size_nat{i < n1 /\ i < n1 /\ i < n1})
(j: Lib.IntTypes.size_nat{j < n2 /\ j < n2 /\ j < n2}).
c.(i, j) == f a.(i, j) b.(i, j) } | {
"end_col": 5,
"end_line": 230,
"start_col": 24,
"start_line": 219
} |
FStar.Pervasives.Lemma | val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b) | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b | val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b = | false | null | true | let aux (k: size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[ i * n2 + j ] /\ b.(i, j) == b.[ i * n2 + j ]);
assert (a.[ k ] == b.[ k ])
in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Spec.Matrix.matrix",
"Lib.Sequence.eq_elim",
"Spec.Matrix.elem",
"Prims.unit",
"Lib.Sequence.eq_intro",
"FStar.Classical.forall_intro",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Prims.nat",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_Multiply",
"Prims.l_True",
"Prims.squash",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims._assert",
"Lib.Sequence.op_String_Access",
"Prims.l_and",
"Spec.Matrix.op_Array_Access",
"FStar.Pervasives.Native.Mktuple2",
"Prims.op_Addition",
"Spec.Matrix.index_lt",
"Lib.Sequence.div_mul_lt",
"Prims.int",
"Prims.op_Modulus",
"Prims.op_Division"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b) | false | false | Spec.Matrix.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 extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b) | [] | Spec.Matrix.extensionality | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Matrix.matrix n1 n2 -> b: Spec.Matrix.matrix n1 n2
-> FStar.Pervasives.Lemma
(requires
forall (i: Lib.IntTypes.size_nat{i < n1 /\ i < n1})
(j: Lib.IntTypes.size_nat{j < n2 /\ j < n2}).
a.(i, j) == b.(i, j)) (ensures a == b) | {
"end_col": 13,
"end_line": 149,
"start_col": 32,
"start_line": 137
} |
Prims.Tot | val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. b.(l, k)))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. b.(l, k1))) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner #n1 #n2 #n3 a b i k
) c
) c | val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul #n1 #n2 #n3 a b = | false | null | false | let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c ->
forall (i1: size_nat{i1 < i}) (k: size_nat{k < n3}).
c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. b.(l, k)))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 ->
(forall (k1: size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. b.(l, k1))) /\
(forall (i1: size_nat{i1 < n1 /\ i <> i1}) (k: size_nat{k < n3}).
c0.(i1, k) == c.(i1, k)))
(fun k c0 -> c0.(i, k) <- mul_inner #n1 #n2 #n3 a b i k)
c)
c | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Prims.l_and",
"Spec.Matrix.matrix",
"Lib.LoopCombinators.repeati_inductive",
"Prims.nat",
"Prims.l_Forall",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.IntTypes.uint16",
"Spec.Matrix.op_Array_Access",
"FStar.Pervasives.Native.Mktuple2",
"Spec.Matrix.sum",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Prims.op_disEquality",
"Prims.l_or",
"Spec.Matrix.elem",
"Spec.Matrix.op_Array_Assignment",
"Spec.Matrix.mul_inner",
"Prims.op_Addition",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Prims.op_Multiply",
"Spec.Matrix.create"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1)
let sum #n f = sum_ #n f n
#push-options "--fuel 1"
val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i)
let rec sum_extensionality n f g i =
if i = 0 then ()
else sum_extensionality n f g (i - 1)
val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul_inner #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. b.(l, k) in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. b.(j, k)
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. b.(l, k)) n2;
res
#pop-options
val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))} | false | false | Spec.Matrix.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))} | [] | Spec.Matrix.mul | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Matrix.matrix n1 n2 -> b: Spec.Matrix.matrix n2 n3
-> c:
Spec.Matrix.matrix n1 n3
{ forall (i: Lib.IntTypes.size_nat{i < n1}) (k: j: Lib.IntTypes.size_nat{j < n3}).
c.(i, k) == Spec.Matrix.sum (fun l -> a.(i, l) *. b.(l, k)) } | {
"end_col": 7,
"end_line": 327,
"start_col": 25,
"start_line": 316
} |
Prims.Tot | val mul_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"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": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_s #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. mget_s b l k))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k1)) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner_s #n1 #n2 #n3 a b i k
) c
) c | val mul_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_s #n1 #n2 #n3 a b = | false | null | false | let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c ->
forall (i1: size_nat{i1 < i}) (k: size_nat{k < n3}).
c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. mget_s b l k))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 ->
(forall (k1: size_nat{k1 < k}).
c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k1)) /\
(forall (i1: size_nat{i1 < n1 /\ i <> i1}) (k: size_nat{k < n3}).
c0.(i1, k) == c.(i1, k)))
(fun k c0 -> c0.(i, k) <- mul_inner_s #n1 #n2 #n3 a b i k)
c)
c | {
"checked_file": "Spec.Matrix.fst.checked",
"dependencies": [
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.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": "Spec.Matrix.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Prims.l_and",
"Spec.Matrix.matrix",
"Lib.LoopCombinators.repeati_inductive",
"Prims.nat",
"Prims.l_Forall",
"Prims.op_LessThan",
"Prims.eq2",
"Lib.IntTypes.uint16",
"Spec.Matrix.op_Array_Access",
"FStar.Pervasives.Native.Mktuple2",
"Spec.Matrix.sum",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Spec.Matrix.mget_s",
"Prims.op_disEquality",
"Prims.l_or",
"Spec.Matrix.elem",
"Spec.Matrix.op_Array_Assignment",
"Spec.Matrix.mul_inner_s",
"Prims.op_Addition",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Prims.op_Multiply",
"Spec.Matrix.create"
] | [] | module Spec.Matrix
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
module LSeq = Lib.Sequence
module Lemmas = Spec.Frodo.Lemmas
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Auxiliary lemmas
val index_lt:
n1:size_nat
-> n2:size_nat
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> Lemma (i * n2 + j < n1 * n2)
let index_lt n1 n2 i j =
calc (<=) {
i * n2 + j;
(<=) { Math.Lemmas.lemma_mult_le_right n2 i (n1 - 1) }
(n1 - 1) * n2 + j;
(==) { Math.Lemmas.distributivity_sub_left n1 1 n2 }
n1 * n2 - n2 + j;
(<=) { }
n1 * n2 - 1;
}
private
val index_neq:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> i:size_nat{i < n1}
-> j:nat{j < n2}
-> i':nat{i' < n1}
-> j':nat{j' < n2}
-> Lemma (((i', j') <> (i, j) ==> (i' * n2 + j' <> i * n2 + j) /\ i' * n2 + j' < n1 * n2))
let index_neq #n1 #n2 i j i' j' =
index_lt n1 n2 i' j';
assert (i' * n2 + j' < n1 * n2);
if i' < i then
calc (<) {
i' * n2 + j';
(<) { }
i' * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i' 1 n2 }
(i' + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i' + 1) i }
i * n2;
(<=) { }
i * n2 + j;
}
else if i = i' then ()
else
calc (<) {
i * n2 + j;
(<) { }
i * n2 + n2;
(==) { Math.Lemmas.distributivity_add_left i 1 n2 }
(i + 1) * n2;
(<=) { Math.Lemmas.lemma_mult_le_right n2 (i + 1) i' }
i' * n2;
(<=) { }
i' * n2 + j';
}
/// Matrices as flat sequences
unfold
let elem = uint16
unfold
let matrix (n1:size_nat) (n2:size_nat{n1 * n2 <= max_size_t}) = LSeq.lseq elem (n1 * n2)
val create: n1:size_nat -> n2:size_nat{n1 * n2 <= max_size_t} -> matrix n1 n2
let create n1 n2 = LSeq.create (n1 * n2) (u16 0)
val mget:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget #n1 #n2 a i j =
index_lt n1 n2 i j;
a.[i * n2 + j]
unfold
let op_Array_Access #n1 #n2 (m:matrix n1 n2) (i,j) = mget m i j
val mset:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> v:elem
-> Pure (matrix n1 n2)
(requires True)
(ensures fun r ->
r.(i,j) == v /\ (forall i' j'. (i', j') <> (i, j) ==> r.(i', j') == a.(i',j')))
let mset #n1 #n2 a i j v =
Classical.forall_intro_2 (index_neq #n1 #n2 i j);
index_lt n1 n2 i j;
a.[i * n2 + j] <- v
unfold
let op_Array_Assignment #n1 #n2 (m:matrix n1 n2) (i,j) x = mset m i j x
val extensionality:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> Lemma
(requires forall i j. a.(i,j) == b.(i,j))
(ensures a == b)
let extensionality #n1 #n2 a b =
let aux (k:size_nat{k < n1 * n2}) : Lemma (index a k == index b k) =
let i = k / n2 in
let j = k % n2 in
div_mul_lt n2 k n1;
assert (i < n1 /\ j < n2);
index_lt n1 n2 i j;
assert (a.(i, j) == a.[i * n2 + j] /\ b.(i, j) == b.[i * n2 + j]);
assert (a.[k] == b.[k]) in
Classical.forall_intro aux;
eq_intro a b;
eq_elim a b
(*
/// Example (of course it doesn't work with Lib.IntTypes)
/// [ 0 2 ]
/// [ 1 3 ]
let m:matrix 2 2 =
assert_norm (List.length [0us; 2us; 1us; 3us] == 4);
Seq.seq_of_list [0us; 2us; 1us; 3us]
let _ = assert_norm (m.(0,0) == 0us /\ m.(1,0) == 1us /\ m.(0,1) == 2us /\ m.(1,1) == 3us)
let _ = assert_norm (let m' = m.(0,0) <- 4us in m'.(0,0) == 4us)
*)
val map:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem)
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) }
let map #n1 #n2 f a =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j))
c)
c
val mod_pow2_felem: logq:size_pos{logq < 16} -> a:elem
-> Pure elem
(requires true)
(ensures fun r -> v r == v a % pow2 logq)
let mod_pow2_felem logq a =
Math.Lemmas.pow2_lt_compat 16 logq;
mod_mask_lemma #U16 a (size logq);
assert (v (mod_mask #U16 #SEC (size logq)) == v ((u16 1 <<. size logq) -. u16 1));
a &. ((u16 1 <<. size logq) -. u16 1)
val mod_pow2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> logq:size_pos{logq <= 16}
-> a:matrix n1 n2
-> c:matrix n1 n2{ forall i j. v c.(i,j) == v a.(i,j) % pow2 logq }
let mod_pow2 #n1 #n2 logq a =
if logq < 16 then
map (mod_pow2_felem logq) a
else a
val map2:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> f:(elem -> elem -> elem)
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == f a.(i,j) b.(i,j) }
let map2 #n1 #n2 f a b =
let c = create n1 n2 in
Loops.repeati_inductive n1
(fun i c -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c.(i0,j) == f a.(i0,j) b.(i0,j))
(fun i c ->
Loops.repeati_inductive n2
(fun j c0 ->
(forall (i0:size_nat{i0 < i}) (j:size_nat{j < n2}). c0.(i0,j) == c.(i0,j)) /\
(forall (j0:size_nat{j0 < j}). c0.(i,j0) == f a.(i,j0) b.(i,j0)))
(fun j c' -> c'.(i,j) <- f a.(i,j) b.(i,j))
c)
c
val add:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) +. b.(i,j) }
let add #n1 #n2 a b =
map2 add_mod a b
val sub:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n1 n2
-> c:matrix n1 n2{ forall i j. c.(i,j) == a.(i,j) -. b.(i,j) }
let sub #n1 #n2 a b =
map2 sub_mod a b
val sum_:
#n:size_nat
-> f:(j:size_nat{j < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> GTot uint16
(decreases i)
let rec sum_ #n f i =
if i = 0 then u16 0
else sum_ #n f (i - 1) +. f (i - 1)
let sum #n f = sum_ #n f n
#push-options "--fuel 1"
val sum_extensionality:
n:size_nat
-> f:(i:size_nat{i < n} -> GTot uint16)
-> g:(i:size_nat{i < n} -> GTot uint16)
-> i:size_nat{i <= n}
-> Lemma
(requires forall (i:size_nat{i < n}). f i == g i)
(ensures sum_ #n f i == sum_ #n g i)
(decreases i)
let rec sum_extensionality n f g i =
if i = 0 then ()
else sum_extensionality n f g (i - 1)
val mul_inner:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul_inner #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. b.(l, k) in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. b.(j, k)
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. b.(l, k)) n2;
res
#pop-options
val mul:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. b.(l, k))}
let mul #n1 #n2 #n3 a b =
let c = create n1 n3 in
Loops.repeati_inductive n1
(fun i c -> forall (i1:size_nat{i1 < i}) (k:size_nat{k < n3}). c.(i1, k) == sum #n2 (fun l -> a.(i1, l) *. b.(l, k)))
(fun i c ->
Loops.repeati_inductive n3
(fun k c0 -> (forall (k1:size_nat{k1 < k}). c0.(i, k1) == sum #n2 (fun l -> a.(i, l) *. b.(l, k1))) /\
(forall (i1:size_nat{i1 < n1 /\ i <> i1}) (k:size_nat{k < n3}). c0.(i1, k) == c.(i1, k)))
(fun k c0 ->
c0.(i, k) <- mul_inner #n1 #n2 #n3 a b i k
) c
) c
val mget_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> a:matrix n1 n2
-> i:size_nat{i < n1}
-> j:size_nat{j < n2}
-> elem
let mget_s #n1 #n2 a i j =
index_lt n2 n1 j i;
a.[j * n1 + i]
#push-options "--fuel 1"
val mul_inner_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> i:size_nat{i < n1}
-> k:size_nat{k < n3}
-> res:uint16{res == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)}
let mul_inner_s #n1 #n2 #n3 a b i k =
let f l = a.(i, l) *. mget_s b l k in
let res =
Loops.repeati_inductive n2
(fun j res -> res == sum_ #n2 f j)
(fun j res ->
res +. a.(i, j) *. mget_s b j k
) (u16 0) in
sum_extensionality n2 f (fun l -> a.(i, l) *. mget_s b l k) n2;
res
#pop-options
val mul_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)} | false | false | Spec.Matrix.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_s:
#n1:size_nat
-> #n2:size_nat{n1 * n2 <= max_size_t}
-> #n3:size_nat{n1 * n3 <= max_size_t /\ n2 * n3 <= max_size_t}
-> a:matrix n1 n2
-> b:matrix n2 n3
-> c:matrix n1 n3{ forall i k. c.(i, k) == sum #n2 (fun l -> a.(i, l) *. mget_s b l k)} | [] | Spec.Matrix.mul_s | {
"file_name": "specs/frodo/Spec.Matrix.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Matrix.matrix n1 n2 -> b: Spec.Matrix.matrix n2 n3
-> c:
Spec.Matrix.matrix n1 n3
{ forall (i: Lib.IntTypes.size_nat{i < n1}) (k: j: Lib.IntTypes.size_nat{j < n3}).
c.(i, k) == Spec.Matrix.sum (fun l -> a.(i, l) *. Spec.Matrix.mget_s b l k) } | {
"end_col": 7,
"end_line": 386,
"start_col": 27,
"start_line": 375
} |
Prims.Tot | val gen_elim_nondep_p (ty: list (Type u#a))
: Tot
(
curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) ->
curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop)
-> Tot vprop) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)) | val gen_elim_nondep_p (ty: list (Type u#a))
: Tot
(
curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) ->
curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop)
-> Tot vprop)
let rec gen_elim_nondep_p (ty: list (Type u#a))
: Tot
(
curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) ->
curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop)
-> Tot vprop) = | false | null | false | match
ty
as ty'
returns
curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) ->
curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop)
-> Tot vprop
with
| [] -> fun q post -> (q (U.raise_val ())) `star` (pure (post (U.raise_val ())))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Prims.list",
"Steel.ST.GenElim1.Base.curried_function_type",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Prims.Nil",
"Steel.Effect.Common.star",
"FStar.Universe.raise_val",
"Steel.ST.Util.pure",
"Prims.Cons",
"Steel.ST.Util.exists_",
"Steel.ST.GenElim1.gen_elim_nondep_p"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x)) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gen_elim_nondep_p (ty: list (Type u#a))
: Tot
(
curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) ->
curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop)
-> Tot vprop) | [
"recursion"
] | Steel.ST.GenElim1.gen_elim_nondep_p | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
ty: Prims.list Type ->
_:
Steel.ST.GenElim1.Base.curried_function_type ty
(_: FStar.Universe.raise_t Prims.unit -> Steel.Effect.Common.vprop) ->
_:
Steel.ST.GenElim1.Base.curried_function_type ty
(_: FStar.Universe.raise_t Prims.unit -> Prims.prop)
-> Steel.Effect.Common.vprop | {
"end_col": 83,
"end_line": 433,
"start_col": 2,
"start_line": 431
} |
Prims.GTot | val compute_gen_unit_elim_f (i: gen_unit_elim_i) : GTot (gen_unit_elim_t i) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2) | val compute_gen_unit_elim_f (i: gen_unit_elim_i) : GTot (gen_unit_elim_t i)
let rec compute_gen_unit_elim_f (i: gen_unit_elim_i) : GTot (gen_unit_elim_t i) = | false | null | false | match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 ->
compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.ST.GenElim1.gen_unit_elim_t",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.compute_gen_unit_elim_f_id",
"Prims.prop",
"Steel.ST.GenElim1.compute_gen_unit_elim_f_pure",
"Steel.ST.GenElim1.compute_gen_unit_elim_f_star",
"Steel.ST.GenElim1.compute_gen_unit_elim_f"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_unit_elim_f (i: gen_unit_elim_i) : GTot (gen_unit_elim_t i) | [
"recursion"
] | Steel.ST.GenElim1.compute_gen_unit_elim_f | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i: Steel.ST.GenElim1.Base.gen_unit_elim_i -> Prims.GTot (Steel.ST.GenElim1.gen_unit_elim_t i) | {
"end_col": 113,
"end_line": 47,
"start_col": 2,
"start_line": 44
} |
Prims.GTot | val compute_gen_elim_tele_correct (x: gen_elim_i) : GTot (ge_to_tele_t x) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x)) | val compute_gen_elim_tele_correct (x: gen_elim_i) : GTot (ge_to_tele_t x)
let rec compute_gen_elim_tele_correct (x: gen_elim_i) : GTot (ge_to_tele_t x) = | false | null | false | match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r ->
compute_gen_elim_tele_correct_star l
(compute_gen_elim_tele_correct l)
r
(compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body ->
compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body ->
compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x)) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.ge_to_tele_t",
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct_unit",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct_star_l",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct_star_r",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct_star",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists_no_abs0",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists_unit0",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists0",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists_no_abs1",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists_unit1",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists1"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_tele_correct (x: gen_elim_i) : GTot (ge_to_tele_t x) | [
"recursion"
] | Steel.ST.GenElim1.compute_gen_elim_tele_correct | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Steel.ST.GenElim1.Base.gen_elim_i -> Prims.GTot (Steel.ST.GenElim1.ge_to_tele_t x) | {
"end_col": 121,
"end_line": 428,
"start_col": 2,
"start_line": 418
} |
Prims.Tot | val tele_p (x: gen_elim_tele) : Tot vprop | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x)) | val tele_p (x: gen_elim_tele) : Tot vprop
let rec tele_p (x: gen_elim_tele) : Tot vprop = | false | null | false | match x with
| TRet v p -> v `star` (pure p)
| TExists ty body -> exists_ (fun x -> tele_p (body x)) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_tele",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.Effect.Common.star",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.ST.GenElim1.tele_p"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x)) | false | true | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tele_p (x: gen_elim_tele) : Tot vprop | [
"recursion"
] | Steel.ST.GenElim1.tele_p | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: Steel.ST.GenElim1.Base.gen_elim_tele -> Steel.Effect.Common.vprop | {
"end_col": 57,
"end_line": 197,
"start_col": 2,
"start_line": 195
} |
Prims.Pure | val coerce_with_smt (#tfrom #tto: Type) (x: tfrom)
: Pure tto (requires ((tfrom == tto))) (ensures (fun _ -> True)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 coerce_with_smt (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires ( (tfrom == tto))) (ensures (fun _ -> True)) = x | val coerce_with_smt (#tfrom #tto: Type) (x: tfrom)
: Pure tto (requires ((tfrom == tto))) (ensures (fun _ -> True))
let coerce_with_smt (#tfrom #tto: Type) (x: tfrom)
: Pure tto (requires ((tfrom == tto))) (ensures (fun _ -> True)) = | false | null | false | x | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [] | [
"Prims.eq2",
"Prims.l_True"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ())))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let res = Mktuple13 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> exists_ (fun x14 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ())))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let x14 = elim_exists' () in
let res = Mktuple14 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type) (tq: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq))
= fun q post intro _ ->
// default case: no exists is opened
let res : compute_gen_elim_nondep_a' (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq) = (U.raise_val ()) in
rewrite_with_trefl (compute_gen_elim_p i0) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct'
(i0: gen_elim_i)
(ty: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 ty)
= match ty returns compute_gen_elim_nondep_correct_t i0 ty with
| [] -> compute_gen_elim_nondep_correct0 i0
| [t1] -> compute_gen_elim_nondep_correct1 i0 t1
| [t1; t2] -> compute_gen_elim_nondep_correct2 i0 t1 t2
| [t1; t2; t3] -> compute_gen_elim_nondep_correct3 i0 t1 t2 t3
| [t1; t2; t3; t4] -> compute_gen_elim_nondep_correct4 i0 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> compute_gen_elim_nondep_correct5 i0 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> compute_gen_elim_nondep_correct6 i0 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> compute_gen_elim_nondep_correct7 i0 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> compute_gen_elim_nondep_correct8 i0 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> compute_gen_elim_nondep_correct9 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> compute_gen_elim_nondep_correct10 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> compute_gen_elim_nondep_correct11 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> compute_gen_elim_nondep_correct12 i0 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] -> compute_gen_elim_nondep_correct13 i0 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] -> compute_gen_elim_nondep_correct14 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq -> compute_gen_elim_nondep_correct_default i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 tq
let compute_gen_elim_nondep_correct_0
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
= match i returns
(sq: squash (check_gen_elim_nondep_sem i0 i)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a i0 i)
(compute_gen_elim_nondep_q0 i0 i)
(compute_gen_elim_nondep_post0 i0 i)
)
with
| GEDep -> fun _ -> compute_gen_elim_f i0
| GENonDep ty q post -> fun _ ->
let intro : vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post) = fun _ ->
compute_gen_elim_tele_correct i0 _;
rewrite (tele_p _) (tele_p (gen_elim_nondep_sem ty q post));
gen_elim_nondep_sem_correct ty q post;
rewrite_equiv (tele_p _) (gen_elim_nondep_p _ _ _)
in
compute_gen_elim_nondep_correct' i0 ty q post intro
let compute_gen_elim_nondep_correct
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(sq: squash (check_gen_elim_nondep_sem i0 i))
: Tot (gen_elim_f
(compute_gen_elim_p i0)
(Ghost.erased (compute_gen_elim_nondep_a i0 i))
(compute_gen_elim_nondep_q i0 i)
(compute_gen_elim_nondep_post i0 i)
)
= fun _ ->
let res0 = compute_gen_elim_nondep_correct_0 i0 i sq _ in
let res = Ghost.hide res0 in
rewrite (compute_gen_elim_nondep_q0 i0 i res0) (compute_gen_elim_nondep_q i0 i res);
res | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val coerce_with_smt (#tfrom #tto: Type) (x: tfrom)
: Pure tto (requires ((tfrom == tto))) (ensures (fun _ -> True)) | [] | Steel.ST.GenElim1.coerce_with_smt | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: tfrom -> Prims.Pure tto | {
"end_col": 120,
"end_line": 829,
"start_col": 119,
"start_line": 829
} |
Prims.GTot | val compute_gen_elim_f_unit (i: gen_unit_elim_i) : GTot (gen_elim_t (GEUnit i)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i | val compute_gen_elim_f_unit (i: gen_unit_elim_i) : GTot (gen_elim_t (GEUnit i))
let compute_gen_elim_f_unit (i: gen_unit_elim_i) : GTot (gen_elim_t (GEUnit i)) = | false | null | false | compute_gen_unit_elim_f i | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.ST.GenElim1.compute_gen_unit_elim_f",
"Steel.ST.GenElim1.gen_elim_t",
"Steel.ST.GenElim1.Base.GEUnit"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_f_unit (i: gen_unit_elim_i) : GTot (gen_elim_t (GEUnit i)) | [] | Steel.ST.GenElim1.compute_gen_elim_f_unit | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i: Steel.ST.GenElim1.Base.gen_unit_elim_i
-> Prims.GTot (Steel.ST.GenElim1.gen_elim_t (Steel.ST.GenElim1.Base.GEUnit i)) | {
"end_col": 27,
"end_line": 55,
"start_col": 2,
"start_line": 55
} |
Prims.GTot | val compute_gen_elim_f (i: gen_elim_i) : GTot (gen_elim_t i) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x)) | val compute_gen_elim_f (i: gen_elim_i) : GTot (gen_elim_t i)
let rec compute_gen_elim_f (i: gen_elim_i) : GTot (gen_elim_t i) = | false | null | false | match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x)) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.gen_elim_t",
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.ST.GenElim1.compute_gen_elim_f_unit",
"Steel.ST.GenElim1.compute_gen_elim_f_star_l",
"Steel.ST.GenElim1.compute_gen_elim_f",
"Steel.ST.GenElim1.compute_gen_elim_f_star_r",
"Steel.ST.GenElim1.compute_gen_elim_f_star",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.compute_gen_elim_f_exists_no_abs0",
"Steel.ST.GenElim1.compute_gen_elim_f_exists_unit0",
"Steel.ST.GenElim1.compute_gen_elim_f_exists0",
"Steel.ST.GenElim1.compute_gen_elim_f_exists_no_abs1",
"Steel.ST.GenElim1.compute_gen_elim_f_exists_unit1",
"Steel.ST.GenElim1.compute_gen_elim_f_exists1"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_f (i: gen_elim_i) : GTot (gen_elim_t i) | [
"recursion"
] | Steel.ST.GenElim1.compute_gen_elim_f | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i: Steel.ST.GenElim1.Base.gen_elim_i -> Prims.GTot (Steel.ST.GenElim1.gen_elim_t i) | {
"end_col": 94,
"end_line": 192,
"start_col": 2,
"start_line": 182
} |
Steel.ST.Effect.Ghost.STGhostF | val gen_elim
(#opened: _)
(#[@@@ framing_implicit] p: vprop)
(#[@@@ framing_implicit] a: Type)
(#[@@@ framing_implicit] q: Ghost.erased a -> Tot vprop)
(#[@@@ framing_implicit] post: Ghost.erased a -> Tot prop)
(#[@@@ framing_implicit] sq: squash (gen_elim_prop_placeholder true p a q post))
(_: unit)
: STGhostF (Ghost.erased a) opened p (fun x -> guard_vprop (q x)) ( (T.with_tactic solve_gen_elim_prop) (squash (gen_elim_prop true p a q post))) post | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 gen_elim
#opened #p #a #q #post #sq _
= gen_elim' #opened _ p a q post sq () | val gen_elim
(#opened: _)
(#[@@@ framing_implicit] p: vprop)
(#[@@@ framing_implicit] a: Type)
(#[@@@ framing_implicit] q: Ghost.erased a -> Tot vprop)
(#[@@@ framing_implicit] post: Ghost.erased a -> Tot prop)
(#[@@@ framing_implicit] sq: squash (gen_elim_prop_placeholder true p a q post))
(_: unit)
: STGhostF (Ghost.erased a) opened p (fun x -> guard_vprop (q x)) ( (T.with_tactic solve_gen_elim_prop) (squash (gen_elim_prop true p a q post))) post
let gen_elim #opened #p #a #q #post #sq _ = | true | null | false | gen_elim' #opened _ p a q post sq () | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [] | [
"Steel.Memory.inames",
"Steel.Effect.Common.vprop",
"FStar.Ghost.erased",
"Prims.prop",
"Prims.squash",
"Steel.ST.GenElim1.Base.gen_elim_prop_placeholder",
"Prims.unit",
"Steel.ST.GenElim1.gen_elim'"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ())))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let res = Mktuple13 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> exists_ (fun x14 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ())))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let x14 = elim_exists' () in
let res = Mktuple14 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type) (tq: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq))
= fun q post intro _ ->
// default case: no exists is opened
let res : compute_gen_elim_nondep_a' (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq) = (U.raise_val ()) in
rewrite_with_trefl (compute_gen_elim_p i0) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct'
(i0: gen_elim_i)
(ty: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 ty)
= match ty returns compute_gen_elim_nondep_correct_t i0 ty with
| [] -> compute_gen_elim_nondep_correct0 i0
| [t1] -> compute_gen_elim_nondep_correct1 i0 t1
| [t1; t2] -> compute_gen_elim_nondep_correct2 i0 t1 t2
| [t1; t2; t3] -> compute_gen_elim_nondep_correct3 i0 t1 t2 t3
| [t1; t2; t3; t4] -> compute_gen_elim_nondep_correct4 i0 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> compute_gen_elim_nondep_correct5 i0 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> compute_gen_elim_nondep_correct6 i0 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> compute_gen_elim_nondep_correct7 i0 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> compute_gen_elim_nondep_correct8 i0 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> compute_gen_elim_nondep_correct9 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> compute_gen_elim_nondep_correct10 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> compute_gen_elim_nondep_correct11 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> compute_gen_elim_nondep_correct12 i0 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] -> compute_gen_elim_nondep_correct13 i0 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] -> compute_gen_elim_nondep_correct14 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq -> compute_gen_elim_nondep_correct_default i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 tq
let compute_gen_elim_nondep_correct_0
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
= match i returns
(sq: squash (check_gen_elim_nondep_sem i0 i)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a i0 i)
(compute_gen_elim_nondep_q0 i0 i)
(compute_gen_elim_nondep_post0 i0 i)
)
with
| GEDep -> fun _ -> compute_gen_elim_f i0
| GENonDep ty q post -> fun _ ->
let intro : vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post) = fun _ ->
compute_gen_elim_tele_correct i0 _;
rewrite (tele_p _) (tele_p (gen_elim_nondep_sem ty q post));
gen_elim_nondep_sem_correct ty q post;
rewrite_equiv (tele_p _) (gen_elim_nondep_p _ _ _)
in
compute_gen_elim_nondep_correct' i0 ty q post intro
let compute_gen_elim_nondep_correct
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(sq: squash (check_gen_elim_nondep_sem i0 i))
: Tot (gen_elim_f
(compute_gen_elim_p i0)
(Ghost.erased (compute_gen_elim_nondep_a i0 i))
(compute_gen_elim_nondep_q i0 i)
(compute_gen_elim_nondep_post i0 i)
)
= fun _ ->
let res0 = compute_gen_elim_nondep_correct_0 i0 i sq _ in
let res = Ghost.hide res0 in
rewrite (compute_gen_elim_nondep_q0 i0 i res0) (compute_gen_elim_nondep_q i0 i res);
res
let coerce_with_smt (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires ( (tfrom == tto))) (ensures (fun _ -> True)) = x
let gen_elim'
#opened enable_nondep_opt p a q post _ ()
=
let (i, j) = gen_elim_prop_elim enable_nondep_opt p a q post in
rewrite p (compute_gen_elim_p i);
let res' = compute_gen_elim_nondep_correct i j () _ in
let res : Ghost.erased a = Ghost.hide (coerce_with_smt (Ghost.reveal res')) in
rewrite (compute_gen_elim_nondep_q i j res') (guard_vprop (q res));
res
let gen_elim | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gen_elim
(#opened: _)
(#[@@@ framing_implicit] p: vprop)
(#[@@@ framing_implicit] a: Type)
(#[@@@ framing_implicit] q: Ghost.erased a -> Tot vprop)
(#[@@@ framing_implicit] post: Ghost.erased a -> Tot prop)
(#[@@@ framing_implicit] sq: squash (gen_elim_prop_placeholder true p a q post))
(_: unit)
: STGhostF (Ghost.erased a) opened p (fun x -> guard_vprop (q x)) ( (T.with_tactic solve_gen_elim_prop) (squash (gen_elim_prop true p a q post))) post | [] | Steel.ST.GenElim1.gen_elim | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | _: Prims.unit -> Steel.ST.Effect.Ghost.STGhostF (FStar.Ghost.erased a) | {
"end_col": 38,
"end_line": 843,
"start_col": 2,
"start_line": 843
} |
Steel.ST.Effect.Ghost.STGhostF | val gen_elim_dep
(#opened: _)
(#[@@@ framing_implicit] p: vprop)
(#[@@@ framing_implicit] a: Type)
(#[@@@ framing_implicit] q: Ghost.erased a -> Tot vprop)
(#[@@@ framing_implicit] post: Ghost.erased a -> Tot prop)
(#[@@@ framing_implicit] sq: squash (gen_elim_prop_placeholder false p a q post))
(_: unit)
: STGhostF (Ghost.erased a) opened p (fun x -> guard_vprop (q x)) ( (T.with_tactic solve_gen_elim_prop) (squash (gen_elim_prop false p a q post))) post | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 gen_elim_dep
#opened #p #a #q #post #sq _
= gen_elim' #opened _ p a q post sq () | val gen_elim_dep
(#opened: _)
(#[@@@ framing_implicit] p: vprop)
(#[@@@ framing_implicit] a: Type)
(#[@@@ framing_implicit] q: Ghost.erased a -> Tot vprop)
(#[@@@ framing_implicit] post: Ghost.erased a -> Tot prop)
(#[@@@ framing_implicit] sq: squash (gen_elim_prop_placeholder false p a q post))
(_: unit)
: STGhostF (Ghost.erased a) opened p (fun x -> guard_vprop (q x)) ( (T.with_tactic solve_gen_elim_prop) (squash (gen_elim_prop false p a q post))) post
let gen_elim_dep #opened #p #a #q #post #sq _ = | true | null | false | gen_elim' #opened _ p a q post sq () | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [] | [
"Steel.Memory.inames",
"Steel.Effect.Common.vprop",
"FStar.Ghost.erased",
"Prims.prop",
"Prims.squash",
"Steel.ST.GenElim1.Base.gen_elim_prop_placeholder",
"Prims.unit",
"Steel.ST.GenElim1.gen_elim'"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ())))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let res = Mktuple13 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> exists_ (fun x14 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ())))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let x14 = elim_exists' () in
let res = Mktuple14 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type) (tq: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq))
= fun q post intro _ ->
// default case: no exists is opened
let res : compute_gen_elim_nondep_a' (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq) = (U.raise_val ()) in
rewrite_with_trefl (compute_gen_elim_p i0) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct'
(i0: gen_elim_i)
(ty: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 ty)
= match ty returns compute_gen_elim_nondep_correct_t i0 ty with
| [] -> compute_gen_elim_nondep_correct0 i0
| [t1] -> compute_gen_elim_nondep_correct1 i0 t1
| [t1; t2] -> compute_gen_elim_nondep_correct2 i0 t1 t2
| [t1; t2; t3] -> compute_gen_elim_nondep_correct3 i0 t1 t2 t3
| [t1; t2; t3; t4] -> compute_gen_elim_nondep_correct4 i0 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> compute_gen_elim_nondep_correct5 i0 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> compute_gen_elim_nondep_correct6 i0 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> compute_gen_elim_nondep_correct7 i0 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> compute_gen_elim_nondep_correct8 i0 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> compute_gen_elim_nondep_correct9 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> compute_gen_elim_nondep_correct10 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> compute_gen_elim_nondep_correct11 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> compute_gen_elim_nondep_correct12 i0 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] -> compute_gen_elim_nondep_correct13 i0 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] -> compute_gen_elim_nondep_correct14 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq -> compute_gen_elim_nondep_correct_default i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 tq
let compute_gen_elim_nondep_correct_0
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
= match i returns
(sq: squash (check_gen_elim_nondep_sem i0 i)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a i0 i)
(compute_gen_elim_nondep_q0 i0 i)
(compute_gen_elim_nondep_post0 i0 i)
)
with
| GEDep -> fun _ -> compute_gen_elim_f i0
| GENonDep ty q post -> fun _ ->
let intro : vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post) = fun _ ->
compute_gen_elim_tele_correct i0 _;
rewrite (tele_p _) (tele_p (gen_elim_nondep_sem ty q post));
gen_elim_nondep_sem_correct ty q post;
rewrite_equiv (tele_p _) (gen_elim_nondep_p _ _ _)
in
compute_gen_elim_nondep_correct' i0 ty q post intro
let compute_gen_elim_nondep_correct
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(sq: squash (check_gen_elim_nondep_sem i0 i))
: Tot (gen_elim_f
(compute_gen_elim_p i0)
(Ghost.erased (compute_gen_elim_nondep_a i0 i))
(compute_gen_elim_nondep_q i0 i)
(compute_gen_elim_nondep_post i0 i)
)
= fun _ ->
let res0 = compute_gen_elim_nondep_correct_0 i0 i sq _ in
let res = Ghost.hide res0 in
rewrite (compute_gen_elim_nondep_q0 i0 i res0) (compute_gen_elim_nondep_q i0 i res);
res
let coerce_with_smt (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires ( (tfrom == tto))) (ensures (fun _ -> True)) = x
let gen_elim'
#opened enable_nondep_opt p a q post _ ()
=
let (i, j) = gen_elim_prop_elim enable_nondep_opt p a q post in
rewrite p (compute_gen_elim_p i);
let res' = compute_gen_elim_nondep_correct i j () _ in
let res : Ghost.erased a = Ghost.hide (coerce_with_smt (Ghost.reveal res')) in
rewrite (compute_gen_elim_nondep_q i j res') (guard_vprop (q res));
res
let gen_elim
#opened #p #a #q #post #sq _
= gen_elim' #opened _ p a q post sq ()
let gen_elim_dep | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gen_elim_dep
(#opened: _)
(#[@@@ framing_implicit] p: vprop)
(#[@@@ framing_implicit] a: Type)
(#[@@@ framing_implicit] q: Ghost.erased a -> Tot vprop)
(#[@@@ framing_implicit] post: Ghost.erased a -> Tot prop)
(#[@@@ framing_implicit] sq: squash (gen_elim_prop_placeholder false p a q post))
(_: unit)
: STGhostF (Ghost.erased a) opened p (fun x -> guard_vprop (q x)) ( (T.with_tactic solve_gen_elim_prop) (squash (gen_elim_prop false p a q post))) post | [] | Steel.ST.GenElim1.gen_elim_dep | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | _: Prims.unit -> Steel.ST.Effect.Ghost.STGhostF (FStar.Ghost.erased a) | {
"end_col": 38,
"end_line": 847,
"start_col": 2,
"start_line": 847
} |
Prims.GTot | val tele_star_correct (i1 i2: gen_elim_tele)
: GTot (vprop_rewrite ((tele_p i1) `star` (tele_p i2)) (tele_p (i1 `tele_star` i2))) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end | val tele_star_correct (i1 i2: gen_elim_tele)
: GTot (vprop_rewrite ((tele_p i1) `star` (tele_p i2)) (tele_p (i1 `tele_star` i2)))
let rec tele_star_correct (i1 i2: gen_elim_tele)
: GTot (vprop_rewrite ((tele_p i1) `star` (tele_p i2)) (tele_p (i1 `tele_star` i2))) = | false | null | false | match i1 returns vprop_rewrite ((tele_p i1) `star` (tele_p i2)) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
match
i2
returns
vprop_rewrite ((tele_p (TExists ty1 f1)) `star` (tele_p i2))
(tele_p ((TExists ty1 f1) `tele_star` i2))
with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 ->
tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2)) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.ST.GenElim1.Base.gen_elim_tele",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.tele_star",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.tele_star_correct_ret_l",
"Steel.ST.GenElim1.Base.TExists",
"Steel.ST.GenElim1.tele_star_correct_ret_r",
"Steel.ST.GenElim1.tele_star_correct_exists",
"Steel.ST.GenElim1.tele_star_correct"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tele_star_correct (i1 i2: gen_elim_tele)
: GTot (vprop_rewrite ((tele_p i1) `star` (tele_p i2)) (tele_p (i1 `tele_star` i2))) | [
"recursion"
] | Steel.ST.GenElim1.tele_star_correct | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i1: Steel.ST.GenElim1.Base.gen_elim_tele -> i2: Steel.ST.GenElim1.Base.gen_elim_tele
-> Prims.GTot
(Steel.ST.GenElim1.vprop_rewrite (Steel.Effect.Common.star (Steel.ST.GenElim1.tele_p i1)
(Steel.ST.GenElim1.tele_p i2))
(Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.tele_star i1 i2))) | {
"end_col": 7,
"end_line": 286,
"start_col": 2,
"start_line": 280
} |
Prims.GTot | val tele_star_vprop_correct (i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite (((tele_p i) `star` v) `star` (pure p)) (tele_p (tele_star_vprop i v p))) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p) | val tele_star_vprop_correct (i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite (((tele_p i) `star` v) `star` (pure p)) (tele_p (tele_star_vprop i v p)))
let rec tele_star_vprop_correct (i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite (((tele_p i) `star` v) `star` (pure p)) (tele_p (tele_star_vprop i v p))) = | false | null | false | match
i returns vprop_rewrite (((tele_p i) `star` v) `star` (pure p)) (tele_p (tele_star_vprop i v p))
with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body ->
tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.ST.GenElim1.Base.gen_elim_tele",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.Util.pure",
"Steel.ST.GenElim1.Base.tele_star_vprop",
"Steel.ST.GenElim1.tele_star_vprop_correct_ret",
"Steel.ST.GenElim1.tele_star_vprop_correct_exists",
"Steel.ST.GenElim1.tele_star_vprop_correct"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tele_star_vprop_correct (i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite (((tele_p i) `star` v) `star` (pure p)) (tele_p (tele_star_vprop i v p))) | [
"recursion"
] | Steel.ST.GenElim1.tele_star_vprop_correct | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i: Steel.ST.GenElim1.Base.gen_elim_tele -> v: Steel.Effect.Common.vprop -> p: Prims.prop
-> Prims.GTot
(Steel.ST.GenElim1.vprop_rewrite (Steel.Effect.Common.star (Steel.Effect.Common.star (Steel.ST.GenElim1.tele_p
i)
v)
(Steel.ST.Util.pure p))
(Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.tele_star_vprop i v p))) | {
"end_col": 113,
"end_line": 245,
"start_col": 2,
"start_line": 241
} |
Prims.Tot | val compute_gen_unit_elim_f_id (v: vprop) : Tot (gen_unit_elim_t (GUEId v)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val () | val compute_gen_unit_elim_f_id (v: vprop) : Tot (gen_unit_elim_t (GUEId v))
let compute_gen_unit_elim_f_id (v: vprop) : Tot (gen_unit_elim_t (GUEId v)) = | false | null | false | fun _ ->
noop ();
U.raise_val () | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.Effect.Common.vprop",
"Steel.Memory.inames",
"FStar.Universe.raise_val",
"Prims.unit",
"FStar.Universe.raise_t",
"Steel.ST.Util.noop",
"Steel.ST.GenElim1.gen_unit_elim_t",
"Steel.ST.GenElim1.Base.GUEId"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_unit_elim_f_id (v: vprop) : Tot (gen_unit_elim_t (GUEId v)) | [] | Steel.ST.GenElim1.compute_gen_unit_elim_f_id | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | v: Steel.Effect.Common.vprop -> Steel.ST.GenElim1.gen_unit_elim_t (Steel.ST.GenElim1.Base.GUEId v) | {
"end_col": 34,
"end_line": 19,
"start_col": 2,
"start_line": 19
} |
FStar.Pervasives.Lemma | val gen_elim_nondep_sem_correct (ty: list (Type u#a))
: Tot
(q: curried_function_type ty _ -> post: curried_function_type ty _
-> Lemma ((tele_p (gen_elim_nondep_sem ty q post)) `equiv` (gen_elim_nondep_p ty q post))) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf () | val gen_elim_nondep_sem_correct (ty: list (Type u#a))
: Tot
(q: curried_function_type ty _ -> post: curried_function_type ty _
-> Lemma ((tele_p (gen_elim_nondep_sem ty q post)) `equiv` (gen_elim_nondep_p ty q post)))
let rec gen_elim_nondep_sem_correct (ty: list (Type u#a))
: Tot
(q: curried_function_type ty _ -> post: curried_function_type ty _
-> Lemma ((tele_p (gen_elim_nondep_sem ty q post)) `equiv` (gen_elim_nondep_p ty q post))) = | false | null | true | match
ty
returns
(q: curried_function_type ty _ -> post: curried_function_type ty _
-> Lemma
((tele_p (gen_elim_nondep_sem ty q post)) `equiv` (gen_elim_nondep_p ty q post)))
with
| [] -> fun q post -> equiv_refl ((q (U.raise_val ())) `star` (pure (post (U.raise_val ()))))
| ta :: tq ->
fun q post ->
let phi (x: ta)
: Lemma
((tele_p (gen_elim_nondep_sem tq (q x) (post x)))
`equiv`
(gen_elim_nondep_p tq (q x) (post x))) =
gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf ()
: Lemma
((exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))))
`equiv`
(exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))) =
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x)))
(fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) ==
exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post ==
exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf () | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"lemma"
] | [
"Prims.list",
"Steel.ST.GenElim1.Base.curried_function_type",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Prims.l_True",
"Prims.squash",
"Steel.Effect.Common.equiv",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.gen_elim_nondep_sem",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Steel.Effect.Common.equiv_refl",
"Steel.Effect.Common.star",
"FStar.Universe.raise_val",
"Steel.ST.Util.pure",
"Prims.Cons",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Steel.ST.Util.exists_",
"Steel.ST.Util.exists_equiv",
"FStar.Classical.forall_intro",
"Steel.ST.GenElim1.gen_elim_nondep_sem_correct"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gen_elim_nondep_sem_correct (ty: list (Type u#a))
: Tot
(q: curried_function_type ty _ -> post: curried_function_type ty _
-> Lemma ((tele_p (gen_elim_nondep_sem ty q post)) `equiv` (gen_elim_nondep_p ty q post))) | [
"recursion"
] | Steel.ST.GenElim1.gen_elim_nondep_sem_correct | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
ty: Prims.list Type ->
q:
Steel.ST.GenElim1.Base.curried_function_type ty
(_: FStar.Universe.raise_t Prims.unit -> Steel.Effect.Common.vprop) ->
post:
Steel.ST.GenElim1.Base.curried_function_type ty
(_: FStar.Universe.raise_t Prims.unit -> Prims.prop)
-> FStar.Pervasives.Lemma
(ensures
Steel.Effect.Common.equiv (Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.gen_elim_nondep_sem
ty
q
post))
(Steel.ST.GenElim1.gen_elim_nondep_p ty q post)) | {
"end_col": 10,
"end_line": 460,
"start_col": 2,
"start_line": 440
} |
Prims.Tot | val compute_gen_elim_nondep_correct
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(sq: squash (check_gen_elim_nondep_sem i0 i))
: Tot
(gen_elim_f (compute_gen_elim_p i0)
(Ghost.erased (compute_gen_elim_nondep_a i0 i))
(compute_gen_elim_nondep_q i0 i)
(compute_gen_elim_nondep_post i0 i)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(sq: squash (check_gen_elim_nondep_sem i0 i))
: Tot (gen_elim_f
(compute_gen_elim_p i0)
(Ghost.erased (compute_gen_elim_nondep_a i0 i))
(compute_gen_elim_nondep_q i0 i)
(compute_gen_elim_nondep_post i0 i)
)
= fun _ ->
let res0 = compute_gen_elim_nondep_correct_0 i0 i sq _ in
let res = Ghost.hide res0 in
rewrite (compute_gen_elim_nondep_q0 i0 i res0) (compute_gen_elim_nondep_q i0 i res);
res | val compute_gen_elim_nondep_correct
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(sq: squash (check_gen_elim_nondep_sem i0 i))
: Tot
(gen_elim_f (compute_gen_elim_p i0)
(Ghost.erased (compute_gen_elim_nondep_a i0 i))
(compute_gen_elim_nondep_q i0 i)
(compute_gen_elim_nondep_post i0 i))
let compute_gen_elim_nondep_correct
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(sq: squash (check_gen_elim_nondep_sem i0 i))
: Tot
(gen_elim_f (compute_gen_elim_p i0)
(Ghost.erased (compute_gen_elim_nondep_a i0 i))
(compute_gen_elim_nondep_q i0 i)
(compute_gen_elim_nondep_post i0 i)) = | false | null | false | fun _ ->
let res0 = compute_gen_elim_nondep_correct_0 i0 i sq _ in
let res = Ghost.hide res0 in
rewrite (compute_gen_elim_nondep_q0 i0 i res0) (compute_gen_elim_nondep_q i0 i res);
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.gen_elim_nondep_t",
"Prims.squash",
"Steel.ST.GenElim1.Base.check_gen_elim_nondep_sem",
"Steel.Memory.inames",
"FStar.Ghost.erased",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a",
"Prims.unit",
"Steel.ST.Util.rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_q0",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_q",
"FStar.Ghost.hide",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_0",
"Steel.ST.GenElim1.gen_elim_f",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_post"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ())))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let res = Mktuple13 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> exists_ (fun x14 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ())))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let x14 = elim_exists' () in
let res = Mktuple14 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type) (tq: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq))
= fun q post intro _ ->
// default case: no exists is opened
let res : compute_gen_elim_nondep_a' (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq) = (U.raise_val ()) in
rewrite_with_trefl (compute_gen_elim_p i0) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct'
(i0: gen_elim_i)
(ty: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 ty)
= match ty returns compute_gen_elim_nondep_correct_t i0 ty with
| [] -> compute_gen_elim_nondep_correct0 i0
| [t1] -> compute_gen_elim_nondep_correct1 i0 t1
| [t1; t2] -> compute_gen_elim_nondep_correct2 i0 t1 t2
| [t1; t2; t3] -> compute_gen_elim_nondep_correct3 i0 t1 t2 t3
| [t1; t2; t3; t4] -> compute_gen_elim_nondep_correct4 i0 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> compute_gen_elim_nondep_correct5 i0 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> compute_gen_elim_nondep_correct6 i0 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> compute_gen_elim_nondep_correct7 i0 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> compute_gen_elim_nondep_correct8 i0 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> compute_gen_elim_nondep_correct9 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> compute_gen_elim_nondep_correct10 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> compute_gen_elim_nondep_correct11 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> compute_gen_elim_nondep_correct12 i0 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] -> compute_gen_elim_nondep_correct13 i0 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] -> compute_gen_elim_nondep_correct14 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq -> compute_gen_elim_nondep_correct_default i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 tq
let compute_gen_elim_nondep_correct_0
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
= match i returns
(sq: squash (check_gen_elim_nondep_sem i0 i)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a i0 i)
(compute_gen_elim_nondep_q0 i0 i)
(compute_gen_elim_nondep_post0 i0 i)
)
with
| GEDep -> fun _ -> compute_gen_elim_f i0
| GENonDep ty q post -> fun _ ->
let intro : vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post) = fun _ ->
compute_gen_elim_tele_correct i0 _;
rewrite (tele_p _) (tele_p (gen_elim_nondep_sem ty q post));
gen_elim_nondep_sem_correct ty q post;
rewrite_equiv (tele_p _) (gen_elim_nondep_p _ _ _)
in
compute_gen_elim_nondep_correct' i0 ty q post intro
let compute_gen_elim_nondep_correct
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(sq: squash (check_gen_elim_nondep_sem i0 i))
: Tot (gen_elim_f
(compute_gen_elim_p i0)
(Ghost.erased (compute_gen_elim_nondep_a i0 i))
(compute_gen_elim_nondep_q i0 i)
(compute_gen_elim_nondep_post i0 i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(sq: squash (check_gen_elim_nondep_sem i0 i))
: Tot
(gen_elim_f (compute_gen_elim_p i0)
(Ghost.erased (compute_gen_elim_nondep_a i0 i))
(compute_gen_elim_nondep_q i0 i)
(compute_gen_elim_nondep_post i0 i)) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim1.Base.gen_elim_i ->
i: Steel.ST.GenElim1.Base.gen_elim_nondep_t ->
sq: Prims.squash (Steel.ST.GenElim1.Base.check_gen_elim_nondep_sem i0 i)
-> Steel.ST.GenElim1.gen_elim_f (Steel.ST.GenElim1.Base.compute_gen_elim_p i0)
(FStar.Ghost.erased (Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a i0 i))
(Steel.ST.GenElim1.Base.compute_gen_elim_nondep_q i0 i)
(Steel.ST.GenElim1.Base.compute_gen_elim_nondep_post i0 i) | {
"end_col": 5,
"end_line": 827,
"start_col": 2,
"start_line": 823
} |
Prims.Tot | val compute_gen_unit_elim_f_pure (p: prop) : Tot (gen_unit_elim_t (GUEPure p)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val () | val compute_gen_unit_elim_f_pure (p: prop) : Tot (gen_unit_elim_t (GUEPure p))
let compute_gen_unit_elim_f_pure (p: prop) : Tot (gen_unit_elim_t (GUEPure p)) = | false | null | false | fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val () | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Prims.prop",
"Steel.Memory.inames",
"FStar.Universe.raise_val",
"Prims.unit",
"FStar.Universe.raise_t",
"Steel.ST.Util.elim_pure",
"Steel.ST.Util.rewrite",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_p",
"Steel.ST.GenElim1.Base.GUEPure",
"Steel.ST.Util.pure",
"Steel.ST.GenElim1.gen_unit_elim_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_unit_elim_f_pure (p: prop) : Tot (gen_unit_elim_t (GUEPure p)) | [] | Steel.ST.GenElim1.compute_gen_unit_elim_f_pure | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Prims.prop -> Steel.ST.GenElim1.gen_unit_elim_t (Steel.ST.GenElim1.Base.GUEPure p) | {
"end_col": 16,
"end_line": 27,
"start_col": 2,
"start_line": 24
} |
Prims.Tot | val tele_star_correct_ret_l (v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot
(vprop_rewrite ((tele_p (TRet v1 p1)) `star` (tele_p i2)) (tele_p ((TRet v1 p1) `tele_star` i2))
) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _) | val tele_star_correct_ret_l (v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot
(vprop_rewrite ((tele_p (TRet v1 p1)) `star` (tele_p i2)) (tele_p ((TRet v1 p1) `tele_star` i2))
)
let tele_star_correct_ret_l (v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot
(vprop_rewrite ((tele_p (TRet v1 p1)) `star` (tele_p i2)) (tele_p ((TRet v1 p1) `tele_star` i2))
) = | false | null | false | fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` (pure p1));
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.Base.gen_elim_tele",
"Steel.Memory.inames",
"Steel.ST.Util.rewrite",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.tele_star_vprop",
"Steel.ST.GenElim1.Base.tele_star",
"Steel.ST.GenElim1.Base.TRet",
"Prims.unit",
"Steel.ST.GenElim1.tele_star_vprop_correct",
"Steel.Effect.Common.star",
"Steel.ST.Util.pure",
"Steel.ST.GenElim1.vprop_rewrite"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tele_star_correct_ret_l (v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot
(vprop_rewrite ((tele_p (TRet v1 p1)) `star` (tele_p i2)) (tele_p ((TRet v1 p1) `tele_star` i2))
) | [] | Steel.ST.GenElim1.tele_star_correct_ret_l | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | v1: Steel.Effect.Common.vprop -> p1: Prims.prop -> i2: Steel.ST.GenElim1.Base.gen_elim_tele
-> Steel.ST.GenElim1.vprop_rewrite (Steel.Effect.Common.star (Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.TRet
v1 p1))
(Steel.ST.GenElim1.tele_p i2))
(Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.tele_star (Steel.ST.GenElim1.Base.TRet v1 p1
)
i2)) | {
"end_col": 31,
"end_line": 253,
"start_col": 2,
"start_line": 250
} |
Prims.Tot | val tele_star_correct_ret_r (i1: gen_elim_tele{~(TRet? i1)}) (v2: vprop) (p2: prop)
: Tot
(vprop_rewrite ((tele_p i1) `star` (tele_p (TRet v2 p2))) (tele_p (i1 `tele_star` (TRet v2 p2)))
) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2)) | val tele_star_correct_ret_r (i1: gen_elim_tele{~(TRet? i1)}) (v2: vprop) (p2: prop)
: Tot
(vprop_rewrite ((tele_p i1) `star` (tele_p (TRet v2 p2))) (tele_p (i1 `tele_star` (TRet v2 p2)))
)
let tele_star_correct_ret_r (i1: gen_elim_tele{~(TRet? i1)}) (v2: vprop) (p2: prop)
: Tot
(vprop_rewrite ((tele_p i1) `star` (tele_p (TRet v2 p2))) (tele_p (i1 `tele_star` (TRet v2 p2)))
) = | false | null | false | fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` (pure p2));
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` (TRet v2 p2))) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_tele",
"Prims.l_not",
"Prims.b2t",
"Steel.ST.GenElim1.Base.uu___is_TRet",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.Memory.inames",
"Steel.ST.Util.rewrite",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.tele_star_vprop",
"Steel.ST.GenElim1.Base.tele_star",
"Steel.ST.GenElim1.Base.TRet",
"Prims.unit",
"Steel.ST.GenElim1.tele_star_vprop_correct",
"Steel.Effect.Common.star",
"Steel.ST.Util.pure",
"Steel.ST.GenElim1.vprop_rewrite"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tele_star_correct_ret_r (i1: gen_elim_tele{~(TRet? i1)}) (v2: vprop) (p2: prop)
: Tot
(vprop_rewrite ((tele_p i1) `star` (tele_p (TRet v2 p2))) (tele_p (i1 `tele_star` (TRet v2 p2)))
) | [] | Steel.ST.GenElim1.tele_star_correct_ret_r | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i1: Steel.ST.GenElim1.Base.gen_elim_tele{~(TRet? i1)} ->
v2: Steel.Effect.Common.vprop ->
p2: Prims.prop
-> Steel.ST.GenElim1.vprop_rewrite (Steel.Effect.Common.star (Steel.ST.GenElim1.tele_p i1)
(Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.TRet v2 p2)))
(Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.tele_star i1
(Steel.ST.GenElim1.Base.TRet v2 p2))) | {
"end_col": 57,
"end_line": 261,
"start_col": 2,
"start_line": 258
} |
Prims.GTot | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct_0
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
= match i returns
(sq: squash (check_gen_elim_nondep_sem i0 i)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a i0 i)
(compute_gen_elim_nondep_q0 i0 i)
(compute_gen_elim_nondep_post0 i0 i)
)
with
| GEDep -> fun _ -> compute_gen_elim_f i0
| GENonDep ty q post -> fun _ ->
let intro : vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post) = fun _ ->
compute_gen_elim_tele_correct i0 _;
rewrite (tele_p _) (tele_p (gen_elim_nondep_sem ty q post));
gen_elim_nondep_sem_correct ty q post;
rewrite_equiv (tele_p _) (gen_elim_nondep_p _ _ _)
in
compute_gen_elim_nondep_correct' i0 ty q post intro | let compute_gen_elim_nondep_correct_0 (i0: gen_elim_i) (i: gen_elim_nondep_t) = | false | null | false | match
i
returns
sq: squash (check_gen_elim_nondep_sem i0 i)
-> GTot
(gen_elim_f (compute_gen_elim_p i0)
(compute_gen_elim_nondep_a i0 i)
(compute_gen_elim_nondep_q0 i0 i)
(compute_gen_elim_nondep_post0 i0 i))
with
| GEDep -> fun _ -> compute_gen_elim_f i0
| GENonDep ty q post ->
fun _ ->
let intro:vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post) =
fun _ ->
compute_gen_elim_tele_correct i0 _;
rewrite (tele_p _) (tele_p (gen_elim_nondep_sem ty q post));
gen_elim_nondep_sem_correct ty q post;
rewrite_equiv (tele_p _) (gen_elim_nondep_p _ _ _)
in
compute_gen_elim_nondep_correct' i0 ty q post intro | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.gen_elim_nondep_t",
"Prims.squash",
"Steel.ST.GenElim1.Base.check_gen_elim_nondep_sem",
"Steel.ST.GenElim1.gen_elim_f",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_q0",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_post0",
"Steel.ST.GenElim1.Base.GEDep",
"Steel.ST.GenElim1.compute_gen_elim_f",
"Prims.list",
"Steel.ST.GenElim1.Base.curried_function_type",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.Base.GENonDep",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct'",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.Util.rewrite_equiv",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.gen_elim_nondep_sem",
"Steel.ST.GenElim1.gen_elim_nondep_sem_correct",
"Steel.ST.Util.rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_tele",
"Steel.ST.GenElim1.compute_gen_elim_tele_correct"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ())))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let res = Mktuple13 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> exists_ (fun x14 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ())))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let x14 = elim_exists' () in
let res = Mktuple14 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type) (tq: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq))
= fun q post intro _ ->
// default case: no exists is opened
let res : compute_gen_elim_nondep_a' (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq) = (U.raise_val ()) in
rewrite_with_trefl (compute_gen_elim_p i0) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct'
(i0: gen_elim_i)
(ty: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 ty)
= match ty returns compute_gen_elim_nondep_correct_t i0 ty with
| [] -> compute_gen_elim_nondep_correct0 i0
| [t1] -> compute_gen_elim_nondep_correct1 i0 t1
| [t1; t2] -> compute_gen_elim_nondep_correct2 i0 t1 t2
| [t1; t2; t3] -> compute_gen_elim_nondep_correct3 i0 t1 t2 t3
| [t1; t2; t3; t4] -> compute_gen_elim_nondep_correct4 i0 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> compute_gen_elim_nondep_correct5 i0 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> compute_gen_elim_nondep_correct6 i0 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> compute_gen_elim_nondep_correct7 i0 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> compute_gen_elim_nondep_correct8 i0 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> compute_gen_elim_nondep_correct9 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> compute_gen_elim_nondep_correct10 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> compute_gen_elim_nondep_correct11 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> compute_gen_elim_nondep_correct12 i0 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] -> compute_gen_elim_nondep_correct13 i0 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] -> compute_gen_elim_nondep_correct14 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq -> compute_gen_elim_nondep_correct_default i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 tq
let compute_gen_elim_nondep_correct_0
(i0: gen_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct_0 : i0: Steel.ST.GenElim1.Base.gen_elim_i -> i: Steel.ST.GenElim1.Base.gen_elim_nondep_t
-> Prims.GTot
(sq: Prims.squash (Steel.ST.GenElim1.Base.check_gen_elim_nondep_sem i0 i)
-> Prims.GTot
(Steel.ST.GenElim1.gen_elim_f (Steel.ST.GenElim1.Base.compute_gen_elim_p i0)
(Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a i0 i)
(Steel.ST.GenElim1.Base.compute_gen_elim_nondep_q0 i0 i)
(Steel.ST.GenElim1.Base.compute_gen_elim_nondep_post0 i0 i))) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct_0 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i0: Steel.ST.GenElim1.Base.gen_elim_i -> i: Steel.ST.GenElim1.Base.gen_elim_nondep_t
-> Prims.GTot
(sq: Prims.squash (Steel.ST.GenElim1.Base.check_gen_elim_nondep_sem i0 i)
-> Prims.GTot
(Steel.ST.GenElim1.gen_elim_f (Steel.ST.GenElim1.Base.compute_gen_elim_p i0)
(Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a i0 i)
(Steel.ST.GenElim1.Base.compute_gen_elim_nondep_q0 i0 i)
(Steel.ST.GenElim1.Base.compute_gen_elim_nondep_post0 i0 i))) | {
"end_col": 55,
"end_line": 811,
"start_col": 2,
"start_line": 794
} |
|
Prims.Tot | val compute_gen_elim_nondep_correct' (i0: gen_elim_i) (ty: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 ty) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct'
(i0: gen_elim_i)
(ty: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 ty)
= match ty returns compute_gen_elim_nondep_correct_t i0 ty with
| [] -> compute_gen_elim_nondep_correct0 i0
| [t1] -> compute_gen_elim_nondep_correct1 i0 t1
| [t1; t2] -> compute_gen_elim_nondep_correct2 i0 t1 t2
| [t1; t2; t3] -> compute_gen_elim_nondep_correct3 i0 t1 t2 t3
| [t1; t2; t3; t4] -> compute_gen_elim_nondep_correct4 i0 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> compute_gen_elim_nondep_correct5 i0 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> compute_gen_elim_nondep_correct6 i0 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> compute_gen_elim_nondep_correct7 i0 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> compute_gen_elim_nondep_correct8 i0 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> compute_gen_elim_nondep_correct9 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> compute_gen_elim_nondep_correct10 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> compute_gen_elim_nondep_correct11 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> compute_gen_elim_nondep_correct12 i0 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] -> compute_gen_elim_nondep_correct13 i0 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] -> compute_gen_elim_nondep_correct14 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq -> compute_gen_elim_nondep_correct_default i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 tq | val compute_gen_elim_nondep_correct' (i0: gen_elim_i) (ty: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 ty)
let compute_gen_elim_nondep_correct' (i0: gen_elim_i) (ty: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 ty) = | false | null | false | match ty returns compute_gen_elim_nondep_correct_t i0 ty with
| [] -> compute_gen_elim_nondep_correct0 i0
| [t1] -> compute_gen_elim_nondep_correct1 i0 t1
| [t1 ; t2] -> compute_gen_elim_nondep_correct2 i0 t1 t2
| [t1 ; t2 ; t3] -> compute_gen_elim_nondep_correct3 i0 t1 t2 t3
| [t1 ; t2 ; t3 ; t4] -> compute_gen_elim_nondep_correct4 i0 t1 t2 t3 t4
| [t1 ; t2 ; t3 ; t4 ; t5] -> compute_gen_elim_nondep_correct5 i0 t1 t2 t3 t4 t5
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6] -> compute_gen_elim_nondep_correct6 i0 t1 t2 t3 t4 t5 t6
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7] -> compute_gen_elim_nondep_correct7 i0 t1 t2 t3 t4 t5 t6 t7
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8] ->
compute_gen_elim_nondep_correct8 i0 t1 t2 t3 t4 t5 t6 t7 t8
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9] ->
compute_gen_elim_nondep_correct9 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10] ->
compute_gen_elim_nondep_correct10 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10 ; t11] ->
compute_gen_elim_nondep_correct11 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1 ; t2 ; t3 ; t4 ; t5 ; t6 ; t7 ; t8 ; t9 ; t10 ; t11 ; t12] ->
compute_gen_elim_nondep_correct12 i0 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] ->
compute_gen_elim_nondep_correct13 i0 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] ->
compute_gen_elim_nondep_correct14 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq ->
compute_gen_elim_nondep_correct_default i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 tq | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Prims.list",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct0",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct1",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct2",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct3",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct4",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct5",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct6",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct7",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct8",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct9",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct10",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct11",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct12",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct13",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct14",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_default"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ())))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let res = Mktuple13 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> exists_ (fun x14 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ())))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let x14 = elim_exists' () in
let res = Mktuple14 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type) (tq: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq))
= fun q post intro _ ->
// default case: no exists is opened
let res : compute_gen_elim_nondep_a' (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq) = (U.raise_val ()) in
rewrite_with_trefl (compute_gen_elim_p i0) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct'
(i0: gen_elim_i)
(ty: list Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct' (i0: gen_elim_i) (ty: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 ty) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct' | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i0: Steel.ST.GenElim1.Base.gen_elim_i -> ty: Prims.list Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 ty | {
"end_col": 202,
"end_line": 789,
"start_col": 2,
"start_line": 773
} |
Steel.ST.Effect.Ghost.STGhostT | val elim_exists': #a: Type -> #opened_invariants: _ -> #p: (a -> vprop) -> unit
-> STGhostT (a) opened_invariants (exists_ p) (fun x -> p x) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x | val elim_exists': #a: Type -> #opened_invariants: _ -> #p: (a -> vprop) -> unit
-> STGhostT (a) opened_invariants (exists_ p) (fun x -> p x)
let elim_exists' (#a: Type) (#opened_invariants: _) (#p: (a -> vprop)) (_: unit)
: STGhostT (a) opened_invariants (exists_ p) (fun x -> p x) = | true | null | false | let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [] | [
"Steel.Memory.inames",
"Steel.Effect.Common.vprop",
"Prims.unit",
"Steel.ST.Util.rewrite",
"FStar.Ghost.reveal",
"FStar.Ghost.erased",
"Steel.ST.Util.elim_exists",
"Steel.ST.Util.exists_"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val elim_exists': #a: Type -> #opened_invariants: _ -> #p: (a -> vprop) -> unit
-> STGhostT (a) opened_invariants (exists_ p) (fun x -> p x) | [] | Steel.ST.GenElim1.elim_exists' | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | _: Prims.unit -> Steel.ST.Effect.Ghost.STGhostT a | {
"end_col": 3,
"end_line": 209,
"start_col": 1,
"start_line": 206
} |
Prims.Tot | val compute_gen_elim_tele_correct_unit (v: gen_unit_elim_i) : Tot (ge_to_tele_t (GEUnit v)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _) | val compute_gen_elim_tele_correct_unit (v: gen_unit_elim_i) : Tot (ge_to_tele_t (GEUnit v))
let compute_gen_elim_tele_correct_unit (v: gen_unit_elim_i) : Tot (ge_to_tele_t (GEUnit v)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl ((compute_gen_unit_elim_q v) `star` (pure _)) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_q",
"Steel.ST.Util.pure",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_post",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.compute_gen_elim_tele",
"Steel.ST.GenElim1.Base.GEUnit",
"Prims.unit",
"Steel.ST.Util.intro_pure",
"FStar.Universe.raise_t",
"Steel.ST.GenElim1.compute_gen_unit_elim_f",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_p",
"Steel.ST.GenElim1.ge_to_tele_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_tele_correct_unit (v: gen_unit_elim_i) : Tot (ge_to_tele_t (GEUnit v)) | [] | Steel.ST.GenElim1.compute_gen_elim_tele_correct_unit | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | v: Steel.ST.GenElim1.Base.gen_unit_elim_i
-> Steel.ST.GenElim1.ge_to_tele_t (Steel.ST.GenElim1.Base.GEUnit v) | {
"end_col": 73,
"end_line": 301,
"start_col": 2,
"start_line": 297
} |
Prims.Tot | val compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type)
(tq: list Type)
: Tot
(compute_gen_elim_nondep_correct_t i0
(t1 ::
t2 ::
t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type) (tq: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq))
= fun q post intro _ ->
// default case: no exists is opened
let res : compute_gen_elim_nondep_a' (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq) = (U.raise_val ()) in
rewrite_with_trefl (compute_gen_elim_p i0) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type)
(tq: list Type)
: Tot
(compute_gen_elim_nondep_correct_t i0
(t1 ::
t2 ::
t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq))
let compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type)
(tq: list Type)
: Tot
(compute_gen_elim_nondep_correct_t i0
(t1 ::
t2 ::
t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq)) = | false | null | false | fun q post intro _ ->
let res:compute_gen_elim_nondep_a' (t1 ::
t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq)
=
(U.raise_val ())
in
rewrite_with_trefl (compute_gen_elim_p i0)
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Prims.list",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ())))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let res = Mktuple13 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> exists_ (fun x14 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ())))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let x14 = elim_exists' () in
let res = Mktuple14 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type) (tq: list Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type)
(tq: list Type)
: Tot
(compute_gen_elim_nondep_correct_t i0
(t1 ::
t2 ::
t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq)) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct_default | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim1.Base.gen_elim_i ->
t1: Type ->
t2: Type ->
t3: Type ->
t4: Type ->
t5: Type ->
t6: Type ->
t7: Type ->
t8: Type ->
t9: Type ->
t10: Type ->
t11: Type ->
t12: Type ->
t13: Type ->
t14: Type ->
t15: Type ->
tq: Prims.list Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0
(t1 ::
t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq
) | {
"end_col": 7,
"end_line": 767,
"start_col": 2,
"start_line": 763
} |
Prims.GTot | val compute_gen_elim_f_exists_no_abs0 (a: Type0) (body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res | val compute_gen_elim_f_exists_no_abs0 (a: Type0) (body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
let compute_gen_elim_f_exists_no_abs0 (a: Type0) (body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body)) = | false | null | false | fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res:compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.Effect.Common.vprop",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_a",
"Steel.ST.GenElim1.Base.GEExistsNoAbs0",
"Prims.unit",
"Steel.ST.Util.rewrite",
"FStar.Ghost.reveal",
"Steel.ST.GenElim1.Base.compute_gen_elim_q",
"FStar.Universe.raise_val",
"FStar.Ghost.erased",
"Steel.ST.Util.elim_exists",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.Util.exists_",
"Steel.ST.GenElim1.gen_elim_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop)) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_f_exists_no_abs0 (a: Type0) (body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body)) | [] | Steel.ST.GenElim1.compute_gen_elim_f_exists_no_abs0 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | a: Type0 -> body: (_: a -> Steel.Effect.Common.vprop)
-> Prims.GTot (Steel.ST.GenElim1.gen_elim_t (Steel.ST.GenElim1.Base.GEExistsNoAbs0 body)) | {
"end_col": 5,
"end_line": 108,
"start_col": 2,
"start_line": 103
} |
Prims.Tot | val compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _) | val compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) ((compute_gen_elim_p l) `star` (compute_gen_elim_p r));
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.ge_to_tele_t",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.tele_star",
"Steel.ST.GenElim1.Base.compute_gen_elim_tele",
"Steel.ST.GenElim1.Base.GEStar",
"Prims.unit",
"Steel.ST.GenElim1.tele_star_correct",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.Effect.Common.star"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r)) | [] | Steel.ST.GenElim1.compute_gen_elim_tele_correct_star | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
l: Steel.ST.GenElim1.Base.gen_elim_i ->
ihl: Steel.ST.GenElim1.ge_to_tele_t l ->
r: Steel.ST.GenElim1.Base.gen_elim_i ->
ihr: Steel.ST.GenElim1.ge_to_tele_t r
-> Steel.ST.GenElim1.ge_to_tele_t (Steel.ST.GenElim1.Base.GEStar l r) | {
"end_col": 42,
"end_line": 340,
"start_col": 2,
"start_line": 335
} |
Prims.GTot | val compute_gen_elim_f_exists_no_abs1 (a: Type) (body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res | val compute_gen_elim_f_exists_no_abs1 (a: Type) (body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
let compute_gen_elim_f_exists_no_abs1 (a: Type) (body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body)) = | false | null | false | fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res:compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.Effect.Common.vprop",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_a",
"Steel.ST.GenElim1.Base.GEExistsNoAbs1",
"Prims.unit",
"Steel.ST.Util.rewrite",
"FStar.Ghost.reveal",
"Steel.ST.GenElim1.Base.compute_gen_elim_q",
"Steel.ST.GenElim1.Base.coerce_with_trefl",
"FStar.Ghost.erased",
"Steel.ST.Util.elim_exists",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.Util.exists_",
"Steel.ST.GenElim1.gen_elim_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop)) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_f_exists_no_abs1 (a: Type) (body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body)) | [] | Steel.ST.GenElim1.compute_gen_elim_f_exists_no_abs1 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | a: Type -> body: (_: a -> Steel.Effect.Common.vprop)
-> Prims.GTot (Steel.ST.GenElim1.gen_elim_t (Steel.ST.GenElim1.Base.GEExistsNoAbs1 body)) | {
"end_col": 5,
"end_line": 152,
"start_col": 2,
"start_line": 147
} |
Prims.Tot | val compute_gen_elim_f_exists_unit0 (a: Type0) (body: (a -> gen_unit_elim_i))
: Tot (gen_elim_t (GEExistsUnit0 body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res | val compute_gen_elim_f_exists_unit0 (a: Type0) (body: (a -> gen_unit_elim_i))
: Tot (gen_elim_t (GEExistsUnit0 body))
let compute_gen_elim_f_exists_unit0 (a: Type0) (body: (a -> gen_unit_elim_i))
: Tot (gen_elim_t (GEExistsUnit0 body)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body))
(exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res:compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_a",
"Steel.ST.GenElim1.Base.GEExistsUnit0",
"Prims.unit",
"Steel.ST.Util.rewrite",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_q",
"FStar.Ghost.reveal",
"Steel.ST.GenElim1.Base.compute_gen_elim_q",
"FStar.Universe.raise_val",
"FStar.Universe.raise_t",
"Steel.ST.GenElim1.compute_gen_unit_elim_f",
"FStar.Ghost.erased",
"Steel.ST.Util.elim_exists",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_p",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.Util.exists_",
"Steel.ST.GenElim1.gen_elim_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_f_exists_unit0 (a: Type0) (body: (a -> gen_unit_elim_i))
: Tot (gen_elim_t (GEExistsUnit0 body)) | [] | Steel.ST.GenElim1.compute_gen_elim_f_exists_unit0 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | a: Type0 -> body: (_: a -> Steel.ST.GenElim1.Base.gen_unit_elim_i)
-> Steel.ST.GenElim1.gen_elim_t (Steel.ST.GenElim1.Base.GEExistsUnit0 body) | {
"end_col": 5,
"end_line": 128,
"start_col": 2,
"start_line": 122
} |
Prims.Tot | val compute_gen_elim_tele_correct_exists_no_abs1 (ty: _) (body: (ty -> vprop))
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _) | val compute_gen_elim_tele_correct_exists_no_abs1 (ty: _) (body: (ty -> vprop))
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
let compute_gen_elim_tele_correct_exists_no_abs1 (ty: _) (body: (ty -> vprop))
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> (body x) `star` (pure True));
rewrite_with_trefl (exists_ _) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.Effect.Common.vprop",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.Util.pure",
"Prims.l_True",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.compute_gen_elim_tele",
"Steel.ST.GenElim1.Base.GEExistsNoAbs1",
"Prims.unit",
"Steel.ST.Util.intro_exists",
"Steel.ST.Util.intro_pure",
"Steel.ST.GenElim1.elim_exists'",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.ge_to_tele_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_tele_correct_exists_no_abs1 (ty: _) (body: (ty -> vprop))
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body)) | [] | Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists_no_abs1 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | ty: Type -> body: (_: ty -> Steel.Effect.Common.vprop)
-> Steel.ST.GenElim1.ge_to_tele_t (Steel.ST.GenElim1.Base.GEExistsNoAbs1 body) | {
"end_col": 43,
"end_line": 389,
"start_col": 2,
"start_line": 384
} |
Prims.Tot | val compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val () | val compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2)) = | false | null | false | fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2))
((compute_gen_unit_elim_p i1) `star` (compute_gen_unit_elim_p i2));
let _ = f1 _ in
let _ = f2 _ in
rewrite ((compute_gen_unit_elim_q i1) `star` (compute_gen_unit_elim_q i2))
(compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val () | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.ST.GenElim1.gen_unit_elim_t",
"Steel.Memory.inames",
"FStar.Universe.raise_val",
"Prims.unit",
"FStar.Universe.raise_t",
"Steel.ST.Util.rewrite",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_q",
"Steel.ST.GenElim1.Base.GUEStar",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_p"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2)) | [] | Steel.ST.GenElim1.compute_gen_unit_elim_f_star | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i1: Steel.ST.GenElim1.Base.gen_unit_elim_i ->
i2: Steel.ST.GenElim1.Base.gen_unit_elim_i ->
f1: Steel.ST.GenElim1.gen_unit_elim_t i1 ->
f2: Steel.ST.GenElim1.gen_unit_elim_t i2
-> Steel.ST.GenElim1.gen_unit_elim_t (Steel.ST.GenElim1.Base.GUEStar i1 i2) | {
"end_col": 16,
"end_line": 39,
"start_col": 2,
"start_line": 34
} |
Prims.Tot | val compute_gen_elim_nondep_correct0 (i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 []) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct0 (i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
let compute_gen_elim_nondep_correct0 (i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 []) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
((q (U.raise_val ())) `star` (pure (post (U.raise_val ()))));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"Steel.Effect.Common.star",
"Steel.ST.Util.pure",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct0 (i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 []) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct0 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i0: Steel.ST.GenElim1.Base.gen_elim_i -> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [] | {
"end_col": 7,
"end_line": 485,
"start_col": 2,
"start_line": 479
} |
Steel.ST.Effect.Ghost.STGhost | val gen_elim'
(#opened: _)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq: squash (gen_elim_prop_placeholder enable_nondep_opt p a q post))
(_: unit)
: STGhost (Ghost.erased a) opened p (fun x -> guard_vprop (q x)) (gen_elim_prop enable_nondep_opt p a q post) post | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 gen_elim'
#opened enable_nondep_opt p a q post _ ()
=
let (i, j) = gen_elim_prop_elim enable_nondep_opt p a q post in
rewrite p (compute_gen_elim_p i);
let res' = compute_gen_elim_nondep_correct i j () _ in
let res : Ghost.erased a = Ghost.hide (coerce_with_smt (Ghost.reveal res')) in
rewrite (compute_gen_elim_nondep_q i j res') (guard_vprop (q res));
res | val gen_elim'
(#opened: _)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq: squash (gen_elim_prop_placeholder enable_nondep_opt p a q post))
(_: unit)
: STGhost (Ghost.erased a) opened p (fun x -> guard_vprop (q x)) (gen_elim_prop enable_nondep_opt p a q post) post
let gen_elim' #opened enable_nondep_opt p a q post _ () = | true | null | false | let i, j = gen_elim_prop_elim enable_nondep_opt p a q post in
rewrite p (compute_gen_elim_p i);
let res' = compute_gen_elim_nondep_correct i j () _ in
let res:Ghost.erased a = Ghost.hide (coerce_with_smt (Ghost.reveal res')) in
rewrite (compute_gen_elim_nondep_q i j res') (guard_vprop (q res));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [] | [
"Steel.Memory.inames",
"Prims.bool",
"Steel.Effect.Common.vprop",
"FStar.Ghost.erased",
"Prims.prop",
"Prims.squash",
"Steel.ST.GenElim1.Base.gen_elim_prop_placeholder",
"Prims.unit",
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.gen_elim_nondep_t",
"Steel.ST.Util.rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_q",
"Steel.Effect.Common.guard_vprop",
"FStar.Ghost.hide",
"Steel.ST.GenElim1.coerce_with_smt",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a",
"FStar.Ghost.reveal",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"FStar.Pervasives.Native.tuple2",
"Steel.ST.GenElim1.Base.gen_elim_prop_elim"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ())))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let res = Mktuple13 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> exists_ (fun x14 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ())))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let x14 = elim_exists' () in
let res = Mktuple14 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct_default
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15: Type) (tq: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq))
= fun q post intro _ ->
// default case: no exists is opened
let res : compute_gen_elim_nondep_a' (t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq) = (U.raise_val ()) in
rewrite_with_trefl (compute_gen_elim_p i0) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct'
(i0: gen_elim_i)
(ty: list Type)
: Tot (compute_gen_elim_nondep_correct_t i0 ty)
= match ty returns compute_gen_elim_nondep_correct_t i0 ty with
| [] -> compute_gen_elim_nondep_correct0 i0
| [t1] -> compute_gen_elim_nondep_correct1 i0 t1
| [t1; t2] -> compute_gen_elim_nondep_correct2 i0 t1 t2
| [t1; t2; t3] -> compute_gen_elim_nondep_correct3 i0 t1 t2 t3
| [t1; t2; t3; t4] -> compute_gen_elim_nondep_correct4 i0 t1 t2 t3 t4
| [t1; t2; t3; t4; t5] -> compute_gen_elim_nondep_correct5 i0 t1 t2 t3 t4 t5
| [t1; t2; t3; t4; t5; t6] -> compute_gen_elim_nondep_correct6 i0 t1 t2 t3 t4 t5 t6
| [t1; t2; t3; t4; t5; t6; t7] -> compute_gen_elim_nondep_correct7 i0 t1 t2 t3 t4 t5 t6 t7
| [t1; t2; t3; t4; t5; t6; t7; t8] -> compute_gen_elim_nondep_correct8 i0 t1 t2 t3 t4 t5 t6 t7 t8
| [t1; t2; t3; t4; t5; t6; t7; t8; t9] -> compute_gen_elim_nondep_correct9 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] -> compute_gen_elim_nondep_correct10 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] -> compute_gen_elim_nondep_correct11 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
| [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] -> compute_gen_elim_nondep_correct12 i0 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] -> compute_gen_elim_nondep_correct13 i0 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] -> compute_gen_elim_nondep_correct14 i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
| t1 :: t2 :: t3 :: t4 :: t5 :: t6 :: t7 :: t8 :: t9 :: t10 :: t11 :: t12 :: t13 :: t14 :: t15 :: tq -> compute_gen_elim_nondep_correct_default i0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 tq
let compute_gen_elim_nondep_correct_0
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
= match i returns
(sq: squash (check_gen_elim_nondep_sem i0 i)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a i0 i)
(compute_gen_elim_nondep_q0 i0 i)
(compute_gen_elim_nondep_post0 i0 i)
)
with
| GEDep -> fun _ -> compute_gen_elim_f i0
| GENonDep ty q post -> fun _ ->
let intro : vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post) = fun _ ->
compute_gen_elim_tele_correct i0 _;
rewrite (tele_p _) (tele_p (gen_elim_nondep_sem ty q post));
gen_elim_nondep_sem_correct ty q post;
rewrite_equiv (tele_p _) (gen_elim_nondep_p _ _ _)
in
compute_gen_elim_nondep_correct' i0 ty q post intro
let compute_gen_elim_nondep_correct
(i0: gen_elim_i)
(i: gen_elim_nondep_t)
(sq: squash (check_gen_elim_nondep_sem i0 i))
: Tot (gen_elim_f
(compute_gen_elim_p i0)
(Ghost.erased (compute_gen_elim_nondep_a i0 i))
(compute_gen_elim_nondep_q i0 i)
(compute_gen_elim_nondep_post i0 i)
)
= fun _ ->
let res0 = compute_gen_elim_nondep_correct_0 i0 i sq _ in
let res = Ghost.hide res0 in
rewrite (compute_gen_elim_nondep_q0 i0 i res0) (compute_gen_elim_nondep_q i0 i res);
res
let coerce_with_smt (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires ( (tfrom == tto))) (ensures (fun _ -> True)) = x
let gen_elim' | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gen_elim'
(#opened: _)
(enable_nondep_opt: bool)
(p: vprop)
(a: Type)
(q: Ghost.erased a -> Tot vprop)
(post: Ghost.erased a -> Tot prop)
(sq: squash (gen_elim_prop_placeholder enable_nondep_opt p a q post))
(_: unit)
: STGhost (Ghost.erased a) opened p (fun x -> guard_vprop (q x)) (gen_elim_prop enable_nondep_opt p a q post) post | [] | Steel.ST.GenElim1.gen_elim' | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"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: Type ->
q: (_: FStar.Ghost.erased a -> Steel.Effect.Common.vprop) ->
post: (_: FStar.Ghost.erased a -> Prims.prop) ->
sq: Prims.squash (Steel.ST.GenElim1.Base.gen_elim_prop_placeholder enable_nondep_opt p a q post) ->
_: Prims.unit
-> Steel.ST.Effect.Ghost.STGhost (FStar.Ghost.erased a) | {
"end_col": 5,
"end_line": 839,
"start_col": 1,
"start_line": 833
} |
Prims.GTot | val compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res | val compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2)) = | false | null | false | fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2))
((compute_gen_elim_p i1) `star` (compute_gen_elim_p i2));
let res1 = f1 _ in
let res2 = f2 _ in
let res:compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite ((compute_gen_elim_q i1 res1) `star` (compute_gen_elim_q i2 res2))
(compute_gen_elim_q (GEStar i1 i2) res);
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.gen_elim_t",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_a",
"Steel.ST.GenElim1.Base.GEStar",
"Prims.unit",
"Steel.ST.Util.rewrite",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.Base.compute_gen_elim_q",
"Steel.ST.GenElim1.Base.coerce_with_trefl",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Steel.ST.GenElim1.Base.compute_gen_elim_p"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2)) | [] | Steel.ST.GenElim1.compute_gen_elim_f_star | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i1: Steel.ST.GenElim1.Base.gen_elim_i ->
f1: Steel.ST.GenElim1.gen_elim_t i1 ->
i2: Steel.ST.GenElim1.Base.gen_elim_i ->
f2: Steel.ST.GenElim1.gen_elim_t i2
-> Prims.GTot (Steel.ST.GenElim1.gen_elim_t (Steel.ST.GenElim1.Base.GEStar i1 i2)) | {
"end_col": 5,
"end_line": 97,
"start_col": 2,
"start_line": 91
} |
Prims.Tot | val compute_gen_elim_tele_correct_exists1
(ty: _)
(body: (ty -> gen_elim_i))
(ih: (x: ty -> GTot (ge_to_tele_t (body x))))
: Tot (ge_to_tele_t (GEExists1 #ty body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _) | val compute_gen_elim_tele_correct_exists1
(ty: _)
(body: (ty -> gen_elim_i))
(ih: (x: ty -> GTot (ge_to_tele_t (body x))))
: Tot (ge_to_tele_t (GEExists1 #ty body))
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: (ty -> gen_elim_i))
(ih: (x: ty -> GTot (ge_to_tele_t (body x))))
: Tot (ge_to_tele_t (GEExists1 #ty body)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.ge_to_tele_t",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.Util.exists_",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.compute_gen_elim_tele",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.Base.GEExists1",
"Prims.unit",
"Steel.ST.Util.intro_exists",
"Steel.ST.GenElim1.elim_exists'",
"Steel.ST.GenElim1.Base.compute_gen_elim_p"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x))) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_tele_correct_exists1
(ty: _)
(body: (ty -> gen_elim_i))
(ih: (x: ty -> GTot (ge_to_tele_t (body x))))
: Tot (ge_to_tele_t (GEExists1 #ty body)) | [] | Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists1 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
ty: Type ->
body: (_: ty -> Steel.ST.GenElim1.Base.gen_elim_i) ->
ih: (x: ty -> Prims.GTot (Steel.ST.GenElim1.ge_to_tele_t (body x)))
-> Steel.ST.GenElim1.ge_to_tele_t (Steel.ST.GenElim1.Base.GEExists1 body) | {
"end_col": 43,
"end_line": 413,
"start_col": 2,
"start_line": 408
} |
Prims.Tot | val compute_gen_elim_f_exists_unit1 (a: Type) (body: (a -> gen_unit_elim_i))
: Tot (gen_elim_t (GEExistsUnit1 body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res | val compute_gen_elim_f_exists_unit1 (a: Type) (body: (a -> gen_unit_elim_i))
: Tot (gen_elim_t (GEExistsUnit1 body))
let compute_gen_elim_f_exists_unit1 (a: Type) (body: (a -> gen_unit_elim_i))
: Tot (gen_elim_t (GEExistsUnit1 body)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body))
(exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res:compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_a",
"Steel.ST.GenElim1.Base.GEExistsUnit1",
"Prims.unit",
"Steel.ST.Util.rewrite",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_q",
"FStar.Ghost.reveal",
"Steel.ST.GenElim1.Base.compute_gen_elim_q",
"Steel.ST.GenElim1.Base.coerce_with_trefl",
"FStar.Universe.raise_t",
"Steel.ST.GenElim1.compute_gen_unit_elim_f",
"FStar.Ghost.erased",
"Steel.ST.Util.elim_exists",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_p",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.Util.exists_",
"Steel.ST.GenElim1.gen_elim_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_f_exists_unit1 (a: Type) (body: (a -> gen_unit_elim_i))
: Tot (gen_elim_t (GEExistsUnit1 body)) | [] | Steel.ST.GenElim1.compute_gen_elim_f_exists_unit1 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | a: Type -> body: (_: a -> Steel.ST.GenElim1.Base.gen_unit_elim_i)
-> Steel.ST.GenElim1.gen_elim_t (Steel.ST.GenElim1.Base.GEExistsUnit1 body) | {
"end_col": 5,
"end_line": 164,
"start_col": 2,
"start_line": 158
} |
Prims.Tot | val tele_star_vprop_correct_exists
(v: vprop)
(p: prop)
(ty: _)
(body: (ty -> gen_elim_tele))
(ih:
(x: ty
-> GTot
(vprop_rewrite (((tele_p (body x)) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (body x) v p)))))
: Tot
(vprop_rewrite (((tele_p (TExists ty body)) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (TExists ty body) v p))) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _) | val tele_star_vprop_correct_exists
(v: vprop)
(p: prop)
(ty: _)
(body: (ty -> gen_elim_tele))
(ih:
(x: ty
-> GTot
(vprop_rewrite (((tele_p (body x)) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (body x) v p)))))
: Tot
(vprop_rewrite (((tele_p (TExists ty body)) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (TExists ty body) v p)))
let tele_star_vprop_correct_exists
(v: vprop)
(p: prop)
(ty: _)
(body: (ty -> gen_elim_tele))
(ih:
(x: ty
-> GTot
(vprop_rewrite (((tele_p (body x)) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (body x) v p)))))
: Tot
(vprop_rewrite (((tele_p (TExists ty body)) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (TExists ty body) v p))) = | false | null | false | fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.Base.gen_elim_tele",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.Util.pure",
"Steel.ST.GenElim1.Base.tele_star_vprop",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.Util.exists_",
"Steel.ST.GenElim1.Base.TExists",
"Prims.unit",
"Steel.ST.Util.intro_exists",
"Steel.ST.GenElim1.elim_exists'"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p)))) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tele_star_vprop_correct_exists
(v: vprop)
(p: prop)
(ty: _)
(body: (ty -> gen_elim_tele))
(ih:
(x: ty
-> GTot
(vprop_rewrite (((tele_p (body x)) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (body x) v p)))))
: Tot
(vprop_rewrite (((tele_p (TExists ty body)) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (TExists ty body) v p))) | [] | Steel.ST.GenElim1.tele_star_vprop_correct_exists | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
v: Steel.Effect.Common.vprop ->
p: Prims.prop ->
ty: Type ->
body: (_: ty -> Steel.ST.GenElim1.Base.gen_elim_tele) ->
ih:
(x: ty
-> Prims.GTot
(Steel.ST.GenElim1.vprop_rewrite (Steel.Effect.Common.star (Steel.Effect.Common.star (Steel.ST.GenElim1.tele_p
(body x))
v)
(Steel.ST.Util.pure p))
(Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.tele_star_vprop (body x) v p))))
-> Steel.ST.GenElim1.vprop_rewrite (Steel.Effect.Common.star (Steel.Effect.Common.star (Steel.ST.GenElim1.tele_p
(Steel.ST.GenElim1.Base.TExists ty body))
v)
(Steel.ST.Util.pure p))
(Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.tele_star_vprop (Steel.ST.GenElim1.Base.TExists
ty body)
v
p)) | {
"end_col": 92,
"end_line": 233,
"start_col": 2,
"start_line": 228
} |
Prims.GTot | val compute_gen_elim_f_star_r (i1: gen_unit_elim_i) (i2: gen_elim_i) (f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res' | val compute_gen_elim_f_star_r (i1: gen_unit_elim_i) (i2: gen_elim_i) (f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
let compute_gen_elim_f_star_r (i1: gen_unit_elim_i) (i2: gen_elim_i) (f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2)) = | false | null | false | let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2))
((compute_gen_unit_elim_p i1) `star` (compute_gen_elim_p i2));
let _ = f1 _ in
let res = f2 _ in
let res':compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite ((compute_gen_unit_elim_q i1) `star` (compute_gen_elim_q i2 res))
(compute_gen_elim_q (GEStarR i1 i2) res');
res' | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.gen_elim_t",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_a",
"Steel.ST.GenElim1.Base.GEStarR",
"Prims.unit",
"Steel.ST.Util.rewrite",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_q",
"Steel.ST.GenElim1.Base.compute_gen_elim_q",
"Steel.ST.GenElim1.Base.coerce_with_trefl",
"FStar.Universe.raise_t",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_p",
"Steel.ST.GenElim1.gen_unit_elim_t",
"Steel.ST.GenElim1.compute_gen_unit_elim_f"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_f_star_r (i1: gen_unit_elim_i) (i2: gen_elim_i) (f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2)) | [] | Steel.ST.GenElim1.compute_gen_elim_f_star_r | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i1: Steel.ST.GenElim1.Base.gen_unit_elim_i ->
i2: Steel.ST.GenElim1.Base.gen_elim_i ->
f2: Steel.ST.GenElim1.gen_elim_t i2
-> Prims.GTot (Steel.ST.GenElim1.gen_elim_t (Steel.ST.GenElim1.Base.GEStarR i1 i2)) | {
"end_col": 6,
"end_line": 83,
"start_col": 1,
"start_line": 76
} |
Prims.Tot | val tele_star_vprop_correct_ret (v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot
(vprop_rewrite (((tele_p (TRet v' p')) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (TRet v' p') v p))) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _) | val tele_star_vprop_correct_ret (v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot
(vprop_rewrite (((tele_p (TRet v' p')) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (TRet v' p') v p)))
let tele_star_vprop_correct_ret (v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot
(vprop_rewrite (((tele_p (TRet v' p')) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (TRet v' p') v p))) = | false | null | false | fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` (pure p'));
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` (pure (p /\ p'))) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.Memory.inames",
"Steel.ST.Util.rewrite",
"Steel.Effect.Common.star",
"Steel.ST.Util.pure",
"Prims.l_and",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.tele_star_vprop",
"Steel.ST.GenElim1.Base.TRet",
"Prims.unit",
"Steel.ST.Util.intro_pure",
"Steel.ST.Util.elim_pure",
"Steel.ST.GenElim1.vprop_rewrite"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tele_star_vprop_correct_ret (v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot
(vprop_rewrite (((tele_p (TRet v' p')) `star` v) `star` (pure p))
(tele_p (tele_star_vprop (TRet v' p') v p))) | [] | Steel.ST.GenElim1.tele_star_vprop_correct_ret | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | v': Steel.Effect.Common.vprop -> p': Prims.prop -> v: Steel.Effect.Common.vprop -> p: Prims.prop
-> Steel.ST.GenElim1.vprop_rewrite (Steel.Effect.Common.star (Steel.Effect.Common.star (Steel.ST.GenElim1.tele_p
(Steel.ST.GenElim1.Base.TRet v' p'))
v)
(Steel.ST.Util.pure p))
(Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.tele_star_vprop (Steel.ST.GenElim1.Base.TRet
v' p')
v
p)) | {
"end_col": 60,
"end_line": 222,
"start_col": 2,
"start_line": 217
} |
Prims.Tot | val compute_gen_elim_f_exists0
(a: Type0)
(body: (a -> gen_elim_i))
(f: (x: a -> GTot (gen_elim_t (body x))))
: Tot (gen_elim_t (GEExists0 body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res | val compute_gen_elim_f_exists0
(a: Type0)
(body: (a -> gen_elim_i))
(f: (x: a -> GTot (gen_elim_t (body x))))
: Tot (gen_elim_t (GEExists0 body))
let compute_gen_elim_f_exists0
(a: Type0)
(body: (a -> gen_elim_i))
(f: (x: a -> GTot (gen_elim_t (body x))))
: Tot (gen_elim_t (GEExists0 body)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body))
(exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res:compute_gen_elim_a (GEExists0 body) =
coerce_with_trefl (Mkdtuple2 #a
#(fun x -> compute_gen_elim_a (body x))
(Ghost.reveal gres1)
(Ghost.reveal gres2))
in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.gen_elim_t",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_a",
"Steel.ST.GenElim1.Base.GEExists0",
"Prims.unit",
"Steel.ST.Util.rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_q",
"FStar.Ghost.reveal",
"Steel.ST.GenElim1.Base.coerce_with_trefl",
"Prims.dtuple2",
"Prims.Mkdtuple2",
"FStar.Ghost.hide",
"FStar.Ghost.erased",
"Steel.ST.Util.elim_exists",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.Util.exists_"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x))) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_f_exists0
(a: Type0)
(body: (a -> gen_elim_i))
(f: (x: a -> GTot (gen_elim_t (body x))))
: Tot (gen_elim_t (GEExists0 body)) | [] | Steel.ST.GenElim1.compute_gen_elim_f_exists0 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
a: Type0 ->
body: (_: a -> Steel.ST.GenElim1.Base.gen_elim_i) ->
f: (x: a -> Prims.GTot (Steel.ST.GenElim1.gen_elim_t (body x)))
-> Steel.ST.GenElim1.gen_elim_t (Steel.ST.GenElim1.Base.GEExists0 body) | {
"end_col": 5,
"end_line": 141,
"start_col": 2,
"start_line": 135
} |
Prims.GTot | val compute_gen_elim_f_star_l (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res' | val compute_gen_elim_f_star_l (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
let compute_gen_elim_f_star_l (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2)) = | false | null | false | let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2))
((compute_gen_elim_p i1) `star` (compute_gen_unit_elim_p i2));
let res = f1 _ in
let _ = f2 _ in
let res':compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite ((compute_gen_elim_q i1 res) `star` (compute_gen_unit_elim_q i2))
(compute_gen_elim_q (GEStarL i1 i2) res');
res' | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"sometrivial"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.gen_elim_t",
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_a",
"Steel.ST.GenElim1.Base.GEStarL",
"Prims.unit",
"Steel.ST.Util.rewrite",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.Base.compute_gen_elim_q",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_q",
"Steel.ST.GenElim1.Base.coerce_with_trefl",
"FStar.Universe.raise_t",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_p",
"Steel.ST.GenElim1.gen_unit_elim_t",
"Steel.ST.GenElim1.compute_gen_unit_elim_f"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_f_star_l (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2)) | [] | Steel.ST.GenElim1.compute_gen_elim_f_star_l | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i1: Steel.ST.GenElim1.Base.gen_elim_i ->
f1: Steel.ST.GenElim1.gen_elim_t i1 ->
i2: Steel.ST.GenElim1.Base.gen_unit_elim_i
-> Prims.GTot (Steel.ST.GenElim1.gen_elim_t (Steel.ST.GenElim1.Base.GEStarL i1 i2)) | {
"end_col": 6,
"end_line": 69,
"start_col": 1,
"start_line": 62
} |
Prims.Tot | val compute_gen_elim_f_exists1
(a: Type)
(body: (a -> gen_elim_i))
(f: (x: a -> GTot (gen_elim_t (body x))))
: Tot (gen_elim_t (GEExists1 body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res | val compute_gen_elim_f_exists1
(a: Type)
(body: (a -> gen_elim_i))
(f: (x: a -> GTot (gen_elim_t (body x))))
: Tot (gen_elim_t (GEExists1 body))
let compute_gen_elim_f_exists1
(a: Type)
(body: (a -> gen_elim_i))
(f: (x: a -> GTot (gen_elim_t (body x))))
: Tot (gen_elim_t (GEExists1 body)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body))
(exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res:compute_gen_elim_a (GEExists1 body) =
coerce_with_trefl (Mkdtuple2 #a
#(fun x -> compute_gen_elim_a (body x))
(Ghost.reveal gres1)
(Ghost.reveal gres2))
in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.gen_elim_t",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_a",
"Steel.ST.GenElim1.Base.GEExists1",
"Prims.unit",
"Steel.ST.Util.rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_q",
"FStar.Ghost.reveal",
"Steel.ST.GenElim1.Base.coerce_with_trefl",
"Prims.dtuple2",
"Prims.Mkdtuple2",
"FStar.Ghost.hide",
"FStar.Ghost.erased",
"Steel.ST.Util.elim_exists",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.Util.exists_"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x))) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_f_exists1
(a: Type)
(body: (a -> gen_elim_i))
(f: (x: a -> GTot (gen_elim_t (body x))))
: Tot (gen_elim_t (GEExists1 body)) | [] | Steel.ST.GenElim1.compute_gen_elim_f_exists1 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
a: Type ->
body: (_: a -> Steel.ST.GenElim1.Base.gen_elim_i) ->
f: (x: a -> Prims.GTot (Steel.ST.GenElim1.gen_elim_t (body x)))
-> Steel.ST.GenElim1.gen_elim_t (Steel.ST.GenElim1.Base.GEExists1 body) | {
"end_col": 5,
"end_line": 177,
"start_col": 2,
"start_line": 171
} |
Prims.Tot | val compute_gen_elim_tele_correct_star_l (l: gen_elim_i) (ihl: ge_to_tele_t l) (ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _) | val compute_gen_elim_tele_correct_star_l (l: gen_elim_i) (ihl: ge_to_tele_t l) (ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
let compute_gen_elim_tele_correct_star_l (l: gen_elim_i) (ihl: ge_to_tele_t l) (ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p _)
((compute_gen_elim_p l) `star` (compute_gen_unit_elim_p ru));
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.ge_to_tele_t",
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.tele_star_vprop",
"Steel.ST.GenElim1.Base.compute_gen_elim_tele",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_q",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_post",
"Steel.ST.GenElim1.Base.GEStarL",
"Prims.unit",
"Steel.ST.GenElim1.tele_star_vprop_correct",
"Steel.ST.Util.intro_pure",
"FStar.Universe.raise_t",
"Steel.ST.GenElim1.compute_gen_unit_elim_f",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_p"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_tele_correct_star_l (l: gen_elim_i) (ihl: ge_to_tele_t l) (ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru)) | [] | Steel.ST.GenElim1.compute_gen_elim_tele_correct_star_l | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
l: Steel.ST.GenElim1.Base.gen_elim_i ->
ihl: Steel.ST.GenElim1.ge_to_tele_t l ->
ru: Steel.ST.GenElim1.Base.gen_unit_elim_i
-> Steel.ST.GenElim1.ge_to_tele_t (Steel.ST.GenElim1.Base.GEStarL l ru) | {
"end_col": 42,
"end_line": 314,
"start_col": 2,
"start_line": 308
} |
Prims.Tot | val compute_gen_elim_tele_correct_exists_no_abs0 (ty: _) (body: (ty -> vprop))
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _) | val compute_gen_elim_tele_correct_exists_no_abs0 (ty: _) (body: (ty -> vprop))
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
let compute_gen_elim_tele_correct_exists_no_abs0 (ty: _) (body: (ty -> vprop))
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> (body (U.downgrade_val x)) `star` (pure True));
rewrite_with_trefl (exists_ _) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.Effect.Common.vprop",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.Util.exists_",
"FStar.Universe.raise_t",
"Steel.Effect.Common.star",
"FStar.Universe.downgrade_val",
"Steel.ST.Util.pure",
"Prims.l_True",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.compute_gen_elim_tele",
"Steel.ST.GenElim1.Base.GEExistsNoAbs0",
"Prims.unit",
"Steel.ST.Util.intro_exists",
"FStar.Universe.raise_val",
"Steel.ST.Util.rewrite",
"Steel.ST.Util.intro_pure",
"Steel.ST.GenElim1.elim_exists'",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.ge_to_tele_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_tele_correct_exists_no_abs0 (ty: _) (body: (ty -> vprop))
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body)) | [] | Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists_no_abs0 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | ty: Type0 -> body: (_: ty -> Steel.Effect.Common.vprop)
-> Steel.ST.GenElim1.ge_to_tele_t (Steel.ST.GenElim1.Base.GEExistsNoAbs0 body) | {
"end_col": 43,
"end_line": 352,
"start_col": 2,
"start_line": 346
} |
Prims.Tot | val compute_gen_elim_tele_correct_exists_unit1 (ty: _) (body: (ty -> gen_unit_elim_i))
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _) | val compute_gen_elim_tele_correct_exists_unit1 (ty: _) (body: (ty -> gen_unit_elim_i))
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
let compute_gen_elim_tele_correct_exists_unit1 (ty: _) (body: (ty -> gen_unit_elim_i))
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x
(fun x -> (compute_gen_unit_elim_q (body x)) `star` (pure (compute_gen_unit_elim_post (body x)))
);
rewrite_with_trefl (exists_ _) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_q",
"Steel.ST.Util.pure",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_post",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.compute_gen_elim_tele",
"Steel.ST.GenElim1.Base.GEExistsUnit1",
"Prims.unit",
"Steel.ST.Util.intro_exists",
"Steel.ST.Util.intro_pure",
"FStar.Universe.raise_t",
"Steel.ST.GenElim1.compute_gen_unit_elim_f",
"Steel.ST.GenElim1.elim_exists'",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_p",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.ge_to_tele_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_tele_correct_exists_unit1 (ty: _) (body: (ty -> gen_unit_elim_i))
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body)) | [] | Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists_unit1 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | ty: Type -> body: (_: ty -> Steel.ST.GenElim1.Base.gen_unit_elim_i)
-> Steel.ST.GenElim1.ge_to_tele_t (Steel.ST.GenElim1.Base.GEExistsUnit1 body) | {
"end_col": 43,
"end_line": 401,
"start_col": 2,
"start_line": 395
} |
Prims.Tot | val compute_gen_elim_nondep_correct1 (i0: gen_elim_i) (t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct1 (i0: gen_elim_i) (t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
let compute_gen_elim_nondep_correct1 (i0: gen_elim_i) (t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 -> (q x1 (U.raise_val ())) `star` (pure (post x1 (U.raise_val ())))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct1 (i0: gen_elim_i) (t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct1 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i0: Steel.ST.GenElim1.Base.gen_elim_i -> t1: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [t1] | {
"end_col": 7,
"end_line": 497,
"start_col": 2,
"start_line": 491
} |
Prims.Tot | val compute_gen_elim_tele_correct_exists0
(ty: _)
(body: (ty -> gen_elim_i))
(ih: (x: ty -> GTot (ge_to_tele_t (body x))))
: Tot (ge_to_tele_t (GEExists0 #ty body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _) | val compute_gen_elim_tele_correct_exists0
(ty: _)
(body: (ty -> gen_elim_i))
(ih: (x: ty -> GTot (ge_to_tele_t (body x))))
: Tot (ge_to_tele_t (GEExists0 #ty body))
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: (ty -> gen_elim_i))
(ih: (x: ty -> GTot (ge_to_tele_t (body x))))
: Tot (ge_to_tele_t (GEExists0 #ty body)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x)))
(tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x)
(fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.ge_to_tele_t",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.Util.exists_",
"FStar.Universe.raise_t",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.compute_gen_elim_tele",
"FStar.Universe.downgrade_val",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.Base.GEExists0",
"Prims.unit",
"Steel.ST.Util.intro_exists",
"FStar.Universe.raise_val",
"Steel.ST.Util.rewrite",
"Steel.ST.GenElim1.elim_exists'",
"Steel.ST.GenElim1.Base.compute_gen_elim_p"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x))) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_tele_correct_exists0
(ty: _)
(body: (ty -> gen_elim_i))
(ih: (x: ty -> GTot (ge_to_tele_t (body x))))
: Tot (ge_to_tele_t (GEExists0 #ty body)) | [] | Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists0 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
ty: Type0 ->
body: (_: ty -> Steel.ST.GenElim1.Base.gen_elim_i) ->
ih: (x: ty -> Prims.GTot (Steel.ST.GenElim1.ge_to_tele_t (body x)))
-> Steel.ST.GenElim1.ge_to_tele_t (Steel.ST.GenElim1.Base.GEExists0 body) | {
"end_col": 43,
"end_line": 378,
"start_col": 2,
"start_line": 372
} |
Prims.Tot | val compute_gen_elim_tele_correct_star_r (lu: gen_unit_elim_i) (r: gen_elim_i) (ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _) | val compute_gen_elim_tele_correct_star_r (lu: gen_unit_elim_i) (r: gen_elim_i) (ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
let compute_gen_elim_tele_correct_star_r (lu: gen_unit_elim_i) (r: gen_elim_i) (ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p _)
((compute_gen_unit_elim_p lu) `star` (compute_gen_elim_p r));
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.ge_to_tele_t",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.tele_star_vprop",
"Steel.ST.GenElim1.Base.compute_gen_elim_tele",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_q",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_post",
"Steel.ST.GenElim1.Base.GEStarR",
"Prims.unit",
"Steel.ST.GenElim1.tele_star_vprop_correct",
"Steel.ST.Util.intro_pure",
"FStar.Universe.raise_t",
"Steel.ST.GenElim1.compute_gen_unit_elim_f",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_p"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_tele_correct_star_r (lu: gen_unit_elim_i) (r: gen_elim_i) (ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r)) | [] | Steel.ST.GenElim1.compute_gen_elim_tele_correct_star_r | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
lu: Steel.ST.GenElim1.Base.gen_unit_elim_i ->
r: Steel.ST.GenElim1.Base.gen_elim_i ->
ihr: Steel.ST.GenElim1.ge_to_tele_t r
-> Steel.ST.GenElim1.ge_to_tele_t (Steel.ST.GenElim1.Base.GEStarR lu r) | {
"end_col": 42,
"end_line": 327,
"start_col": 2,
"start_line": 321
} |
Prims.Tot | val compute_gen_elim_tele_correct_exists_unit0 (ty: _) (body: (ty -> gen_unit_elim_i))
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body)) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _) | val compute_gen_elim_tele_correct_exists_unit0 (ty: _) (body: (ty -> gen_unit_elim_i))
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
let compute_gen_elim_tele_correct_exists_unit0 (ty: _) (body: (ty -> gen_unit_elim_i))
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body)) = | false | null | false | fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x))
(compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x)
(fun x ->
(compute_gen_unit_elim_q (body (U.downgrade_val x)))
`star`
(pure (compute_gen_unit_elim_post (body (U.downgrade_val x)))));
rewrite_with_trefl (exists_ _) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_unit_elim_i",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.Util.exists_",
"FStar.Universe.raise_t",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_q",
"FStar.Universe.downgrade_val",
"Steel.ST.Util.pure",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_post",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.compute_gen_elim_tele",
"Steel.ST.GenElim1.Base.GEExistsUnit0",
"Prims.unit",
"Steel.ST.Util.intro_exists",
"FStar.Universe.raise_val",
"Steel.ST.Util.rewrite",
"Steel.ST.Util.intro_pure",
"Steel.ST.GenElim1.compute_gen_unit_elim_f",
"Steel.ST.GenElim1.elim_exists'",
"Steel.ST.GenElim1.Base.compute_gen_unit_elim_p",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.ge_to_tele_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_tele_correct_exists_unit0 (ty: _) (body: (ty -> gen_unit_elim_i))
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body)) | [] | Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists_unit0 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | ty: Type0 -> body: (_: ty -> Steel.ST.GenElim1.Base.gen_unit_elim_i)
-> Steel.ST.GenElim1.ge_to_tele_t (Steel.ST.GenElim1.Base.GEExistsUnit0 body) | {
"end_col": 43,
"end_line": 365,
"start_col": 2,
"start_line": 358
} |
Prims.Tot | val compute_gen_elim_nondep_correct2 (i0: gen_elim_i) (t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct2 (i0: gen_elim_i) (t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
let compute_gen_elim_nondep_correct2 (i0: gen_elim_i) (t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
(q x1 x2 (U.raise_val ())) `star` (pure (post x1 x2 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct2 (i0: gen_elim_i) (t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct2 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i0: Steel.ST.GenElim1.Base.gen_elim_i -> t1: Type -> t2: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [t1; t2] | {
"end_col": 7,
"end_line": 511,
"start_col": 2,
"start_line": 503
} |
Prims.Tot | val tele_star_correct_exists
(ty1: _)
(f1: (ty1 -> gen_elim_tele))
(ty2: _)
(f2: (ty2 -> gen_elim_tele))
(ih:
(x1: ty1 -> x2: ty2
-> GTot
(vprop_rewrite ((tele_p (f1 x1)) `star` (tele_p (f2 x2)))
(tele_p ((f1 x1) `tele_star` (f2 x2))))))
: Tot
(vprop_rewrite ((tele_p (TExists ty1 f1)) `star` (tele_p (TExists ty2 f2)))
(tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2)))) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _) | val tele_star_correct_exists
(ty1: _)
(f1: (ty1 -> gen_elim_tele))
(ty2: _)
(f2: (ty2 -> gen_elim_tele))
(ih:
(x1: ty1 -> x2: ty2
-> GTot
(vprop_rewrite ((tele_p (f1 x1)) `star` (tele_p (f2 x2)))
(tele_p ((f1 x1) `tele_star` (f2 x2))))))
: Tot
(vprop_rewrite ((tele_p (TExists ty1 f1)) `star` (tele_p (TExists ty2 f2)))
(tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
let tele_star_correct_exists
(ty1: _)
(f1: (ty1 -> gen_elim_tele))
(ty2: _)
(f2: (ty2 -> gen_elim_tele))
(ih:
(x1: ty1 -> x2: ty2
-> GTot
(vprop_rewrite ((tele_p (f1 x1)) `star` (tele_p (f2 x2)))
(tele_p ((f1 x1) `tele_star` (f2 x2))))))
: Tot
(vprop_rewrite ((tele_p (TExists ty1 f1)) `star` (tele_p (TExists ty2 f2)))
(tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2)))) = | false | null | false | fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _) | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_tele",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.tele_p",
"Steel.ST.GenElim1.Base.tele_star",
"Steel.Memory.inames",
"Steel.ST.GenElim1.rewrite_with_trefl",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.vprop",
"Steel.ST.GenElim1.Base.TExists",
"Prims.unit",
"Steel.ST.Util.intro_exists",
"Steel.ST.GenElim1.elim_exists'"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2)))) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tele_star_correct_exists
(ty1: _)
(f1: (ty1 -> gen_elim_tele))
(ty2: _)
(f2: (ty2 -> gen_elim_tele))
(ih:
(x1: ty1 -> x2: ty2
-> GTot
(vprop_rewrite ((tele_p (f1 x1)) `star` (tele_p (f2 x2)))
(tele_p ((f1 x1) `tele_star` (f2 x2))))))
: Tot
(vprop_rewrite ((tele_p (TExists ty1 f1)) `star` (tele_p (TExists ty2 f2)))
(tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2)))) | [] | Steel.ST.GenElim1.tele_star_correct_exists | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
ty1: Type ->
f1: (_: ty1 -> Steel.ST.GenElim1.Base.gen_elim_tele) ->
ty2: Type ->
f2: (_: ty2 -> Steel.ST.GenElim1.Base.gen_elim_tele) ->
ih:
(x1: ty1 -> x2: ty2
-> Prims.GTot
(Steel.ST.GenElim1.vprop_rewrite (Steel.Effect.Common.star (Steel.ST.GenElim1.tele_p (f1
x1))
(Steel.ST.GenElim1.tele_p (f2 x2)))
(Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.tele_star (f1 x1) (f2 x2)))))
-> Steel.ST.GenElim1.vprop_rewrite (Steel.Effect.Common.star (Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.TExists
ty1 f1))
(Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.TExists ty2 f2)))
(Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.tele_star (Steel.ST.GenElim1.Base.TExists
ty1 f1)
(Steel.ST.GenElim1.Base.TExists ty2 f2))) | {
"end_col": 43,
"end_line": 275,
"start_col": 2,
"start_line": 267
} |
Prims.Tot | val compute_gen_elim_nondep_correct3 (i0: gen_elim_i) (t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct3 (i0: gen_elim_i) (t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
let compute_gen_elim_nondep_correct3 (i0: gen_elim_i) (t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
(q x1 x2 x3 (U.raise_val ())) `star` (pure (post x1 x2 x3 (U.raise_val ())))
))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct3 (i0: gen_elim_i) (t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct3 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i0: Steel.ST.GenElim1.Base.gen_elim_i -> t1: Type -> t2: Type -> t3: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [t1; t2; t3] | {
"end_col": 7,
"end_line": 526,
"start_col": 2,
"start_line": 517
} |
Prims.Tot | val compute_gen_elim_nondep_correct4 (i0: gen_elim_i) (t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct4 (i0: gen_elim_i) (t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
let compute_gen_elim_nondep_correct4 (i0: gen_elim_i) (t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
exists_ (fun x4 ->
(q x1 x2 x3 x4 (U.raise_val ()))
`star`
(pure (post x1 x2 x3 x4 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple4",
"FStar.Pervasives.Native.Mktuple4",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct4 (i0: gen_elim_i) (t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct4 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i0: Steel.ST.GenElim1.Base.gen_elim_i -> t1: Type -> t2: Type -> t3: Type -> t4: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4] | {
"end_col": 7,
"end_line": 542,
"start_col": 2,
"start_line": 532
} |
Prims.Tot | val compute_gen_elim_nondep_correct5 (i0: gen_elim_i) (t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct5 (i0: gen_elim_i) (t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
let compute_gen_elim_nondep_correct5 (i0: gen_elim_i) (t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
exists_ (fun x4 ->
exists_ (fun x5 ->
(q x1 x2 x3 x4 x5 (U.raise_val ()))
`star`
(pure (post x1 x2 x3 x4 x5 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple5",
"FStar.Pervasives.Native.Mktuple5",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct5 (i0: gen_elim_i) (t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct5 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i0: Steel.ST.GenElim1.Base.gen_elim_i -> t1: Type -> t2: Type -> t3: Type -> t4: Type -> t5: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5] | {
"end_col": 7,
"end_line": 559,
"start_col": 2,
"start_line": 548
} |
Prims.Tot | val compute_gen_elim_nondep_correct6 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct6 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
let compute_gen_elim_nondep_correct6 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
exists_ (fun x4 ->
exists_ (fun x5 ->
exists_ (fun x6 ->
(q x1 x2 x3 x4 x5 x6 (U.raise_val ()))
`star`
(pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple6",
"FStar.Pervasives.Native.Mktuple6",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct6 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct6 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim1.Base.gen_elim_i ->
t1: Type ->
t2: Type ->
t3: Type ->
t4: Type ->
t5: Type ->
t6: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6] | {
"end_col": 7,
"end_line": 577,
"start_col": 2,
"start_line": 565
} |
Prims.Tot | val compute_gen_elim_nondep_correct7 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct7 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
let compute_gen_elim_nondep_correct7 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
exists_ (fun x4 ->
exists_ (fun x5 ->
exists_ (fun x6 ->
exists_ (fun x7 ->
(q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))
`star`
(pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))
)))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple7",
"FStar.Pervasives.Native.Mktuple7",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct7 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct7 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim1.Base.gen_elim_i ->
t1: Type ->
t2: Type ->
t3: Type ->
t4: Type ->
t5: Type ->
t6: Type ->
t7: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7] | {
"end_col": 7,
"end_line": 596,
"start_col": 2,
"start_line": 583
} |
Prims.Tot | val compute_gen_elim_nondep_correct8 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct8 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
let compute_gen_elim_nondep_correct8 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
exists_ (fun x4 ->
exists_ (fun x5 ->
exists_ (fun x6 ->
exists_ (fun x7 ->
exists_ (fun x8 ->
(q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()))
`star`
(pure (post x1
x2
x3
x4
x5
x6
x7
x8
(U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple8",
"FStar.Pervasives.Native.Mktuple8",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct8 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct8 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim1.Base.gen_elim_i ->
t1: Type ->
t2: Type ->
t3: Type ->
t4: Type ->
t5: Type ->
t6: Type ->
t7: Type ->
t8: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8] | {
"end_col": 7,
"end_line": 616,
"start_col": 2,
"start_line": 602
} |
Prims.Tot | val compute_gen_elim_nondep_correct9 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct9 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
let compute_gen_elim_nondep_correct9 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
exists_ (fun x4 ->
exists_ (fun x5 ->
exists_ (fun x6 ->
exists_ (fun x7 ->
exists_ (fun x8 ->
exists_ (fun x9 ->
(q x1 x2 x3 x4 x5 x6 x7 x8 x9
(U.raise_val ()))
`star`
(pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9
(U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple9",
"FStar.Pervasives.Native.Mktuple9",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct9 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct9 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim1.Base.gen_elim_i ->
t1: Type ->
t2: Type ->
t3: Type ->
t4: Type ->
t5: Type ->
t6: Type ->
t7: Type ->
t8: Type ->
t9: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9] | {
"end_col": 7,
"end_line": 637,
"start_col": 2,
"start_line": 622
} |
Prims.Tot | val compute_gen_elim_nondep_correct10 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct10 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
let compute_gen_elim_nondep_correct10 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
exists_ (fun x4 ->
exists_ (fun x5 ->
exists_ (fun x6 ->
exists_ (fun x7 ->
exists_ (fun x8 ->
exists_ (fun x9 ->
exists_ (fun x10 ->
(q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10
(U.raise_val ()))
`star`
(pure (post x1 x2 x3 x4 x5 x6 x7
x8 x9 x10 (U.raise_val ())
)))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple10",
"FStar.Pervasives.Native.Mktuple10",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct10 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct10 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim1.Base.gen_elim_i ->
t1: Type ->
t2: Type ->
t3: Type ->
t4: Type ->
t5: Type ->
t6: Type ->
t7: Type ->
t8: Type ->
t9: Type ->
t10: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0
[t1; t2; t3; t4; t5; t6; t7; t8; t9; t10] | {
"end_col": 7,
"end_line": 659,
"start_col": 2,
"start_line": 643
} |
Prims.Tot | val compute_gen_elim_nondep_correct11 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct11 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
let compute_gen_elim_nondep_correct11 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
exists_ (fun x4 ->
exists_ (fun x5 ->
exists_ (fun x6 ->
exists_ (fun x7 ->
exists_ (fun x8 ->
exists_ (fun x9 ->
exists_ (fun x10 ->
exists_ (fun x11 ->
(q x1 x2 x3 x4 x5 x6 x7 x8
x9 x10 x11
(U.raise_val ()))
`star`
(pure (post x1 x2 x3 x4 x5
x6 x7 x8 x9 x10 x11
(U.raise_val ())))))
))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple11",
"FStar.Pervasives.Native.Mktuple11",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct11 (i0: gen_elim_i) (t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct11 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim1.Base.gen_elim_i ->
t1: Type ->
t2: Type ->
t3: Type ->
t4: Type ->
t5: Type ->
t6: Type ->
t7: Type ->
t8: Type ->
t9: Type ->
t10: Type ->
t11: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0
[t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11] | {
"end_col": 7,
"end_line": 682,
"start_col": 2,
"start_line": 665
} |
Prims.Tot | val compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ())))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
exists_ (fun x4 ->
exists_ (fun x5 ->
exists_ (fun x6 ->
exists_ (fun x7 ->
exists_ (fun x8 ->
exists_ (fun x9 ->
exists_ (fun x10 ->
exists_ (fun x11 ->
exists_ (fun x12 ->
(q x1 x2 x3 x4 x5 x6
x7 x8 x9 x10 x11
x12
(U.raise_val ()))
`star`
(pure (post x1 x2 x3
x4 x5 x6 x7 x8
x9 x10 x11 x12
(U.raise_val ()
))))))))))))
))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple12",
"FStar.Pervasives.Native.Mktuple12",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct12 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim1.Base.gen_elim_i ->
t1: Type ->
t2: Type ->
t3: Type ->
t4: Type ->
t5: Type ->
t6: Type ->
t7: Type ->
t8: Type ->
t9: Type ->
t10: Type ->
t11: Type ->
t12: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0
[t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12] | {
"end_col": 7,
"end_line": 706,
"start_col": 2,
"start_line": 688
} |
Prims.Tot | val compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot
(compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let res = Mktuple13 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot
(compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13])
let compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot
(compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
exists_ (fun x4 ->
exists_ (fun x5 ->
exists_ (fun x6 ->
exists_ (fun x7 ->
exists_ (fun x8 ->
exists_ (fun x9 ->
exists_ (fun x10 ->
exists_ (fun x11 ->
exists_ (fun x12 ->
exists_ (fun x13 ->
(q x1 x2 x3 x4
x5 x6 x7 x8
x9 x10 x11
x12 x13
(U.raise_val
()))
`star`
(pure (post x1
x2 x3 x4
x5 x6 x7
x8 x9
x10 x11
x12 x13
(U.raise_val
()))
)))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let res = Mktuple13 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple13",
"FStar.Pervasives.Native.Mktuple13",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ())))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot
(compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct13 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim1.Base.gen_elim_i ->
t1: Type ->
t2: Type ->
t3: Type ->
t4: Type ->
t5: Type ->
t6: Type ->
t7: Type ->
t8: Type ->
t9: Type ->
t10: Type ->
t11: Type ->
t12: Type ->
t13: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0
[t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13] | {
"end_col": 7,
"end_line": 731,
"start_col": 2,
"start_line": 712
} |
Prims.Tot | val compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot
(compute_gen_elim_nondep_correct_t i0
[t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14]) | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim1.Base",
"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 compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> exists_ (fun x14 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 (U.raise_val ())))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let x14 = elim_exists' () in
let res = Mktuple14 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | val compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot
(compute_gen_elim_nondep_correct_t i0
[t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14])
let compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot
(compute_gen_elim_nondep_correct_t i0
[t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14]) = | false | null | false | fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _)
(exists_ (fun x1 ->
exists_ (fun x2 ->
exists_ (fun x3 ->
exists_ (fun x4 ->
exists_ (fun x5 ->
exists_ (fun x6 ->
exists_ (fun x7 ->
exists_ (fun x8 ->
exists_ (fun x9 ->
exists_ (fun x10 ->
exists_ (fun x11 ->
exists_ (fun x12 ->
exists_ (fun x13 ->
exists_ (fun
x14
->
(q x1 x2
x3 x4
x5 x6
x7 x8
x9 x10
x11
x12
x13
x14
(U.raise_val
()
))
`star`
(pure (post
x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
x12
x13
x14
(U.raise_val
()
))
))))))))))
))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let x14 = elim_exists' () in
let res = Mktuple14 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ()))
(compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res | {
"checked_file": "Steel.ST.GenElim1.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GenElim1.fst"
} | [
"total"
] | [
"Steel.ST.GenElim1.Base.gen_elim_i",
"Steel.ST.GenElim1.Base.curried_function_type",
"Prims.Cons",
"Prims.Nil",
"FStar.Universe.raise_t",
"Prims.unit",
"Steel.Effect.Common.vprop",
"Prims.prop",
"Steel.ST.GenElim1.vprop_rewrite",
"Steel.ST.GenElim1.Base.compute_gen_elim_p",
"Steel.ST.GenElim1.gen_elim_nondep_p",
"Steel.Memory.inames",
"Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'",
"Steel.ST.GenElim1.rewrite_with_trefl",
"FStar.Universe.raise_val",
"Steel.ST.GenElim1.Base.compute_uncurry",
"Steel.ST.GenElim1.Base.compute_gen_elim_p'",
"Steel.ST.Util.elim_pure",
"FStar.Pervasives.Native.tuple14",
"FStar.Pervasives.Native.Mktuple14",
"Steel.ST.GenElim1.elim_exists'",
"Steel.Effect.Common.VStar",
"Steel.ST.Util.pure",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t"
] | [] | module Steel.ST.GenElim1
let gen_elim_f
(p: vprop)
(a: Type)
(q: (a -> vprop))
(post: (a -> prop))
: Tot Type
= ((opened: inames) -> STGhost a opened p q True post)
module U = FStar.Universe
let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type =
gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i)
let compute_gen_unit_elim_f_id
(v: vprop)
: Tot (gen_unit_elim_t (GUEId v))
= fun _ -> noop (); U.raise_val ()
let compute_gen_unit_elim_f_pure
(p: prop)
: Tot (gen_unit_elim_t (GUEPure p))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p);
elim_pure p;
U.raise_val ()
let compute_gen_unit_elim_f_star
(i1 i2: gen_unit_elim_i)
(f1: gen_unit_elim_t i1)
(f2: gen_unit_elim_t i2)
: Tot (gen_unit_elim_t (GUEStar i1 i2))
= fun _ ->
rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2);
let _ = f1 _ in
let _ = f2 _ in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2));
U.raise_val ()
let rec compute_gen_unit_elim_f
(i: gen_unit_elim_i)
: GTot (gen_unit_elim_t i)
= match i returns (gen_unit_elim_t i) with
| GUEId v -> compute_gen_unit_elim_f_id v
| GUEPure p -> compute_gen_unit_elim_f_pure p
| GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2)
let gen_elim_t (i: gen_elim_i) : Tot Type =
gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i)
let compute_gen_elim_f_unit
(i: gen_unit_elim_i)
: GTot (gen_elim_t (GEUnit i))
= compute_gen_unit_elim_f i
let compute_gen_elim_f_star_l
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_unit_elim_i)
: GTot (gen_elim_t (GEStarL i1 i2))
= let f2 = compute_gen_unit_elim_f i2 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2);
let res = f1 _ in
let _ = f2 _ in
let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res');
res'
let compute_gen_elim_f_star_r
(i1: gen_unit_elim_i)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStarR i1 i2))
= let f1 = compute_gen_unit_elim_f i1 in
fun _ ->
rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2);
let _ = f1 _ in
let res = f2 _ in
let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in
rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res');
res'
let compute_gen_elim_f_star
(i1: gen_elim_i)
(f1: gen_elim_t i1)
(i2: gen_elim_i)
(f2: gen_elim_t i2)
: GTot (gen_elim_t (GEStar i1 i2))
= fun _ ->
rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2);
let res1 = f1 _ in
let res2 = f2 _ in
let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in
rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res);
res
let compute_gen_elim_f_exists_no_abs0
(a: Type0)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs0 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res);
res
let rewrite_with_trefl (#opened:_) (p q:vprop)
: STGhost unit opened
p
(fun _ -> q)
(requires T.with_tactic T.trefl (p == q))
(ensures fun _ -> True)
= rewrite p q
let compute_gen_elim_f_exists_unit0
(a: Type0)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res);
res
let compute_gen_elim_f_exists0
(a: Type0)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists0 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res);
res
let compute_gen_elim_f_exists_no_abs1
(a: Type)
(body: (a -> vprop))
: GTot (gen_elim_t (GEExistsNoAbs1 body))
= fun _ ->
rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body);
let gres = elim_exists () in
let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res);
res
let compute_gen_elim_f_exists_unit1
(a: Type)
(body: a -> gen_unit_elim_i)
: Tot (gen_elim_t (GEExistsUnit1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let gres = elim_exists () in
let _ = compute_gen_unit_elim_f (body gres) _ in
let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in
rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res);
res
let compute_gen_elim_f_exists1
(a: Type)
(body: a -> gen_elim_i)
(f: (x: a) -> GTot (gen_elim_t (body x)))
: Tot (gen_elim_t (GEExists1 body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x)));
let gres1 = elim_exists () in
let gres2 = f gres1 _ in
let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in
rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res);
res
let rec compute_gen_elim_f
(i: gen_elim_i)
: GTot (gen_elim_t i)
= match i returns (gen_elim_t i) with
| GEUnit i -> compute_gen_elim_f_unit i
| GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2
| GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2)
| GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2)
| GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body
| GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body
| GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x))
| GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body
| GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body
| GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x))
let rec tele_p (x: gen_elim_tele) : Tot vprop =
match x with
| TRet v p -> v `star` pure p
| TExists ty body -> exists_ (fun x -> tele_p (body x))
let elim_exists' (#a:Type)
(#opened_invariants:_)
(#p:a -> vprop)
(_:unit)
: STGhostT (a) opened_invariants
(exists_ p)
(fun x -> p x)
= let gx = elim_exists () in
let x = Ghost.reveal gx in
rewrite (p gx) (p x);
x
let vprop_rewrite (from to: vprop) : Tot Type =
gen_elim_f from unit (fun _ -> to) (fun _ -> True)
let tele_star_vprop_correct_ret
(v': vprop) (p': prop) (v: vprop) (p: prop)
: Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p)))
= fun _ ->
elim_pure p;
rewrite (tele_p _) (v' `star` pure p');
elim_pure p';
intro_pure (p /\ p');
rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _)
let tele_star_vprop_correct_exists
(v: vprop) (p: prop)
(ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p))))
: Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p)))
= fun _ ->
rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p));
rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _)
let rec tele_star_vprop_correct
(i: gen_elim_tele) (v: vprop) (p: prop)
: GTot (vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p))
)
= match i returns vprop_rewrite
(tele_p i `star` v `star` pure p)
(tele_p (tele_star_vprop i v p)) with
| TRet v' p' -> tele_star_vprop_correct_ret v' p' v p
| TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p)
let tele_star_correct_ret_l
(v1: vprop) (p1: prop) (i2: gen_elim_tele)
: Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2)))
= fun _ ->
rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1);
tele_star_vprop_correct i2 v1 p1 _;
rewrite (tele_p _) (tele_p _)
let tele_star_correct_ret_r
(i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop)
: Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2)))
= fun _ ->
rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2);
tele_star_vprop_correct i1 v2 p2 _;
rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
let tele_star_correct_exists
(ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele)
(ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2))))
: Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
= fun _ ->
rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1)));
let x1 = elim_exists' () in
rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2)));
let x2 = elim_exists' () in
ih x1 x2 _;
intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)));
intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec tele_star_correct
(i1 i2: gen_elim_tele)
: GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)))
= match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with
| TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2
| TExists ty1 f1 ->
begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with
| TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2
| TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2))
end
[@@noextract_to "Plugin" ]
let ge_to_tele_t
(i: gen_elim_i)
: Tot Type
= vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i))
let compute_gen_elim_tele_correct_unit
(v: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEUnit v))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v);
let _ = compute_gen_unit_elim_f v _ in
intro_pure (compute_gen_unit_elim_post v);
rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _)
let compute_gen_elim_tele_correct_star_l
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(ru: gen_unit_elim_i)
: Tot (ge_to_tele_t (GEStarL l ru))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru);
ihl _;
let _ = compute_gen_unit_elim_f ru _ in
intro_pure (compute_gen_unit_elim_post ru);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star_r
(lu: gen_unit_elim_i)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStarR lu r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r);
ihr _;
let _ = compute_gen_unit_elim_f lu _ in
intro_pure (compute_gen_unit_elim_post lu);
tele_star_vprop_correct _ _ _ _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_star
(l: gen_elim_i)
(ihl: ge_to_tele_t l)
(r: gen_elim_i)
(ihr: ge_to_tele_t r)
: Tot (ge_to_tele_t (GEStar l r))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r);
ihl _;
ihr _;
tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _;
rewrite_with_trefl (tele_p _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs0
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
rewrite (body x) (body (U.downgrade_val (U.raise_val x)));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit0
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x))));
rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists0
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists0 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x)))));
intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x))));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_no_abs1
(ty: _)
(body: ty -> vprop)
: Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ body);
let x = elim_exists' () in
intro_pure True;
intro_exists x (fun x -> body x `star` pure True);
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists_unit1
(ty: _)
(body: ty -> gen_unit_elim_i)
: Tot (ge_to_tele_t (GEExistsUnit1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x)));
let x = elim_exists' () in
let _ = compute_gen_unit_elim_f (body x) _ in
intro_pure (compute_gen_unit_elim_post (body x));
intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let compute_gen_elim_tele_correct_exists1
(ty: _)
(body: ty -> gen_elim_i)
(ih: (x: ty) -> GTot (ge_to_tele_t (body x)))
: Tot (ge_to_tele_t (GEExists1 #ty body))
= fun _ ->
rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x)));
let x = elim_exists' () in
ih x _;
intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x)));
rewrite_with_trefl (exists_ _) (tele_p _)
let rec compute_gen_elim_tele_correct
(x: gen_elim_i)
: GTot (ge_to_tele_t x)
= match x returns ge_to_tele_t x with
| GEUnit v -> compute_gen_elim_tele_correct_unit v
| GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru
| GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r)
| GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r)
| GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body
| GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body
| GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x))
| GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body
| GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body
| GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x))
let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) =
match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with
| [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ()))
| t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))
let rec gen_elim_nondep_sem_correct
(ty: list (Type u#a))
: Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
= match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma
(tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post)
)
with
| [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ())))
| ta :: tq -> fun q post ->
let phi
(x: ta)
: Lemma
(tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x))
= gen_elim_nondep_sem_correct tq (q x) (post x)
in
Classical.forall_intro phi;
let prf () : Lemma
(exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)))
=
exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x))
in
assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))));
assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)));
prf ()
let compute_gen_elim_nondep_correct_t
(i0: gen_elim_i)
(ty: list (Type u#1))
: Tot Type
= (q: _) ->
(post: _) ->
(intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) ->
GTot (gen_elim_f
(compute_gen_elim_p i0)
(compute_gen_elim_nondep_a' ty)
(fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ()))
(fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ()))
)
let compute_gen_elim_nondep_correct0
(i0: gen_elim_i)
: Tot (compute_gen_elim_nondep_correct_t i0 [])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ())));
let res = U.raise_val () in
elim_pure _;
rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct1
(i0: gen_elim_i)
(t1: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ()))));
let res = elim_exists' () in
elim_pure _;
rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct2
(i0: gen_elim_i)
(t1 t2: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ())))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let res = Mktuple2 x1 x2 in
elim_pure _;
rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct3
(i0: gen_elim_i)
(t1 t2 t3: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ()))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let res = Mktuple3 x1 x2 x3 in
elim_pure _;
rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct4
(i0: gen_elim_i)
(t1 t2 t3 t4: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> q x1 x2 x3 x4 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 (U.raise_val ())))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let res = Mktuple4 x1 x2 x3 x4 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct5
(i0: gen_elim_i)
(t1 t2 t3 t4 t5: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> q x1 x2 x3 x4 x5 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 (U.raise_val ()))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let res = Mktuple5 x1 x2 x3 x4 x5 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct6
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> q x1 x2 x3 x4 x5 x6 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 (U.raise_val ())))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let res = Mktuple6 x1 x2 x3 x4 x5 x6 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct7
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> q x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 (U.raise_val ()))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let res = Mktuple7 x1 x2 x3 x4 x5 x6 x7 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct8
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> q x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 (U.raise_val ())))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let res = Mktuple8 x1 x2 x3 x4 x5 x6 x7 x8 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct9
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 (U.raise_val ()))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let res = Mktuple9 x1 x2 x3 x4 x5 x6 x7 x8 x9 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct10
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 (U.raise_val ())))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let res = Mktuple10 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct11
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 (U.raise_val ()))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let res = Mktuple11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct12
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 (U.raise_val ())))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let res = Mktuple12 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct13
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13: Type)
: Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13])
= fun q post intro _ ->
intro _;
rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> exists_ (fun x4 -> exists_ (fun x5 -> exists_ (fun x6 -> exists_ (fun x7 -> exists_ (fun x8 -> exists_ (fun x9 -> exists_ (fun x10 -> exists_ (fun x11 -> exists_ (fun x12 -> exists_ (fun x13 -> q x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()) `star` pure (post x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 (U.raise_val ()))))))))))))))));
let x1 = elim_exists' () in
let x2 = elim_exists' () in
let x3 = elim_exists' () in
let x4 = elim_exists' () in
let x5 = elim_exists' () in
let x6 = elim_exists' () in
let x7 = elim_exists' () in
let x8 = elim_exists' () in
let x9 = elim_exists' () in
let x10 = elim_exists' () in
let x11 = elim_exists' () in
let x12 = elim_exists' () in
let x13 = elim_exists' () in
let res = Mktuple13 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 in
elim_pure _;
rewrite_with_trefl (q _ _ _ _ _ _ _ _ _ _ _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ()));
res
let compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type) | false | false | Steel.ST.GenElim1.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val compute_gen_elim_nondep_correct14
(i0: gen_elim_i)
(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14: Type)
: Tot
(compute_gen_elim_nondep_correct_t i0
[t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14]) | [] | Steel.ST.GenElim1.compute_gen_elim_nondep_correct14 | {
"file_name": "lib/steel/Steel.ST.GenElim1.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
i0: Steel.ST.GenElim1.Base.gen_elim_i ->
t1: Type ->
t2: Type ->
t3: Type ->
t4: Type ->
t5: Type ->
t6: Type ->
t7: Type ->
t8: Type ->
t9: Type ->
t10: Type ->
t11: Type ->
t12: Type ->
t13: Type ->
t14: Type
-> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0
[t1; t2; t3; t4; t5; t6; t7; t8; t9; t10; t11; t12; t13; t14] | {
"end_col": 7,
"end_line": 757,
"start_col": 2,
"start_line": 737
} |
Prims.Tot | val op_String_Access (#a: Type) (s: seq a) (i: nat{i < length s}) : Tot a | [
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i | val op_String_Access (#a: Type) (s: seq a) (i: nat{i < length s}) : Tot a
let op_String_Access (#a: Type) (s: seq a) (i: nat{i < length s}) : Tot a = | false | null | false | index s i | {
"checked_file": "Vale.AES.AES_helpers_BE.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES_helpers_BE.fsti"
} | [
"total"
] | [
"FStar.Seq.Base.seq",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"FStar.Seq.Base.index"
] | [] | module Vale.AES.AES_helpers_BE
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_BE_s
open FStar.Mul
open Vale.Arch.Types
open Vale.Def.Words.Seq_s | false | false | Vale.AES.AES_helpers_BE.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_String_Access (#a: Type) (s: seq a) (i: nat{i < length s}) : Tot a | [] | Vale.AES.AES_helpers_BE.op_String_Access | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers_BE.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq a -> i: Prims.nat{i < FStar.Seq.Base.length s} -> a | {
"end_col": 79,
"end_line": 13,
"start_col": 70,
"start_line": 13
} |
Prims.Tot | val round_key_128 (prev: quad32) (round: nat) : quad32 | [
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let round_key_128 (prev:quad32) (round:nat) : quad32 =
round_key_128_rcon prev (aes_rcon (round - 1)) | val round_key_128 (prev: quad32) (round: nat) : quad32
let round_key_128 (prev: quad32) (round: nat) : quad32 = | false | null | false | round_key_128_rcon prev (aes_rcon (round - 1)) | {
"checked_file": "Vale.AES.AES_helpers_BE.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES_helpers_BE.fsti"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Prims.nat",
"Vale.AES.AES_helpers_BE.round_key_128_rcon",
"Vale.AES.AES_common_s.aes_rcon",
"Prims.op_Subtraction"
] | [] | module Vale.AES.AES_helpers_BE
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_BE_s
open FStar.Mul
open Vale.Arch.Types
open Vale.Def.Words.Seq_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor
unfold let be_quad32_to_seq (q:quad32) : seq nat32 = four_to_seq_BE q
let quad32_shr32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour v1 v2 v3 0
// Redefine key expansion in terms of quad32 values rather than nat32 values,
// then prove both definitions are equivalent.
let round_key_128_rcon (prev:quad32) (rcon:nat32) : quad32 =
let Mkfour v0 v1 v2 v3 = prev in
let w3 = v3 *^ (sub_word (rot_word v0) *^ rcon) in
let w2 = v2 *^ w3 in
let w1 = v1 *^ w2 in
let w0 = v0 *^ w1 in
Mkfour w0 w1 w2 w3 | false | true | Vale.AES.AES_helpers_BE.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val round_key_128 (prev: quad32) (round: nat) : quad32 | [] | Vale.AES.AES_helpers_BE.round_key_128 | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers_BE.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | prev: Vale.Def.Types_s.quad32 -> round: Prims.nat -> Vale.Def.Types_s.quad32 | {
"end_col": 48,
"end_line": 38,
"start_col": 2,
"start_line": 38
} |
Prims.Tot | val be_quad32_to_seq (q: quad32) : seq nat32 | [
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let be_quad32_to_seq (q:quad32) : seq nat32 = four_to_seq_BE q | val be_quad32_to_seq (q: quad32) : seq nat32
let be_quad32_to_seq (q: quad32) : seq nat32 = | false | null | false | four_to_seq_BE q | {
"checked_file": "Vale.AES.AES_helpers_BE.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES_helpers_BE.fsti"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Words.Seq_s.four_to_seq_BE",
"Vale.Def.Types_s.nat32",
"FStar.Seq.Base.seq"
] | [] | module Vale.AES.AES_helpers_BE
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_BE_s
open FStar.Mul
open Vale.Arch.Types
open Vale.Def.Words.Seq_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor | false | true | Vale.AES.AES_helpers_BE.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val be_quad32_to_seq (q: quad32) : seq nat32 | [] | Vale.AES.AES_helpers_BE.be_quad32_to_seq | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers_BE.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | q: Vale.Def.Types_s.quad32 -> FStar.Seq.Base.seq Vale.Def.Types_s.nat32 | {
"end_col": 69,
"end_line": 19,
"start_col": 53,
"start_line": 19
} |
Prims.Tot | val simd_round_key_128 (prev: quad32) (rcon: nat32) : quad32 | [
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let simd_round_key_128 (prev:quad32) (rcon:nat32) : quad32 =
let r = rot_word (sub_word prev.lo0 *^ ishl32 rcon 16) in
let q = prev in
let q = q *^^ quad32_shr32 q in
let q = q *^^ quad32_shr32 q in
let q = q *^^ quad32_shr32 q in
q *^^ Mkfour r r r r | val simd_round_key_128 (prev: quad32) (rcon: nat32) : quad32
let simd_round_key_128 (prev: quad32) (rcon: nat32) : quad32 = | false | null | false | let r = rot_word (sub_word prev.lo0 *^ ishl32 rcon 16) in
let q = prev in
let q = q *^^ quad32_shr32 q in
let q = q *^^ quad32_shr32 q in
let q = q *^^ quad32_shr32 q in
q *^^ Mkfour r r r r | {
"checked_file": "Vale.AES.AES_helpers_BE.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES_helpers_BE.fsti"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.nat32",
"Vale.AES.AES_helpers_BE.op_Star_Hat_Hat",
"Vale.Def.Words_s.Mkfour",
"Vale.AES.AES_helpers_BE.quad32_shr32",
"Vale.Def.Words_s.nat32",
"Vale.AES.AES_BE_s.rot_word",
"Vale.AES.AES_helpers_BE.op_Star_Hat",
"Vale.AES.AES_common_s.sub_word",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Arch.Types.ishl32"
] | [] | module Vale.AES.AES_helpers_BE
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_BE_s
open FStar.Mul
open Vale.Arch.Types
open Vale.Def.Words.Seq_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor
unfold let be_quad32_to_seq (q:quad32) : seq nat32 = four_to_seq_BE q
let quad32_shr32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour v1 v2 v3 0
// Redefine key expansion in terms of quad32 values rather than nat32 values,
// then prove both definitions are equivalent.
let round_key_128_rcon (prev:quad32) (rcon:nat32) : quad32 =
let Mkfour v0 v1 v2 v3 = prev in
let w3 = v3 *^ (sub_word (rot_word v0) *^ rcon) in
let w2 = v2 *^ w3 in
let w1 = v1 *^ w2 in
let w0 = v0 *^ w1 in
Mkfour w0 w1 w2 w3
let round_key_128 (prev:quad32) (round:nat) : quad32 =
round_key_128_rcon prev (aes_rcon (round - 1))
let rec expand_key_128_def (key:seq nat32) (round:nat) : Pure quad32
(requires is_aes_key_word AES_128 key)
(ensures fun _ -> True)
=
if round = 0 then Mkfour key.[3] key.[2] key.[1] key.[0]
else round_key_128 (expand_key_128_def key (round - 1)) round
[@"opaque_to_smt"] let expand_key_128 = opaque_make expand_key_128_def
irreducible let expand_key_128_reveal = opaque_revealer (`%expand_key_128) expand_key_128 expand_key_128_def
val lemma_expand_key_128_0 (key:aes_key_word AES_128) : Lemma
(equal key (expand_key AES_128 key 4))
val lemma_expand_key_128_i (key:aes_key_word AES_128) (i:nat) : Lemma
(requires
0 < i /\ i < 11
)
(ensures (
let m = 4 * (i - 1) in
let n = 4 * i in
let v = expand_key AES_128 key n in
let w = expand_key AES_128 key (n + 4) in
let prev = Mkfour v.[m + 3] v.[m + 2] v.[m + 1] v.[m + 0] in
round_key_128 prev i == Mkfour w.[n + 3] w.[n + 2] w.[n + 1] w.[n + 0]
))
// expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument
val lemma_expand_append (key:aes_key_word AES_128) (size1:nat) (size2:nat) : Lemma
(requires size1 <= size2 /\ size2 <= 44)
(ensures equal (expand_key AES_128 key size1) (slice (expand_key AES_128 key size2) 0 size1))
(decreases size2)
// quad32 key expansion is equivalent to nat32 key expansion
val lemma_expand_key_128 (key:seq nat32) (size:nat) : Lemma
(requires size <= 11 /\ is_aes_key_word AES_128 key)
(ensures (
let s = key_schedule_to_round_keys size (expand_key AES_128 key 44) in
(forall (i:nat).{:pattern (expand_key_128 key i) \/ (expand_key_128_def key i)}
i < size ==> expand_key_128 key i == s.[i])
)) | false | true | Vale.AES.AES_helpers_BE.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val simd_round_key_128 (prev: quad32) (rcon: nat32) : quad32 | [] | Vale.AES.AES_helpers_BE.simd_round_key_128 | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers_BE.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | prev: Vale.Def.Types_s.quad32 -> rcon: Vale.Def.Types_s.nat32 -> Vale.Def.Types_s.quad32 | {
"end_col": 22,
"end_line": 87,
"start_col": 60,
"start_line": 81
} |
Prims.Pure | [
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let expand_key_128 = opaque_make expand_key_128_def | let expand_key_128 = | false | null | false | opaque_make expand_key_128_def | {
"checked_file": "Vale.AES.AES_helpers_BE.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES_helpers_BE.fsti"
} | [] | [
"Vale.Def.Opaque_s.opaque_make",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Prims.nat",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_BE_s.is_aes_key_word",
"Vale.AES.AES_common_s.AES_128",
"Prims.l_True",
"Vale.AES.AES_helpers_BE.expand_key_128_def"
] | [] | module Vale.AES.AES_helpers_BE
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_BE_s
open FStar.Mul
open Vale.Arch.Types
open Vale.Def.Words.Seq_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor
unfold let be_quad32_to_seq (q:quad32) : seq nat32 = four_to_seq_BE q
let quad32_shr32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour v1 v2 v3 0
// Redefine key expansion in terms of quad32 values rather than nat32 values,
// then prove both definitions are equivalent.
let round_key_128_rcon (prev:quad32) (rcon:nat32) : quad32 =
let Mkfour v0 v1 v2 v3 = prev in
let w3 = v3 *^ (sub_word (rot_word v0) *^ rcon) in
let w2 = v2 *^ w3 in
let w1 = v1 *^ w2 in
let w0 = v0 *^ w1 in
Mkfour w0 w1 w2 w3
let round_key_128 (prev:quad32) (round:nat) : quad32 =
round_key_128_rcon prev (aes_rcon (round - 1))
let rec expand_key_128_def (key:seq nat32) (round:nat) : Pure quad32
(requires is_aes_key_word AES_128 key)
(ensures fun _ -> True)
=
if round = 0 then Mkfour key.[3] key.[2] key.[1] key.[0] | false | false | Vale.AES.AES_helpers_BE.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val expand_key_128 : key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> round: Prims.nat
-> Prims.Pure Vale.Def.Types_s.quad32 | [] | Vale.AES.AES_helpers_BE.expand_key_128 | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers_BE.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> round: Prims.nat
-> Prims.Pure Vale.Def.Types_s.quad32 | {
"end_col": 70,
"end_line": 46,
"start_col": 40,
"start_line": 46
} |
|
Prims.Tot | val round_key_128_rcon (prev: quad32) (rcon: nat32) : quad32 | [
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let round_key_128_rcon (prev:quad32) (rcon:nat32) : quad32 =
let Mkfour v0 v1 v2 v3 = prev in
let w3 = v3 *^ (sub_word (rot_word v0) *^ rcon) in
let w2 = v2 *^ w3 in
let w1 = v1 *^ w2 in
let w0 = v0 *^ w1 in
Mkfour w0 w1 w2 w3 | val round_key_128_rcon (prev: quad32) (rcon: nat32) : quad32
let round_key_128_rcon (prev: quad32) (rcon: nat32) : quad32 = | false | null | false | let Mkfour v0 v1 v2 v3 = prev in
let w3 = v3 *^ (sub_word (rot_word v0) *^ rcon) in
let w2 = v2 *^ w3 in
let w1 = v1 *^ w2 in
let w0 = v0 *^ w1 in
Mkfour w0 w1 w2 w3 | {
"checked_file": "Vale.AES.AES_helpers_BE.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES_helpers_BE.fsti"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Words_s.nat32",
"Vale.AES.AES_helpers_BE.op_Star_Hat",
"Vale.AES.AES_common_s.sub_word",
"Vale.AES.AES_BE_s.rot_word"
] | [] | module Vale.AES.AES_helpers_BE
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_BE_s
open FStar.Mul
open Vale.Arch.Types
open Vale.Def.Words.Seq_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor
unfold let be_quad32_to_seq (q:quad32) : seq nat32 = four_to_seq_BE q
let quad32_shr32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour v1 v2 v3 0
// Redefine key expansion in terms of quad32 values rather than nat32 values,
// then prove both definitions are equivalent. | false | true | Vale.AES.AES_helpers_BE.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val round_key_128_rcon (prev: quad32) (rcon: nat32) : quad32 | [] | Vale.AES.AES_helpers_BE.round_key_128_rcon | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers_BE.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | prev: Vale.Def.Types_s.quad32 -> rcon: Vale.Def.Types_s.nat32 -> Vale.Def.Types_s.quad32 | {
"end_col": 20,
"end_line": 35,
"start_col": 60,
"start_line": 29
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.