effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | val t_as_list:list uint32 | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 t_as_list : list uint32 = [
u32 0xd76aa478;
u32 0xe8c7b756;
u32 0x242070db;
u32 0xc1bdceee;
u32 0xf57c0faf;
u32 0x4787c62a;
u32 0xa8304613;
u32 0xfd469501;
u32 0x698098d8;
u32 0x8b44f7af;
u32 0xffff5bb1;
u32 0x895cd7be;
u32 0x6b901122;
u32 0xfd987193;
u32 0xa679438e;
u32 0x49b40821;
u32 0xf61e2562;
u32 0xc040b340;
u32 0x265e5a51;
u32 0xe9b6c7aa;
u32 0xd62f105d;
u32 0x02441453;
u32 0xd8a1e681;
u32 0xe7d3fbc8;
u32 0x21e1cde6;
u32 0xc33707d6;
u32 0xf4d50d87;
u32 0x455a14ed;
u32 0xa9e3e905;
u32 0xfcefa3f8;
u32 0x676f02d9;
u32 0x8d2a4c8a;
u32 0xfffa3942;
u32 0x8771f681;
u32 0x6d9d6122;
u32 0xfde5380c;
u32 0xa4beea44;
u32 0x4bdecfa9;
u32 0xf6bb4b60;
u32 0xbebfbc70;
u32 0x289b7ec6;
u32 0xeaa127fa;
u32 0xd4ef3085;
u32 0x4881d05;
u32 0xd9d4d039;
u32 0xe6db99e5;
u32 0x1fa27cf8;
u32 0xc4ac5665;
u32 0xf4292244;
u32 0x432aff97;
u32 0xab9423a7;
u32 0xfc93a039;
u32 0x655b59c3;
u32 0x8f0ccc92;
u32 0xffeff47d;
u32 0x85845dd1;
u32 0x6fa87e4f;
u32 0xfe2ce6e0;
u32 0xa3014314;
u32 0x4e0811a1;
u32 0xf7537e82;
u32 0xbd3af235;
u32 0x2ad7d2bb;
u32 0xeb86d391;
] | val t_as_list:list uint32
let t_as_list:list uint32 = | false | null | false | [
u32 0xd76aa478; u32 0xe8c7b756; u32 0x242070db; u32 0xc1bdceee; u32 0xf57c0faf; u32 0x4787c62a;
u32 0xa8304613; u32 0xfd469501; u32 0x698098d8; u32 0x8b44f7af; u32 0xffff5bb1; u32 0x895cd7be;
u32 0x6b901122; u32 0xfd987193; u32 0xa679438e; u32 0x49b40821; u32 0xf61e2562; u32 0xc040b340;
u32 0x265e5a51; u32 0xe9b6c7aa; u32 0xd62f105d; u32 0x02441453; u32 0xd8a1e681; u32 0xe7d3fbc8;
u32 0x21e1cde6; u32 0xc33707d6; u32 0xf4d50d87; u32 0x455a14ed; u32 0xa9e3e905; u32 0xfcefa3f8;
u32 0x676f02d9; u32 0x8d2a4c8a; u32 0xfffa3942; u32 0x8771f681; u32 0x6d9d6122; u32 0xfde5380c;
u32 0xa4beea44; u32 0x4bdecfa9; u32 0xf6bb4b60; u32 0xbebfbc70; u32 0x289b7ec6; u32 0xeaa127fa;
u32 0xd4ef3085; u32 0x4881d05; u32 0xd9d4d039; u32 0xe6db99e5; u32 0x1fa27cf8; u32 0xc4ac5665;
u32 0xf4292244; u32 0x432aff97; u32 0xab9423a7; u32 0xfc93a039; u32 0x655b59c3; u32 0x8f0ccc92;
u32 0xffeff47d; u32 0x85845dd1; u32 0x6fa87e4f; u32 0xfe2ce6e0; u32 0xa3014314; u32 0x4e0811a1;
u32 0xf7537e82; u32 0xbd3af235; u32 0x2ad7d2bb; u32 0xeb86d391
] | {
"checked_file": "Spec.MD5.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Spec.MD5.fst"
} | [
"total"
] | [
"Prims.Cons",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Lib.IntTypes.u32",
"Prims.Nil"
] | [] | module Spec.MD5
(* Source: https://tools.ietf.org/html/rfc1321 *)
open Lib.IntTypes
open Spec.Hash.Definitions
(* Section 3.3 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
]
let init : words_state MD5 = Seq.seq_of_list init_as_list
(* Section 3.4 *)
inline_for_extraction
let f (x y z: uint32) : Tot uint32 =
(x &. y) |. ((~. x) &. z)
inline_for_extraction
let g (x y z: uint32) : Tot uint32 =
(x &. z) |. (y &. (~. z))
inline_for_extraction
let h (x y z: uint32) : Tot uint32 =
x ^. y ^. z
inline_for_extraction
let i (x y z: uint32) : Tot uint32 =
y ^. (x |. ~. z)
(* Table T: specified in 3.4, defined in Appendix A.3, function MD5Transform *) | false | true | Spec.MD5.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val t_as_list:list uint32 | [] | Spec.MD5.t_as_list | {
"file_name": "specs/Spec.MD5.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.SEC) | {
"end_col": 1,
"end_line": 109,
"start_col": 30,
"start_line": 41
} |
Prims.Tot | val init: init_t MD5 | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"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 init : words_state MD5 = Seq.seq_of_list init_as_list | val init: init_t MD5
let init:words_state MD5 = | false | null | false | Seq.seq_of_list init_as_list | {
"checked_file": "Spec.MD5.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Spec.MD5.fst"
} | [
"total"
] | [
"FStar.Seq.Properties.seq_of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Spec.MD5.init_as_list",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Definitions.MD5"
] | [] | module Spec.MD5
(* Source: https://tools.ietf.org/html/rfc1321 *)
open Lib.IntTypes
open Spec.Hash.Definitions
(* Section 3.3 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
] | false | true | Spec.MD5.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val init: init_t MD5 | [] | Spec.MD5.init | {
"file_name": "specs/Spec.MD5.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.Hash.Definitions.init_t Spec.Hash.Definitions.MD5 | {
"end_col": 57,
"end_line": 18,
"start_col": 29,
"start_line": 18
} |
Prims.GTot | val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let free_stack64 start finish h = BS.free_stack' start finish h | val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
let free_stack64 start finish h = | false | null | false | BS.free_stack' start finish h | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.X64.Stack_i.vale_stack",
"Vale.X64.Machine_Semantics_s.free_stack'"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack | [] | Vale.X64.Stack_i.free_stack64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | start: Prims.int -> finish: Prims.int -> h: Vale.X64.Stack_i.vale_stack
-> Prims.GTot Vale.X64.Stack_i.vale_stack | {
"end_col": 63,
"end_line": 11,
"start_col": 34,
"start_line": 11
} |
Prims.GTot | val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let load_stack64 i st = BS.eval_stack i st | val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64
let load_stack64 i st = | false | null | false | BS.eval_stack i st | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.X64.Stack_i.vale_stack",
"Vale.X64.Machine_Semantics_s.eval_stack",
"Vale.X64.Memory.nat64"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 | [] | Vale.X64.Stack_i.load_stack64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> h: Vale.X64.Stack_i.vale_stack -> Prims.GTot Vale.X64.Memory.nat64 | {
"end_col": 42,
"end_line": 9,
"start_col": 24,
"start_line": 9
} |
Prims.Tot | val vale_stack : Type u#0 | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let vale_stack = BS.machine_stack | val vale_stack : Type u#0
let vale_stack = | false | null | false | BS.machine_stack | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"total"
] | [
"Vale.X64.Machine_Semantics_s.machine_stack"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s | false | true | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val vale_stack : Type u#0 | [] | Vale.X64.Stack_i.vale_stack | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 33,
"end_line": 6,
"start_col": 17,
"start_line": 6
} |
Prims.GTot | val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_src_stack64 i st = BS.valid_src_stack64 i st | val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool
let valid_src_stack64 i st = | false | null | false | BS.valid_src_stack64 i st | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.X64.Stack_i.vale_stack",
"Vale.X64.Machine_Semantics_s.valid_src_stack64",
"Prims.bool"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool | [] | Vale.X64.Stack_i.valid_src_stack64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> h: Vale.X64.Stack_i.vale_stack -> Prims.GTot Prims.bool | {
"end_col": 54,
"end_line": 8,
"start_col": 29,
"start_line": 8
} |
Prims.GTot | val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_taint_stack128 ptr t stackTaint =
valid_taint_stack64 ptr t stackTaint /\ valid_taint_stack64 (ptr + 8) t stackTaint | val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
let valid_taint_stack128 ptr t stackTaint = | false | null | false | valid_taint_stack64 ptr t stackTaint /\ valid_taint_stack64 (ptr + 8) t stackTaint | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.Arch.HeapTypes_s.taint",
"Vale.X64.Memory.memtaint",
"Prims.l_and",
"Vale.X64.Stack_i.valid_taint_stack64",
"Prims.op_Addition",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st
let load_stack128 i st = BS.eval_stack128 i st
let store_stack128 i v h = BS.update_stack128' i v h
let init_rsp h = h.BS.initial_rsp
(* Lemmas *)
#push-options "--z3rlimit 40"
let lemma_store_stack_same_valid64 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let lemma_free_stack_same_valid64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish)
let lemma_store_new_valid64 ptr v h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
#pop-options
let lemma_correct_store_load_stack64 ptr v h =
let BS.Machine_stack _ mem = h in
correct_update_get64 ptr v mem
let lemma_frame_store_load_stack64 ptr v h i =
let BS.Machine_stack _ mem = h in
frame_update_heap64 ptr v mem;
BS.get_heap_val64_reveal ()
let lemma_free_stack_same_load64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish);
BS.get_heap_val64_reveal ()
let lemma_compose_free_stack64 start inter finish h =
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
let map_restr = Map.restrict (Vale.Lib.Set.remove_between domain start inter) mem in
let restrict = Map.domain map_restr in
let BS.Machine_stack _ mem1 = free_stack64 inter finish (free_stack64 start inter h) in
let BS.Machine_stack _ mem2 = free_stack64 start finish h in
let aux (i:int) : Lemma (Map.contains mem1 i = Map.contains mem2 i /\ Map.sel mem1 i = Map.sel mem2 i)
= Vale.Lib.Set.remove_between_reveal domain start inter i;
Vale.Lib.Set.remove_between_reveal restrict inter finish i;
Vale.Lib.Set.remove_between_reveal domain start finish i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start inter) mem i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between restrict inter finish) map_restr i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start finish) mem i
in Classical.forall_intro aux;
assert (Map.equal mem1 mem2)
let lemma_same_init_rsp_free_stack64 start finish h = ()
let lemma_same_init_rsp_store_stack64 ptr v h = ()
let valid_taint_stack64 ptr t stackTaint =
Map.sel stackTaint ptr = t &&
Map.sel stackTaint (ptr + 1) = t &&
Map.sel stackTaint (ptr + 2) = t &&
Map.sel stackTaint (ptr + 3) = t &&
Map.sel stackTaint (ptr + 4) = t &&
Map.sel stackTaint (ptr + 5) = t &&
Map.sel stackTaint (ptr + 6) = t &&
Map.sel stackTaint (ptr + 7) = t | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 | [] | Vale.X64.Stack_i.valid_taint_stack128 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> t: Vale.Arch.HeapTypes_s.taint -> stackTaint: Vale.X64.Memory.memtaint
-> Prims.GTot Vale.Def.Prop_s.prop0 | {
"end_col": 84,
"end_line": 84,
"start_col": 2,
"start_line": 84
} |
Prims.Tot | val init_rsp (h:vale_stack) : (n:nat64{n >= 4096}) | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let init_rsp h = h.BS.initial_rsp | val init_rsp (h:vale_stack) : (n:nat64{n >= 4096})
let init_rsp h = | false | null | false | h.BS.initial_rsp | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"total"
] | [
"Vale.X64.Stack_i.vale_stack",
"Vale.X64.Machine_Semantics_s.__proj__Machine_stack__item__initial_rsp",
"Vale.X64.Memory.nat64",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st
let load_stack128 i st = BS.eval_stack128 i st
let store_stack128 i v h = BS.update_stack128' i v h | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val init_rsp (h:vale_stack) : (n:nat64{n >= 4096}) | [] | Vale.X64.Stack_i.init_rsp | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: Vale.X64.Stack_i.vale_stack -> n: Vale.X64.Memory.nat64{n >= 4096} | {
"end_col": 33,
"end_line": 17,
"start_col": 17,
"start_line": 17
} |
Prims.GTot | val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let load_stack128 i st = BS.eval_stack128 i st | val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32
let load_stack128 i st = | false | null | false | BS.eval_stack128 i st | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.X64.Stack_i.vale_stack",
"Vale.X64.Machine_Semantics_s.eval_stack128",
"Vale.X64.Memory.quad32"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 | [] | Vale.X64.Stack_i.load_stack128 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> h: Vale.X64.Stack_i.vale_stack -> Prims.GTot Vale.X64.Memory.quad32 | {
"end_col": 46,
"end_line": 14,
"start_col": 25,
"start_line": 14
} |
Prims.GTot | val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let store_stack64 i v h = BS.update_stack64' i v h | val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack
let store_stack64 i v h = | false | null | false | BS.update_stack64' i v h | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.X64.Memory.nat64",
"Vale.X64.Stack_i.vale_stack",
"Vale.X64.Machine_Semantics_s.update_stack64'"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack | [] | Vale.X64.Stack_i.store_stack64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> v: Vale.X64.Memory.nat64 -> h: Vale.X64.Stack_i.vale_stack
-> Prims.GTot Vale.X64.Stack_i.vale_stack | {
"end_col": 50,
"end_line": 10,
"start_col": 26,
"start_line": 10
} |
Prims.GTot | val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_src_stack128 i st = BS.valid_src_stack128 i st | val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool
let valid_src_stack128 i st = | false | null | false | BS.valid_src_stack128 i st | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.X64.Stack_i.vale_stack",
"Vale.X64.Machine_Semantics_s.valid_src_stack128",
"Prims.bool"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool | [] | Vale.X64.Stack_i.valid_src_stack128 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> h: Vale.X64.Stack_i.vale_stack -> Prims.GTot Prims.bool | {
"end_col": 56,
"end_line": 13,
"start_col": 30,
"start_line": 13
} |
Prims.GTot | val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let store_taint_stack64 ptr t stackTaint = BS.update_n ptr 8 stackTaint t | val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint
let store_taint_stack64 ptr t stackTaint = | false | null | false | BS.update_n ptr 8 stackTaint t | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.Arch.HeapTypes_s.taint",
"Vale.X64.Memory.memtaint",
"Vale.X64.Machine_Semantics_s.update_n"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st
let load_stack128 i st = BS.eval_stack128 i st
let store_stack128 i v h = BS.update_stack128' i v h
let init_rsp h = h.BS.initial_rsp
(* Lemmas *)
#push-options "--z3rlimit 40"
let lemma_store_stack_same_valid64 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let lemma_free_stack_same_valid64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish)
let lemma_store_new_valid64 ptr v h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
#pop-options
let lemma_correct_store_load_stack64 ptr v h =
let BS.Machine_stack _ mem = h in
correct_update_get64 ptr v mem
let lemma_frame_store_load_stack64 ptr v h i =
let BS.Machine_stack _ mem = h in
frame_update_heap64 ptr v mem;
BS.get_heap_val64_reveal ()
let lemma_free_stack_same_load64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish);
BS.get_heap_val64_reveal ()
let lemma_compose_free_stack64 start inter finish h =
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
let map_restr = Map.restrict (Vale.Lib.Set.remove_between domain start inter) mem in
let restrict = Map.domain map_restr in
let BS.Machine_stack _ mem1 = free_stack64 inter finish (free_stack64 start inter h) in
let BS.Machine_stack _ mem2 = free_stack64 start finish h in
let aux (i:int) : Lemma (Map.contains mem1 i = Map.contains mem2 i /\ Map.sel mem1 i = Map.sel mem2 i)
= Vale.Lib.Set.remove_between_reveal domain start inter i;
Vale.Lib.Set.remove_between_reveal restrict inter finish i;
Vale.Lib.Set.remove_between_reveal domain start finish i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start inter) mem i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between restrict inter finish) map_restr i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start finish) mem i
in Classical.forall_intro aux;
assert (Map.equal mem1 mem2)
let lemma_same_init_rsp_free_stack64 start finish h = ()
let lemma_same_init_rsp_store_stack64 ptr v h = ()
let valid_taint_stack64 ptr t stackTaint =
Map.sel stackTaint ptr = t &&
Map.sel stackTaint (ptr + 1) = t &&
Map.sel stackTaint (ptr + 2) = t &&
Map.sel stackTaint (ptr + 3) = t &&
Map.sel stackTaint (ptr + 4) = t &&
Map.sel stackTaint (ptr + 5) = t &&
Map.sel stackTaint (ptr + 6) = t &&
Map.sel stackTaint (ptr + 7) = t
let valid_taint_stack128 ptr t stackTaint =
valid_taint_stack64 ptr t stackTaint /\ valid_taint_stack64 (ptr + 8) t stackTaint | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint | [] | Vale.X64.Stack_i.store_taint_stack64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> t: Vale.Arch.HeapTypes_s.taint -> stackTaint: Vale.X64.Memory.memtaint
-> Prims.GTot Vale.X64.Memory.memtaint | {
"end_col": 73,
"end_line": 86,
"start_col": 43,
"start_line": 86
} |
Prims.GTot | val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let store_stack128 i v h = BS.update_stack128' i v h | val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack
let store_stack128 i v h = | false | null | false | BS.update_stack128' i v h | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.X64.Memory.quad32",
"Vale.X64.Stack_i.vale_stack",
"Vale.X64.Machine_Semantics_s.update_stack128'"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack | [] | Vale.X64.Stack_i.store_stack128 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> v: Vale.X64.Memory.quad32 -> h: Vale.X64.Stack_i.vale_stack
-> Prims.GTot Vale.X64.Stack_i.vale_stack | {
"end_col": 52,
"end_line": 15,
"start_col": 27,
"start_line": 15
} |
Prims.GTot | val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_taint_stack64 ptr t stackTaint =
Map.sel stackTaint ptr = t &&
Map.sel stackTaint (ptr + 1) = t &&
Map.sel stackTaint (ptr + 2) = t &&
Map.sel stackTaint (ptr + 3) = t &&
Map.sel stackTaint (ptr + 4) = t &&
Map.sel stackTaint (ptr + 5) = t &&
Map.sel stackTaint (ptr + 6) = t &&
Map.sel stackTaint (ptr + 7) = t | val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
let valid_taint_stack64 ptr t stackTaint = | false | null | false | Map.sel stackTaint ptr = t && Map.sel stackTaint (ptr + 1) = t && Map.sel stackTaint (ptr + 2) = t &&
Map.sel stackTaint (ptr + 3) = t &&
Map.sel stackTaint (ptr + 4) = t &&
Map.sel stackTaint (ptr + 5) = t &&
Map.sel stackTaint (ptr + 6) = t &&
Map.sel stackTaint (ptr + 7) = t | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.Arch.HeapTypes_s.taint",
"Vale.X64.Memory.memtaint",
"Prims.b2t",
"Prims.op_AmpAmp",
"Prims.op_Equality",
"FStar.Map.sel",
"Prims.op_Addition",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st
let load_stack128 i st = BS.eval_stack128 i st
let store_stack128 i v h = BS.update_stack128' i v h
let init_rsp h = h.BS.initial_rsp
(* Lemmas *)
#push-options "--z3rlimit 40"
let lemma_store_stack_same_valid64 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let lemma_free_stack_same_valid64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish)
let lemma_store_new_valid64 ptr v h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
#pop-options
let lemma_correct_store_load_stack64 ptr v h =
let BS.Machine_stack _ mem = h in
correct_update_get64 ptr v mem
let lemma_frame_store_load_stack64 ptr v h i =
let BS.Machine_stack _ mem = h in
frame_update_heap64 ptr v mem;
BS.get_heap_val64_reveal ()
let lemma_free_stack_same_load64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish);
BS.get_heap_val64_reveal ()
let lemma_compose_free_stack64 start inter finish h =
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
let map_restr = Map.restrict (Vale.Lib.Set.remove_between domain start inter) mem in
let restrict = Map.domain map_restr in
let BS.Machine_stack _ mem1 = free_stack64 inter finish (free_stack64 start inter h) in
let BS.Machine_stack _ mem2 = free_stack64 start finish h in
let aux (i:int) : Lemma (Map.contains mem1 i = Map.contains mem2 i /\ Map.sel mem1 i = Map.sel mem2 i)
= Vale.Lib.Set.remove_between_reveal domain start inter i;
Vale.Lib.Set.remove_between_reveal restrict inter finish i;
Vale.Lib.Set.remove_between_reveal domain start finish i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start inter) mem i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between restrict inter finish) map_restr i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start finish) mem i
in Classical.forall_intro aux;
assert (Map.equal mem1 mem2)
let lemma_same_init_rsp_free_stack64 start finish h = ()
let lemma_same_init_rsp_store_stack64 ptr v h = () | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 | [] | Vale.X64.Stack_i.valid_taint_stack64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> t: Vale.Arch.HeapTypes_s.taint -> stackTaint: Vale.X64.Memory.memtaint
-> Prims.GTot Vale.Def.Prop_s.prop0 | {
"end_col": 34,
"end_line": 81,
"start_col": 2,
"start_line": 74
} |
FStar.Pervasives.Lemma | val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(load_stack64 ptr (store_stack64 ptr v h) == v)
[SMTPat (load_stack64 ptr (store_stack64 ptr v h))] | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_correct_store_load_stack64 ptr v h =
let BS.Machine_stack _ mem = h in
correct_update_get64 ptr v mem | val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(load_stack64 ptr (store_stack64 ptr v h) == v)
[SMTPat (load_stack64 ptr (store_stack64 ptr v h))]
let lemma_correct_store_load_stack64 ptr v h = | false | null | true | let BS.Machine_stack _ mem = h in
correct_update_get64 ptr v mem | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"lemma"
] | [
"Prims.int",
"Vale.X64.Memory.nat64",
"Vale.X64.Stack_i.vale_stack",
"Vale.Def.Types_s.nat64",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.Map.t",
"Vale.Def.Types_s.nat8",
"Vale.Arch.MachineHeap.correct_update_get64",
"Prims.unit"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st
let load_stack128 i st = BS.eval_stack128 i st
let store_stack128 i v h = BS.update_stack128' i v h
let init_rsp h = h.BS.initial_rsp
(* Lemmas *)
#push-options "--z3rlimit 40"
let lemma_store_stack_same_valid64 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let lemma_free_stack_same_valid64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish)
let lemma_store_new_valid64 ptr v h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
#pop-options | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(load_stack64 ptr (store_stack64 ptr v h) == v)
[SMTPat (load_stack64 ptr (store_stack64 ptr v h))] | [] | Vale.X64.Stack_i.lemma_correct_store_load_stack64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> v: Vale.X64.Memory.nat64 -> h: Vale.X64.Stack_i.vale_stack
-> FStar.Pervasives.Lemma
(ensures Vale.X64.Stack_i.load_stack64 ptr (Vale.X64.Stack_i.store_stack64 ptr v h) == v)
[SMTPat (Vale.X64.Stack_i.load_stack64 ptr (Vale.X64.Stack_i.store_stack64 ptr v h))] | {
"end_col": 32,
"end_line": 38,
"start_col": 46,
"start_line": 36
} |
FStar.Pervasives.Lemma | val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures valid_src_stack64 ptr (free_stack64 start finish h))
[SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))] | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_free_stack_same_valid64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) | val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures valid_src_stack64 ptr (free_stack64 start finish h))
[SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))]
let lemma_free_stack_same_valid64 start finish ptr h = | false | null | true | reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"lemma"
] | [
"Prims.int",
"Vale.X64.Stack_i.vale_stack",
"Vale.Def.Types_s.nat64",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.Map.t",
"Vale.Def.Types_s.nat8",
"FStar.Classical.forall_intro",
"Prims.l_and",
"Prims.l_imp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Negation",
"FStar.Set.mem",
"Vale.Lib.Set.remove_between",
"Prims.l_or",
"Prims.op_Equality",
"Prims.bool",
"Vale.Lib.Set.remove_between_reveal",
"FStar.Set.set",
"FStar.Map.domain",
"Prims.unit",
"FStar.Pervasives.reveal_opaque",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Arch.MachineHeap_s.valid_addr64"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st
let load_stack128 i st = BS.eval_stack128 i st
let store_stack128 i v h = BS.update_stack128' i v h
let init_rsp h = h.BS.initial_rsp
(* Lemmas *)
#push-options "--z3rlimit 40"
let lemma_store_stack_same_valid64 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal () | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures valid_src_stack64 ptr (free_stack64 start finish h))
[SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))] | [] | Vale.X64.Stack_i.lemma_free_stack_same_valid64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | start: Prims.int -> finish: Prims.int -> ptr: Prims.int -> h: Vale.X64.Stack_i.vale_stack
-> FStar.Pervasives.Lemma
(requires Vale.X64.Stack_i.valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start))
(ensures Vale.X64.Stack_i.valid_src_stack64 ptr (Vale.X64.Stack_i.free_stack64 start finish h)
)
[
SMTPat (Vale.X64.Stack_i.valid_src_stack64 ptr
(Vale.X64.Stack_i.free_stack64 start finish h))
] | {
"end_col": 81,
"end_line": 29,
"start_col": 2,
"start_line": 26
} |
FStar.Pervasives.Lemma | val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h))
[SMTPat (load_stack64 i (store_stack64 ptr v h))] | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_frame_store_load_stack64 ptr v h i =
let BS.Machine_stack _ mem = h in
frame_update_heap64 ptr v mem;
BS.get_heap_val64_reveal () | val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h))
[SMTPat (load_stack64 i (store_stack64 ptr v h))]
let lemma_frame_store_load_stack64 ptr v h i = | false | null | true | let BS.Machine_stack _ mem = h in
frame_update_heap64 ptr v mem;
BS.get_heap_val64_reveal () | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"lemma"
] | [
"Prims.int",
"Vale.X64.Memory.nat64",
"Vale.X64.Stack_i.vale_stack",
"Vale.Def.Types_s.nat64",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.Map.t",
"Vale.Def.Types_s.nat8",
"Vale.Arch.MachineHeap_s.get_heap_val64_reveal",
"Prims.unit",
"Vale.Arch.MachineHeap.frame_update_heap64"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st
let load_stack128 i st = BS.eval_stack128 i st
let store_stack128 i v h = BS.update_stack128' i v h
let init_rsp h = h.BS.initial_rsp
(* Lemmas *)
#push-options "--z3rlimit 40"
let lemma_store_stack_same_valid64 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let lemma_free_stack_same_valid64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish)
let lemma_store_new_valid64 ptr v h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
#pop-options
let lemma_correct_store_load_stack64 ptr v h =
let BS.Machine_stack _ mem = h in
correct_update_get64 ptr v mem | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h))
[SMTPat (load_stack64 i (store_stack64 ptr v h))] | [] | Vale.X64.Stack_i.lemma_frame_store_load_stack64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> v: Vale.X64.Memory.nat64 -> h: Vale.X64.Stack_i.vale_stack -> i: Prims.int
-> FStar.Pervasives.Lemma
(requires Vale.X64.Stack_i.valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr))
(ensures
Vale.X64.Stack_i.load_stack64 i (Vale.X64.Stack_i.store_stack64 ptr v h) ==
Vale.X64.Stack_i.load_stack64 i h)
[SMTPat (Vale.X64.Stack_i.load_stack64 i (Vale.X64.Stack_i.store_stack64 ptr v h))] | {
"end_col": 29,
"end_line": 43,
"start_col": 46,
"start_line": 40
} |
FStar.Pervasives.Lemma | val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h))
[SMTPat (load_stack64 ptr (free_stack64 start finish h))] | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_free_stack_same_load64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish);
BS.get_heap_val64_reveal () | val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h))
[SMTPat (load_stack64 ptr (free_stack64 start finish h))]
let lemma_free_stack_same_load64 start finish ptr h = | false | null | true | reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish);
BS.get_heap_val64_reveal () | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"lemma"
] | [
"Prims.int",
"Vale.X64.Stack_i.vale_stack",
"Vale.Def.Types_s.nat64",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.Map.t",
"Vale.Def.Types_s.nat8",
"Vale.Arch.MachineHeap_s.get_heap_val64_reveal",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.l_and",
"Prims.l_imp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Negation",
"FStar.Set.mem",
"Vale.Lib.Set.remove_between",
"Prims.l_or",
"Prims.op_Equality",
"Prims.bool",
"Vale.Lib.Set.remove_between_reveal",
"FStar.Set.set",
"FStar.Map.domain",
"FStar.Pervasives.reveal_opaque",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Arch.MachineHeap_s.valid_addr64"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st
let load_stack128 i st = BS.eval_stack128 i st
let store_stack128 i v h = BS.update_stack128' i v h
let init_rsp h = h.BS.initial_rsp
(* Lemmas *)
#push-options "--z3rlimit 40"
let lemma_store_stack_same_valid64 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let lemma_free_stack_same_valid64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish)
let lemma_store_new_valid64 ptr v h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
#pop-options
let lemma_correct_store_load_stack64 ptr v h =
let BS.Machine_stack _ mem = h in
correct_update_get64 ptr v mem
let lemma_frame_store_load_stack64 ptr v h i =
let BS.Machine_stack _ mem = h in
frame_update_heap64 ptr v mem;
BS.get_heap_val64_reveal () | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h))
[SMTPat (load_stack64 ptr (free_stack64 start finish h))] | [] | Vale.X64.Stack_i.lemma_free_stack_same_load64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | start: Prims.int -> finish: Prims.int -> ptr: Prims.int -> h: Vale.X64.Stack_i.vale_stack
-> FStar.Pervasives.Lemma
(requires Vale.X64.Stack_i.valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start))
(ensures
Vale.X64.Stack_i.load_stack64 ptr h ==
Vale.X64.Stack_i.load_stack64 ptr (Vale.X64.Stack_i.free_stack64 start finish h))
[SMTPat (Vale.X64.Stack_i.load_stack64 ptr (Vale.X64.Stack_i.free_stack64 start finish h))] | {
"end_col": 29,
"end_line": 50,
"start_col": 2,
"start_line": 46
} |
FStar.Pervasives.Lemma | val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures valid_src_stack64 i (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 i (store_stack64 ptr v h))] | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_store_stack_same_valid64 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal () | val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures valid_src_stack64 i (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 i (store_stack64 ptr v h))]
let lemma_store_stack_same_valid64 ptr v h i = | false | null | true | reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal () | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"lemma"
] | [
"Prims.int",
"Vale.X64.Memory.nat64",
"Vale.X64.Stack_i.vale_stack",
"Vale.Arch.MachineHeap_s.update_heap64_reveal",
"Prims.unit",
"FStar.Pervasives.reveal_opaque",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.bool",
"Vale.Arch.MachineHeap_s.valid_addr64"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st
let load_stack128 i st = BS.eval_stack128 i st
let store_stack128 i v h = BS.update_stack128' i v h
let init_rsp h = h.BS.initial_rsp
(* Lemmas *)
#push-options "--z3rlimit 40" | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures valid_src_stack64 i (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 i (store_stack64 ptr v h))] | [] | Vale.X64.Stack_i.lemma_store_stack_same_valid64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> v: Vale.X64.Memory.nat64 -> h: Vale.X64.Stack_i.vale_stack -> i: Prims.int
-> FStar.Pervasives.Lemma
(requires Vale.X64.Stack_i.valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr))
(ensures Vale.X64.Stack_i.valid_src_stack64 i (Vale.X64.Stack_i.store_stack64 ptr v h))
[SMTPat (Vale.X64.Stack_i.valid_src_stack64 i (Vale.X64.Stack_i.store_stack64 ptr v h))] | {
"end_col": 28,
"end_line": 23,
"start_col": 2,
"start_line": 22
} |
FStar.Pervasives.Lemma | val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(valid_src_stack64 ptr (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))] | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_store_new_valid64 ptr v h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal () | val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(valid_src_stack64 ptr (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))]
let lemma_store_new_valid64 ptr v h = | false | null | true | reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal () | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"lemma"
] | [
"Prims.int",
"Vale.X64.Memory.nat64",
"Vale.X64.Stack_i.vale_stack",
"Vale.Arch.MachineHeap_s.update_heap64_reveal",
"Prims.unit",
"FStar.Pervasives.reveal_opaque",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.bool",
"Vale.Arch.MachineHeap_s.valid_addr64"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st
let load_stack128 i st = BS.eval_stack128 i st
let store_stack128 i v h = BS.update_stack128' i v h
let init_rsp h = h.BS.initial_rsp
(* Lemmas *)
#push-options "--z3rlimit 40"
let lemma_store_stack_same_valid64 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let lemma_free_stack_same_valid64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(valid_src_stack64 ptr (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))] | [] | Vale.X64.Stack_i.lemma_store_new_valid64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> v: Vale.X64.Memory.nat64 -> h: Vale.X64.Stack_i.vale_stack
-> FStar.Pervasives.Lemma
(ensures Vale.X64.Stack_i.valid_src_stack64 ptr (Vale.X64.Stack_i.store_stack64 ptr v h))
[SMTPat (Vale.X64.Stack_i.valid_src_stack64 ptr (Vale.X64.Stack_i.store_stack64 ptr v h))] | {
"end_col": 28,
"end_line": 33,
"start_col": 2,
"start_line": 32
} |
FStar.Pervasives.Lemma | val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma
(requires start <= inter /\ inter <= finish)
(ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h)
[SMTPat (free_stack64 inter finish (free_stack64 start inter h))] | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_compose_free_stack64 start inter finish h =
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
let map_restr = Map.restrict (Vale.Lib.Set.remove_between domain start inter) mem in
let restrict = Map.domain map_restr in
let BS.Machine_stack _ mem1 = free_stack64 inter finish (free_stack64 start inter h) in
let BS.Machine_stack _ mem2 = free_stack64 start finish h in
let aux (i:int) : Lemma (Map.contains mem1 i = Map.contains mem2 i /\ Map.sel mem1 i = Map.sel mem2 i)
= Vale.Lib.Set.remove_between_reveal domain start inter i;
Vale.Lib.Set.remove_between_reveal restrict inter finish i;
Vale.Lib.Set.remove_between_reveal domain start finish i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start inter) mem i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between restrict inter finish) map_restr i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start finish) mem i
in Classical.forall_intro aux;
assert (Map.equal mem1 mem2) | val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma
(requires start <= inter /\ inter <= finish)
(ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h)
[SMTPat (free_stack64 inter finish (free_stack64 start inter h))]
let lemma_compose_free_stack64 start inter finish h = | false | null | true | let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
let map_restr = Map.restrict (Vale.Lib.Set.remove_between domain start inter) mem in
let restrict = Map.domain map_restr in
let BS.Machine_stack _ mem1 = free_stack64 inter finish (free_stack64 start inter h) in
let BS.Machine_stack _ mem2 = free_stack64 start finish h in
let aux (i: int)
: Lemma (Map.contains mem1 i = Map.contains mem2 i /\ Map.sel mem1 i = Map.sel mem2 i) =
Vale.Lib.Set.remove_between_reveal domain start inter i;
Vale.Lib.Set.remove_between_reveal restrict inter finish i;
Vale.Lib.Set.remove_between_reveal domain start finish i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start inter) mem i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between restrict inter finish) map_restr i;
Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start finish) mem i
in
Classical.forall_intro aux;
assert (Map.equal mem1 mem2) | {
"checked_file": "Vale.X64.Stack_i.fst.checked",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Arch.MachineHeap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Stack_i.fst"
} | [
"lemma"
] | [
"Prims.int",
"Vale.X64.Stack_i.vale_stack",
"Vale.Def.Types_s.nat64",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.Map.t",
"Vale.Def.Types_s.nat8",
"Prims._assert",
"FStar.Map.equal",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.l_and",
"Prims.op_Equality",
"Prims.bool",
"FStar.Map.contains",
"FStar.Map.sel",
"Prims.l_True",
"Prims.squash",
"Vale.Def.Words_s.nat8",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.Lib.Set.lemma_sel_restrict",
"Vale.Lib.Set.remove_between",
"Vale.Lib.Set.remove_between_reveal",
"Vale.X64.Stack_i.free_stack64",
"FStar.Set.set",
"FStar.Map.domain",
"FStar.Map.restrict"
] | [] | module Vale.X64.Stack_i
open FStar.Mul
module BS = Vale.X64.Machine_Semantics_s
open Vale.Arch.MachineHeap
let vale_stack = BS.machine_stack
let valid_src_stack64 i st = BS.valid_src_stack64 i st
let load_stack64 i st = BS.eval_stack i st
let store_stack64 i v h = BS.update_stack64' i v h
let free_stack64 start finish h = BS.free_stack' start finish h
let valid_src_stack128 i st = BS.valid_src_stack128 i st
let load_stack128 i st = BS.eval_stack128 i st
let store_stack128 i v h = BS.update_stack128' i v h
let init_rsp h = h.BS.initial_rsp
(* Lemmas *)
#push-options "--z3rlimit 40"
let lemma_store_stack_same_valid64 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
let lemma_free_stack_same_valid64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish)
let lemma_store_new_valid64 ptr v h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
BS.update_heap64_reveal ()
#pop-options
let lemma_correct_store_load_stack64 ptr v h =
let BS.Machine_stack _ mem = h in
correct_update_get64 ptr v mem
let lemma_frame_store_load_stack64 ptr v h i =
let BS.Machine_stack _ mem = h in
frame_update_heap64 ptr v mem;
BS.get_heap_val64_reveal ()
let lemma_free_stack_same_load64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64;
let BS.Machine_stack _ mem = h in
let domain = Map.domain mem in
Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish);
BS.get_heap_val64_reveal () | false | false | Vale.X64.Stack_i.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma
(requires start <= inter /\ inter <= finish)
(ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h)
[SMTPat (free_stack64 inter finish (free_stack64 start inter h))] | [] | Vale.X64.Stack_i.lemma_compose_free_stack64 | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | start: Prims.int -> inter: Prims.int -> finish: Prims.int -> h: Vale.X64.Stack_i.vale_stack
-> FStar.Pervasives.Lemma (requires start <= inter /\ inter <= finish)
(ensures
Vale.X64.Stack_i.free_stack64 inter finish (Vale.X64.Stack_i.free_stack64 start inter h) ==
Vale.X64.Stack_i.free_stack64 start finish h)
[
SMTPat (Vale.X64.Stack_i.free_stack64 inter
finish
(Vale.X64.Stack_i.free_stack64 start inter h))
] | {
"end_col": 30,
"end_line": 67,
"start_col": 53,
"start_line": 52
} |
FStar.Pervasives.Lemma | val lemma_BitwiseXorWithZero64 (n:nat64) : Lemma (ixor n 0 == n) | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 lemma_BitwiseXorWithZero64 n =
lemma_ixor_nth_all 64;
lemma_zero_nth 64;
lemma_equal_nth 64 (ixor n 0) n | val lemma_BitwiseXorWithZero64 (n:nat64) : Lemma (ixor n 0 == n)
let lemma_BitwiseXorWithZero64 n = | false | null | true | lemma_ixor_nth_all 64;
lemma_zero_nth 64;
lemma_equal_nth 64 (ixor n 0) n | {
"checked_file": "Vale.AES.Types_helpers.fst.checked",
"dependencies": [
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.Types_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.nat64",
"Vale.Arch.TypesNative.lemma_equal_nth",
"Vale.Def.Types_s.ixor",
"Vale.Def.Words_s.pow2_64",
"Prims.unit",
"Vale.Arch.TypesNative.lemma_zero_nth",
"Vale.Arch.TypesNative.lemma_ixor_nth_all"
] | [] | module Vale.AES.Types_helpers
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Seq
open Vale.Arch.TypesNative
let lemma_slices_le_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = le_quad32_to_bytes q in
q.lo0 == four_to_nat 8 (seq_to_four_LE (slice s 0 4)) /\
q.lo1 == four_to_nat 8 (seq_to_four_LE (slice s 4 8)) /\
q.hi2 == four_to_nat 8 (seq_to_four_LE (slice s 8 12)) /\
q.hi3 == four_to_nat 8 (seq_to_four_LE (slice s 12 16))
))
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8);
reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes;
()
let lemma_slices_be_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = be_quad32_to_bytes q in
q.hi3 == four_to_nat 8 (seq_to_four_BE (slice s 0 4)) /\
q.hi2 == four_to_nat 8 (seq_to_four_BE (slice s 4 8)) /\
q.lo1 == four_to_nat 8 (seq_to_four_BE (slice s 8 12)) /\
q.lo0 == four_to_nat 8 (seq_to_four_BE (slice s 12 16))
))
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat8);
reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes;
() | false | false | Vale.AES.Types_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_BitwiseXorWithZero64 (n:nat64) : Lemma (ixor n 0 == n) | [] | Vale.AES.Types_helpers.lemma_BitwiseXorWithZero64 | {
"file_name": "vale/code/crypto/aes/Vale.AES.Types_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Vale.Def.Types_s.nat64 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.ixor n 0 == n) | {
"end_col": 33,
"end_line": 39,
"start_col": 2,
"start_line": 37
} |
FStar.Pervasives.Lemma | val lemma_slices_be_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = be_quad32_to_bytes q in
q.hi3 == four_to_nat 8 (seq_to_four_BE (slice s 0 4)) /\
q.hi2 == four_to_nat 8 (seq_to_four_BE (slice s 4 8)) /\
q.lo1 == four_to_nat 8 (seq_to_four_BE (slice s 8 12)) /\
q.lo0 == four_to_nat 8 (seq_to_four_BE (slice s 12 16))
)) | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 lemma_slices_be_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = be_quad32_to_bytes q in
q.hi3 == four_to_nat 8 (seq_to_four_BE (slice s 0 4)) /\
q.hi2 == four_to_nat 8 (seq_to_four_BE (slice s 4 8)) /\
q.lo1 == four_to_nat 8 (seq_to_four_BE (slice s 8 12)) /\
q.lo0 == four_to_nat 8 (seq_to_four_BE (slice s 12 16))
))
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat8);
reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes;
() | val lemma_slices_be_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = be_quad32_to_bytes q in
q.hi3 == four_to_nat 8 (seq_to_four_BE (slice s 0 4)) /\
q.hi2 == four_to_nat 8 (seq_to_four_BE (slice s 4 8)) /\
q.lo1 == four_to_nat 8 (seq_to_four_BE (slice s 8 12)) /\
q.lo0 == four_to_nat 8 (seq_to_four_BE (slice s 12 16))
))
let lemma_slices_be_quad32_to_bytes (q: quad32)
: Lemma
(ensures
(let s = be_quad32_to_bytes q in
q.hi3 == four_to_nat 8 (seq_to_four_BE (slice s 0 4)) /\
q.hi2 == four_to_nat 8 (seq_to_four_BE (slice s 4 8)) /\
q.lo1 == four_to_nat 8 (seq_to_four_BE (slice s 8 12)) /\
q.lo0 == four_to_nat 8 (seq_to_four_BE (slice s 12 16)))) = | false | null | true | reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat8);
reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes;
() | {
"checked_file": "Vale.AES.Types_helpers.fst.checked",
"dependencies": [
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.Types_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Prims.unit",
"FStar.Pervasives.reveal_opaque",
"Vale.Def.Words.Seq_s.seq16",
"Vale.Def.Words_s.nat8",
"Vale.Arch.Types.be_quad32_to_bytes",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.four",
"Vale.Def.Types_s.nat8",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Mul.op_Star",
"Vale.Def.Words.Seq_s.seq_four_to_seq_BE",
"Prims.l_True",
"Prims.squash",
"Prims.l_and",
"Vale.Def.Words_s.natN",
"Vale.Def.Words_s.pow2_32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words.Four_s.four_to_nat",
"Vale.Def.Words.Seq_s.seq_to_four_BE",
"FStar.Seq.Base.slice",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Prims.pow2",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.AES.Types_helpers
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Seq
open Vale.Arch.TypesNative
let lemma_slices_le_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = le_quad32_to_bytes q in
q.lo0 == four_to_nat 8 (seq_to_four_LE (slice s 0 4)) /\
q.lo1 == four_to_nat 8 (seq_to_four_LE (slice s 4 8)) /\
q.hi2 == four_to_nat 8 (seq_to_four_LE (slice s 8 12)) /\
q.hi3 == four_to_nat 8 (seq_to_four_LE (slice s 12 16))
))
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8);
reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes;
()
let lemma_slices_be_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = be_quad32_to_bytes q in
q.hi3 == four_to_nat 8 (seq_to_four_BE (slice s 0 4)) /\
q.hi2 == four_to_nat 8 (seq_to_four_BE (slice s 4 8)) /\
q.lo1 == four_to_nat 8 (seq_to_four_BE (slice s 8 12)) /\
q.lo0 == four_to_nat 8 (seq_to_four_BE (slice s 12 16))
)) | false | false | Vale.AES.Types_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_slices_be_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = be_quad32_to_bytes q in
q.hi3 == four_to_nat 8 (seq_to_four_BE (slice s 0 4)) /\
q.hi2 == four_to_nat 8 (seq_to_four_BE (slice s 4 8)) /\
q.lo1 == four_to_nat 8 (seq_to_four_BE (slice s 8 12)) /\
q.lo0 == four_to_nat 8 (seq_to_four_BE (slice s 12 16))
)) | [] | Vale.AES.Types_helpers.lemma_slices_be_quad32_to_bytes | {
"file_name": "vale/code/crypto/aes/Vale.AES.Types_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | q: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(ensures
(let s = Vale.Arch.Types.be_quad32_to_bytes q in
Mkfour?.hi3 q ==
Vale.Def.Words.Four_s.four_to_nat 8
(Vale.Def.Words.Seq_s.seq_to_four_BE (FStar.Seq.Base.slice s 0 4)) /\
Mkfour?.hi2 q ==
Vale.Def.Words.Four_s.four_to_nat 8
(Vale.Def.Words.Seq_s.seq_to_four_BE (FStar.Seq.Base.slice s 4 8)) /\
Mkfour?.lo1 q ==
Vale.Def.Words.Four_s.four_to_nat 8
(Vale.Def.Words.Seq_s.seq_to_four_BE (FStar.Seq.Base.slice s 8 12)) /\
Mkfour?.lo0 q ==
Vale.Def.Words.Four_s.four_to_nat 8
(Vale.Def.Words.Seq_s.seq_to_four_BE (FStar.Seq.Base.slice s 12 16)))) | {
"end_col": 4,
"end_line": 34,
"start_col": 2,
"start_line": 32
} |
FStar.Pervasives.Lemma | val lemma_slices_le_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = le_quad32_to_bytes q in
q.lo0 == four_to_nat 8 (seq_to_four_LE (slice s 0 4)) /\
q.lo1 == four_to_nat 8 (seq_to_four_LE (slice s 4 8)) /\
q.hi2 == four_to_nat 8 (seq_to_four_LE (slice s 8 12)) /\
q.hi3 == four_to_nat 8 (seq_to_four_LE (slice s 12 16))
)) | [
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 lemma_slices_le_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = le_quad32_to_bytes q in
q.lo0 == four_to_nat 8 (seq_to_four_LE (slice s 0 4)) /\
q.lo1 == four_to_nat 8 (seq_to_four_LE (slice s 4 8)) /\
q.hi2 == four_to_nat 8 (seq_to_four_LE (slice s 8 12)) /\
q.hi3 == four_to_nat 8 (seq_to_four_LE (slice s 12 16))
))
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8);
reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes;
() | val lemma_slices_le_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = le_quad32_to_bytes q in
q.lo0 == four_to_nat 8 (seq_to_four_LE (slice s 0 4)) /\
q.lo1 == four_to_nat 8 (seq_to_four_LE (slice s 4 8)) /\
q.hi2 == four_to_nat 8 (seq_to_four_LE (slice s 8 12)) /\
q.hi3 == four_to_nat 8 (seq_to_four_LE (slice s 12 16))
))
let lemma_slices_le_quad32_to_bytes (q: quad32)
: Lemma
(ensures
(let s = le_quad32_to_bytes q in
q.lo0 == four_to_nat 8 (seq_to_four_LE (slice s 0 4)) /\
q.lo1 == four_to_nat 8 (seq_to_four_LE (slice s 4 8)) /\
q.hi2 == four_to_nat 8 (seq_to_four_LE (slice s 8 12)) /\
q.hi3 == four_to_nat 8 (seq_to_four_LE (slice s 12 16)))) = | false | null | true | reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8);
reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes;
() | {
"checked_file": "Vale.AES.Types_helpers.fst.checked",
"dependencies": [
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.Types_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Prims.unit",
"FStar.Pervasives.reveal_opaque",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Prims.l_True",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.Def.Words_s.four",
"FStar.Mul.op_Star",
"Vale.Def.Words.Seq_s.seq_four_to_seq_LE",
"Prims.squash",
"Prims.l_and",
"Vale.Def.Words_s.natN",
"Vale.Def.Words_s.pow2_32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words.Four_s.four_to_nat",
"Vale.Def.Words.Seq_s.seq_to_four_LE",
"FStar.Seq.Base.slice",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Prims.pow2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Words_s.nat8",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.AES.Types_helpers
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Seq
open Vale.Arch.TypesNative
let lemma_slices_le_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = le_quad32_to_bytes q in
q.lo0 == four_to_nat 8 (seq_to_four_LE (slice s 0 4)) /\
q.lo1 == four_to_nat 8 (seq_to_four_LE (slice s 4 8)) /\
q.hi2 == four_to_nat 8 (seq_to_four_LE (slice s 8 12)) /\
q.hi3 == four_to_nat 8 (seq_to_four_LE (slice s 12 16))
)) | false | false | Vale.AES.Types_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_slices_le_quad32_to_bytes (q:quad32) : Lemma
(ensures (
let s = le_quad32_to_bytes q in
q.lo0 == four_to_nat 8 (seq_to_four_LE (slice s 0 4)) /\
q.lo1 == four_to_nat 8 (seq_to_four_LE (slice s 4 8)) /\
q.hi2 == four_to_nat 8 (seq_to_four_LE (slice s 8 12)) /\
q.hi3 == four_to_nat 8 (seq_to_four_LE (slice s 12 16))
)) | [] | Vale.AES.Types_helpers.lemma_slices_le_quad32_to_bytes | {
"file_name": "vale/code/crypto/aes/Vale.AES.Types_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | q: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(ensures
(let s = Vale.Def.Types_s.le_quad32_to_bytes q in
Mkfour?.lo0 q ==
Vale.Def.Words.Four_s.four_to_nat 8
(Vale.Def.Words.Seq_s.seq_to_four_LE (FStar.Seq.Base.slice s 0 4)) /\
Mkfour?.lo1 q ==
Vale.Def.Words.Four_s.four_to_nat 8
(Vale.Def.Words.Seq_s.seq_to_four_LE (FStar.Seq.Base.slice s 4 8)) /\
Mkfour?.hi2 q ==
Vale.Def.Words.Four_s.four_to_nat 8
(Vale.Def.Words.Seq_s.seq_to_four_LE (FStar.Seq.Base.slice s 8 12)) /\
Mkfour?.hi3 q ==
Vale.Def.Words.Four_s.four_to_nat 8
(Vale.Def.Words.Seq_s.seq_to_four_LE (FStar.Seq.Base.slice s 12 16)))) | {
"end_col": 4,
"end_line": 21,
"start_col": 2,
"start_line": 19
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256.Lemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.PrecompTable",
"short_module": "SPTK"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable256",
"short_module": "SPT256"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow_point (k:nat) (p:S.aff_point) =
LE.pow S.mk_p256_comm_monoid p k | let pow_point (k: nat) (p: S.aff_point) = | false | null | false | LE.pow S.mk_p256_comm_monoid p k | {
"checked_file": "Hacl.P256.PrecompTable.fsti.checked",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.PrecompBaseTable.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Group.fst.checked",
"Hacl.Impl.Exponentiation.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.P256.PrecompTable.fsti"
} | [
"total"
] | [
"Prims.nat",
"Spec.P256.PointOps.aff_point",
"Lib.Exponentiation.Definition.pow",
"Spec.P256.mk_p256_comm_monoid"
] | [] | module Hacl.P256.PrecompTable
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LE = Lib.Exponentiation.Definition
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation.Definitions
module SPT = Hacl.Spec.PrecompBaseTable
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
open Hacl.Impl.P256.Point
include Hacl.Impl.P256.Group
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val proj_point_to_list: p:S.proj_point
-> x:list uint64{FStar.List.Tot.length x = 12 /\
mk_to_p256_comm_monoid.BE.linv (Seq.seq_of_list x)}
val lemma_refl: x:S.proj_point ->
Lemma (S.mk_p256_concrete_ops.SE.to.SE.refl x ==
mk_to_p256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x)))
inline_for_extraction noextract
let mk_p256_precomp_base_table: SPT.mk_precomp_base_table S.proj_point U64 12ul 0ul = {
SPT.concr_ops = S.mk_p256_concrete_ops;
SPT.to_cm = mk_to_p256_comm_monoid;
SPT.to_list = proj_point_to_list;
SPT.lemma_refl = lemma_refl;
}
inline_for_extraction noextract | false | true | Hacl.P256.PrecompTable.fsti | {
"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 pow_point : k: Prims.nat -> p: Spec.P256.PointOps.aff_point -> Spec.P256.PointOps.aff_point | [] | Hacl.P256.PrecompTable.pow_point | {
"file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | k: Prims.nat -> p: Spec.P256.PointOps.aff_point -> Spec.P256.PointOps.aff_point | {
"end_col": 34,
"end_line": 45,
"start_col": 2,
"start_line": 45
} |
|
Prims.Tot | val g_aff:S.aff_point | [
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256.Lemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.PrecompTable",
"short_module": "SPTK"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable256",
"short_module": "SPT256"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let g_aff : S.aff_point = S.to_aff_point S.base_point | val g_aff:S.aff_point
let g_aff:S.aff_point = | false | null | false | S.to_aff_point S.base_point | {
"checked_file": "Hacl.P256.PrecompTable.fsti.checked",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.PrecompBaseTable.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Group.fst.checked",
"Hacl.Impl.Exponentiation.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.P256.PrecompTable.fsti"
} | [
"total"
] | [
"Spec.P256.PointOps.to_aff_point",
"Spec.P256.PointOps.base_point"
] | [] | module Hacl.P256.PrecompTable
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LE = Lib.Exponentiation.Definition
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation.Definitions
module SPT = Hacl.Spec.PrecompBaseTable
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
open Hacl.Impl.P256.Point
include Hacl.Impl.P256.Group
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val proj_point_to_list: p:S.proj_point
-> x:list uint64{FStar.List.Tot.length x = 12 /\
mk_to_p256_comm_monoid.BE.linv (Seq.seq_of_list x)}
val lemma_refl: x:S.proj_point ->
Lemma (S.mk_p256_concrete_ops.SE.to.SE.refl x ==
mk_to_p256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x)))
inline_for_extraction noextract
let mk_p256_precomp_base_table: SPT.mk_precomp_base_table S.proj_point U64 12ul 0ul = {
SPT.concr_ops = S.mk_p256_concrete_ops;
SPT.to_cm = mk_to_p256_comm_monoid;
SPT.to_list = proj_point_to_list;
SPT.lemma_refl = lemma_refl;
}
inline_for_extraction noextract
let pow_point (k:nat) (p:S.aff_point) =
LE.pow S.mk_p256_comm_monoid p k
//---------------- | false | true | Hacl.P256.PrecompTable.fsti | {
"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 g_aff:S.aff_point | [] | Hacl.P256.PrecompTable.g_aff | {
"file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.P256.PointOps.aff_point | {
"end_col": 53,
"end_line": 50,
"start_col": 26,
"start_line": 50
} |
Prims.Tot | val g_pow2_64:S.aff_point | [
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256.Lemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.PrecompTable",
"short_module": "SPTK"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable256",
"short_module": "SPT256"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let g_pow2_64 : S.aff_point = pow_point (pow2 64) g_aff | val g_pow2_64:S.aff_point
let g_pow2_64:S.aff_point = | false | null | false | pow_point (pow2 64) g_aff | {
"checked_file": "Hacl.P256.PrecompTable.fsti.checked",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.PrecompBaseTable.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Group.fst.checked",
"Hacl.Impl.Exponentiation.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.P256.PrecompTable.fsti"
} | [
"total"
] | [
"Hacl.P256.PrecompTable.pow_point",
"Prims.pow2",
"Hacl.P256.PrecompTable.g_aff"
] | [] | module Hacl.P256.PrecompTable
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LE = Lib.Exponentiation.Definition
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation.Definitions
module SPT = Hacl.Spec.PrecompBaseTable
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
open Hacl.Impl.P256.Point
include Hacl.Impl.P256.Group
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val proj_point_to_list: p:S.proj_point
-> x:list uint64{FStar.List.Tot.length x = 12 /\
mk_to_p256_comm_monoid.BE.linv (Seq.seq_of_list x)}
val lemma_refl: x:S.proj_point ->
Lemma (S.mk_p256_concrete_ops.SE.to.SE.refl x ==
mk_to_p256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x)))
inline_for_extraction noextract
let mk_p256_precomp_base_table: SPT.mk_precomp_base_table S.proj_point U64 12ul 0ul = {
SPT.concr_ops = S.mk_p256_concrete_ops;
SPT.to_cm = mk_to_p256_comm_monoid;
SPT.to_list = proj_point_to_list;
SPT.lemma_refl = lemma_refl;
}
inline_for_extraction noextract
let pow_point (k:nat) (p:S.aff_point) =
LE.pow S.mk_p256_comm_monoid p k
//----------------
noextract
let g_aff : S.aff_point = S.to_aff_point S.base_point
// [pow2 64]G | false | true | Hacl.P256.PrecompTable.fsti | {
"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 g_pow2_64:S.aff_point | [] | Hacl.P256.PrecompTable.g_pow2_64 | {
"file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.P256.PointOps.aff_point | {
"end_col": 55,
"end_line": 54,
"start_col": 30,
"start_line": 54
} |
Prims.Tot | val g_pow2_192:S.aff_point | [
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256.Lemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.PrecompTable",
"short_module": "SPTK"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable256",
"short_module": "SPT256"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let g_pow2_192 : S.aff_point = pow_point (pow2 192) g_aff | val g_pow2_192:S.aff_point
let g_pow2_192:S.aff_point = | false | null | false | pow_point (pow2 192) g_aff | {
"checked_file": "Hacl.P256.PrecompTable.fsti.checked",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.PrecompBaseTable.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Group.fst.checked",
"Hacl.Impl.Exponentiation.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.P256.PrecompTable.fsti"
} | [
"total"
] | [
"Hacl.P256.PrecompTable.pow_point",
"Prims.pow2",
"Hacl.P256.PrecompTable.g_aff"
] | [] | module Hacl.P256.PrecompTable
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LE = Lib.Exponentiation.Definition
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation.Definitions
module SPT = Hacl.Spec.PrecompBaseTable
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
open Hacl.Impl.P256.Point
include Hacl.Impl.P256.Group
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val proj_point_to_list: p:S.proj_point
-> x:list uint64{FStar.List.Tot.length x = 12 /\
mk_to_p256_comm_monoid.BE.linv (Seq.seq_of_list x)}
val lemma_refl: x:S.proj_point ->
Lemma (S.mk_p256_concrete_ops.SE.to.SE.refl x ==
mk_to_p256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x)))
inline_for_extraction noextract
let mk_p256_precomp_base_table: SPT.mk_precomp_base_table S.proj_point U64 12ul 0ul = {
SPT.concr_ops = S.mk_p256_concrete_ops;
SPT.to_cm = mk_to_p256_comm_monoid;
SPT.to_list = proj_point_to_list;
SPT.lemma_refl = lemma_refl;
}
inline_for_extraction noextract
let pow_point (k:nat) (p:S.aff_point) =
LE.pow S.mk_p256_comm_monoid p k
//----------------
noextract
let g_aff : S.aff_point = S.to_aff_point S.base_point
// [pow2 64]G
noextract
let g_pow2_64 : S.aff_point = pow_point (pow2 64) g_aff
// [pow2 128]G
noextract
let g_pow2_128 : S.aff_point = pow_point (pow2 128) g_aff
// [pow2 192]G | false | true | Hacl.P256.PrecompTable.fsti | {
"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 g_pow2_192:S.aff_point | [] | Hacl.P256.PrecompTable.g_pow2_192 | {
"file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.P256.PointOps.aff_point | {
"end_col": 57,
"end_line": 62,
"start_col": 31,
"start_line": 62
} |
Prims.Tot | val g_pow2_128:S.aff_point | [
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256.Lemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.PrecompTable",
"short_module": "SPTK"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable256",
"short_module": "SPT256"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let g_pow2_128 : S.aff_point = pow_point (pow2 128) g_aff | val g_pow2_128:S.aff_point
let g_pow2_128:S.aff_point = | false | null | false | pow_point (pow2 128) g_aff | {
"checked_file": "Hacl.P256.PrecompTable.fsti.checked",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.PrecompBaseTable.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Group.fst.checked",
"Hacl.Impl.Exponentiation.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.P256.PrecompTable.fsti"
} | [
"total"
] | [
"Hacl.P256.PrecompTable.pow_point",
"Prims.pow2",
"Hacl.P256.PrecompTable.g_aff"
] | [] | module Hacl.P256.PrecompTable
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LE = Lib.Exponentiation.Definition
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation.Definitions
module SPT = Hacl.Spec.PrecompBaseTable
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
open Hacl.Impl.P256.Point
include Hacl.Impl.P256.Group
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val proj_point_to_list: p:S.proj_point
-> x:list uint64{FStar.List.Tot.length x = 12 /\
mk_to_p256_comm_monoid.BE.linv (Seq.seq_of_list x)}
val lemma_refl: x:S.proj_point ->
Lemma (S.mk_p256_concrete_ops.SE.to.SE.refl x ==
mk_to_p256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x)))
inline_for_extraction noextract
let mk_p256_precomp_base_table: SPT.mk_precomp_base_table S.proj_point U64 12ul 0ul = {
SPT.concr_ops = S.mk_p256_concrete_ops;
SPT.to_cm = mk_to_p256_comm_monoid;
SPT.to_list = proj_point_to_list;
SPT.lemma_refl = lemma_refl;
}
inline_for_extraction noextract
let pow_point (k:nat) (p:S.aff_point) =
LE.pow S.mk_p256_comm_monoid p k
//----------------
noextract
let g_aff : S.aff_point = S.to_aff_point S.base_point
// [pow2 64]G
noextract
let g_pow2_64 : S.aff_point = pow_point (pow2 64) g_aff
// [pow2 128]G | false | true | Hacl.P256.PrecompTable.fsti | {
"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 g_pow2_128:S.aff_point | [] | Hacl.P256.PrecompTable.g_pow2_128 | {
"file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Spec.P256.PointOps.aff_point | {
"end_col": 57,
"end_line": 58,
"start_col": 31,
"start_line": 58
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256.Lemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.PrecompTable",
"short_module": "SPTK"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable256",
"short_module": "SPT256"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let precomp_table_acc_inv
(p:S.aff_point)
(table_len:nat{table_len * 12 <= max_size_t})
(table:LSeq.lseq uint64 (table_len * 12))
(j:nat{j < table_len})
=
Math.Lemmas.lemma_mult_lt_right 12 j table_len;
Math.Lemmas.lemma_mult_le_right 12 (j + 1) table_len;
let bj = LSeq.sub table (j * 12) 12 in
point_inv_seq bj /\ S.to_aff_point (from_mont_point (as_point_nat_seq bj)) == pow_point j p | let precomp_table_acc_inv
(p: S.aff_point)
(table_len: nat{table_len * 12 <= max_size_t})
(table: LSeq.lseq uint64 (table_len * 12))
(j: nat{j < table_len})
= | false | null | false | Math.Lemmas.lemma_mult_lt_right 12 j table_len;
Math.Lemmas.lemma_mult_le_right 12 (j + 1) table_len;
let bj = LSeq.sub table (j * 12) 12 in
point_inv_seq bj /\ S.to_aff_point (from_mont_point (as_point_nat_seq bj)) == pow_point j p | {
"checked_file": "Hacl.P256.PrecompTable.fsti.checked",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.PrecompBaseTable.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Group.fst.checked",
"Hacl.Impl.Exponentiation.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.P256.PrecompTable.fsti"
} | [
"total"
] | [
"Spec.P256.PointOps.aff_point",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Prims.op_LessThan",
"Prims.l_and",
"Hacl.Impl.P256.Point.point_inv_seq",
"Prims.eq2",
"Spec.P256.PointOps.to_aff_point",
"Hacl.Impl.P256.Point.from_mont_point",
"Hacl.Impl.P256.Point.as_point_nat_seq",
"Hacl.P256.PrecompTable.pow_point",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Prims.op_Multiply",
"Prims.op_Addition",
"Prims.l_Forall",
"Prims.l_or",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.Sequence.sub",
"Prims.unit",
"FStar.Math.Lemmas.lemma_mult_le_right",
"FStar.Math.Lemmas.lemma_mult_lt_right",
"Prims.logical"
] | [] | module Hacl.P256.PrecompTable
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LE = Lib.Exponentiation.Definition
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation.Definitions
module SPT = Hacl.Spec.PrecompBaseTable
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
open Hacl.Impl.P256.Point
include Hacl.Impl.P256.Group
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val proj_point_to_list: p:S.proj_point
-> x:list uint64{FStar.List.Tot.length x = 12 /\
mk_to_p256_comm_monoid.BE.linv (Seq.seq_of_list x)}
val lemma_refl: x:S.proj_point ->
Lemma (S.mk_p256_concrete_ops.SE.to.SE.refl x ==
mk_to_p256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x)))
inline_for_extraction noextract
let mk_p256_precomp_base_table: SPT.mk_precomp_base_table S.proj_point U64 12ul 0ul = {
SPT.concr_ops = S.mk_p256_concrete_ops;
SPT.to_cm = mk_to_p256_comm_monoid;
SPT.to_list = proj_point_to_list;
SPT.lemma_refl = lemma_refl;
}
inline_for_extraction noextract
let pow_point (k:nat) (p:S.aff_point) =
LE.pow S.mk_p256_comm_monoid p k
//----------------
noextract
let g_aff : S.aff_point = S.to_aff_point S.base_point
// [pow2 64]G
noextract
let g_pow2_64 : S.aff_point = pow_point (pow2 64) g_aff
// [pow2 128]G
noextract
let g_pow2_128 : S.aff_point = pow_point (pow2 128) g_aff
// [pow2 192]G
noextract
let g_pow2_192 : S.aff_point = pow_point (pow2 192) g_aff
inline_for_extraction noextract
val proj_g_pow2_64_lseq : LSeq.lseq uint64 12
inline_for_extraction noextract
val proj_g_pow2_128_lseq : LSeq.lseq uint64 12
inline_for_extraction noextract
val proj_g_pow2_192_lseq : LSeq.lseq uint64 12
val proj_g_pow2_64_lseq_lemma: unit ->
Lemma (point_inv_seq proj_g_pow2_64_lseq /\
S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_64_lseq)) == g_pow2_64)
val proj_g_pow2_128_lseq_lemma: unit ->
Lemma (point_inv_seq proj_g_pow2_128_lseq /\
S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_128_lseq)) == g_pow2_128)
val proj_g_pow2_192_lseq_lemma: unit ->
Lemma (point_inv_seq proj_g_pow2_192_lseq /\
S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_192_lseq)) == g_pow2_192)
inline_for_extraction
val mk_proj_g_pow2_64: unit -> StackInline (lbuffer uint64 12ul)
(requires fun _ -> True)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_64_lseq)
inline_for_extraction
val mk_proj_g_pow2_128: unit -> StackInline (lbuffer uint64 12ul)
(requires fun _ -> True)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_128_lseq)
inline_for_extraction
val mk_proj_g_pow2_192: unit -> StackInline (lbuffer uint64 12ul)
(requires fun _ -> True)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_192_lseq)
//----------------
unfold
let precomp_table_acc_inv
(p:S.aff_point)
(table_len:nat{table_len * 12 <= max_size_t})
(table:LSeq.lseq uint64 (table_len * 12))
(j:nat{j < table_len}) | false | false | Hacl.P256.PrecompTable.fsti | {
"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 precomp_table_acc_inv : p: Spec.P256.PointOps.aff_point ->
table_len: Prims.nat{table_len * 12 <= Lib.IntTypes.max_size_t} ->
table: Lib.Sequence.lseq Lib.IntTypes.uint64 (table_len * 12) ->
j: Prims.nat{j < table_len}
-> Prims.logical | [] | Hacl.P256.PrecompTable.precomp_table_acc_inv | {
"file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
p: Spec.P256.PointOps.aff_point ->
table_len: Prims.nat{table_len * 12 <= Lib.IntTypes.max_size_t} ->
table: Lib.Sequence.lseq Lib.IntTypes.uint64 (table_len * 12) ->
j: Prims.nat{j < table_len}
-> Prims.logical | {
"end_col": 93,
"end_line": 112,
"start_col": 2,
"start_line": 109
} |
|
Prims.Tot | val mk_p256_precomp_base_table:SPT.mk_precomp_base_table S.proj_point U64 12ul 0ul | [
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256.Lemmas",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.PrecompTable",
"short_module": "SPTK"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable256",
"short_module": "SPT256"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Group",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.PrecompBaseTable",
"short_module": "SPT"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation.Definitions",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation.Definition",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_p256_precomp_base_table: SPT.mk_precomp_base_table S.proj_point U64 12ul 0ul = {
SPT.concr_ops = S.mk_p256_concrete_ops;
SPT.to_cm = mk_to_p256_comm_monoid;
SPT.to_list = proj_point_to_list;
SPT.lemma_refl = lemma_refl;
} | val mk_p256_precomp_base_table:SPT.mk_precomp_base_table S.proj_point U64 12ul 0ul
let mk_p256_precomp_base_table:SPT.mk_precomp_base_table S.proj_point U64 12ul 0ul = | false | null | false | {
SPT.concr_ops = S.mk_p256_concrete_ops;
SPT.to_cm = mk_to_p256_comm_monoid;
SPT.to_list = proj_point_to_list;
SPT.lemma_refl = lemma_refl
} | {
"checked_file": "Hacl.P256.PrecompTable.fsti.checked",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.Definition.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.PrecompBaseTable.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Impl.P256.Point.fsti.checked",
"Hacl.Impl.P256.Group.fst.checked",
"Hacl.Impl.Exponentiation.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.P256.PrecompTable.fsti"
} | [
"total"
] | [
"Hacl.Spec.PrecompBaseTable.Mkmk_precomp_base_table",
"Spec.P256.PointOps.proj_point",
"Lib.IntTypes.U64",
"FStar.UInt32.uint_to_t",
"Spec.P256.mk_p256_concrete_ops",
"Hacl.Impl.P256.Group.mk_to_p256_comm_monoid",
"Hacl.P256.PrecompTable.proj_point_to_list",
"Hacl.P256.PrecompTable.lemma_refl"
] | [] | module Hacl.P256.PrecompTable
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LE = Lib.Exponentiation.Definition
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation.Definitions
module SPT = Hacl.Spec.PrecompBaseTable
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
open Hacl.Impl.P256.Point
include Hacl.Impl.P256.Group
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val proj_point_to_list: p:S.proj_point
-> x:list uint64{FStar.List.Tot.length x = 12 /\
mk_to_p256_comm_monoid.BE.linv (Seq.seq_of_list x)}
val lemma_refl: x:S.proj_point ->
Lemma (S.mk_p256_concrete_ops.SE.to.SE.refl x ==
mk_to_p256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x)))
inline_for_extraction noextract | false | false | Hacl.P256.PrecompTable.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_p256_precomp_base_table:SPT.mk_precomp_base_table S.proj_point U64 12ul 0ul | [] | Hacl.P256.PrecompTable.mk_p256_precomp_base_table | {
"file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Spec.PrecompBaseTable.mk_precomp_base_table Spec.P256.PointOps.proj_point
Lib.IntTypes.U64
(FStar.UInt32.uint_to_t 12 <: FStar.UInt32.t)
(FStar.UInt32.uint_to_t 0 <: FStar.UInt32.t) | {
"end_col": 30,
"end_line": 40,
"start_col": 2,
"start_line": 37
} |
Prims.Tot | [
{
"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": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nullary_macro t d = {
macro_arguments_t = [];
macro_result_t = t;
macro_defn_t = d
} | let nullary_macro t d = | false | null | false | { macro_arguments_t = []; macro_result_t = t; macro_defn_t = d } | {
"checked_file": "GlobalEnv.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hashtable.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.All.fst.checked",
"Config.fst.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "GlobalEnv.fst"
} | [
"total"
] | [
"Ast.typ",
"FStar.Pervasives.Native.option",
"Ast.expr",
"GlobalEnv.Mkmacro_signature",
"Prims.Nil",
"GlobalEnv.macro_signature"
] | [] | (*
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 GlobalEnv
(*
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
/// Computed attributes for a decl:
/// -- its size in bytes
/// -- whether or not it ends with a variable-length field (suffix)
/// -- whether or not its validator may fail
/// -- whether the type is an integral type, i.e., can it be decomposed into bitfields
type decl_attributes = {
may_fail:bool;
integral:option integer_type;
bit_order: (bit_order: option bitfield_bit_order { Some? bit_order ==> Some? integral });
has_reader:bool;
parser_weak_kind:weak_kind;
parser_kind_nz:option bool
}
noeq
type macro_signature = {
macro_arguments_t: list typ;
macro_result_t: typ;
macro_defn_t:option expr
} | false | true | GlobalEnv.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 nullary_macro : t: Ast.typ -> d: FStar.Pervasives.Native.option Ast.expr -> GlobalEnv.macro_signature | [] | GlobalEnv.nullary_macro | {
"file_name": "src/3d/GlobalEnv.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | t: Ast.typ -> d: FStar.Pervasives.Native.option Ast.expr -> GlobalEnv.macro_signature | {
"end_col": 18,
"end_line": 55,
"start_col": 2,
"start_line": 53
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ecdsa_verify_p256_st (alg:S.hash_alg_ecdsa) =
msg_len:size_t{v msg_len >= S.min_input_length alg}
-> msg:lbuffer uint8 msg_len
-> public_key:lbuffer uint8 64ul
-> signature_r:lbuffer uint8 32ul
-> signature_s:lbuffer uint8 32ul ->
Stack bool
(requires fun h ->
live h public_key /\ live h signature_r /\ live h signature_s /\ live h msg)
(ensures fun h0 res h1 -> modifies0 h0 h1 /\
res == S.ecdsa_verification_agile alg (v msg_len) (as_seq h0 msg)
(as_seq h0 public_key) (as_seq h0 signature_r) (as_seq h0 signature_s)) | let ecdsa_verify_p256_st (alg: S.hash_alg_ecdsa) = | false | null | false |
msg_len: size_t{v msg_len >= S.min_input_length alg} ->
msg: lbuffer uint8 msg_len ->
public_key: lbuffer uint8 64ul ->
signature_r: lbuffer uint8 32ul ->
signature_s: lbuffer uint8 32ul
-> Stack bool
(requires fun h -> live h public_key /\ live h signature_r /\ live h signature_s /\ live h msg
)
(ensures
fun h0 res h1 ->
modifies0 h0 h1 /\
res ==
S.ecdsa_verification_agile alg
(v msg_len)
(as_seq h0 msg)
(as_seq h0 public_key)
(as_seq h0 signature_r)
(as_seq h0 signature_s)) | {
"checked_file": "Hacl.P256.fsti.checked",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.P256.fsti"
} | [
"total"
] | [
"Spec.P256.hash_alg_ecdsa",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Spec.P256.min_input_length",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.modifies0",
"Prims.eq2",
"Spec.P256.ecdsa_verification_agile",
"Lib.Buffer.as_seq"
] | [] | module Hacl.P256
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Spec.Hash.Definitions
module S = Spec.P256
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
// TODO?: change API for `ecdsa_verify`, namely, take `signature` as an argument
inline_for_extraction noextract
let ecdsa_sign_p256_st (alg:S.hash_alg_ecdsa) =
signature:lbuffer uint8 64ul
-> msg_len:size_t{v msg_len >= S.min_input_length alg}
-> msg:lbuffer uint8 msg_len
-> private_key:lbuffer uint8 32ul
-> nonce:lbuffer uint8 32ul ->
Stack bool
(requires fun h ->
live h signature /\ live h msg /\ live h private_key /\ live h nonce /\
disjoint signature msg /\ disjoint signature private_key /\ disjoint signature nonce)
(ensures fun h0 flag h1 -> modifies (loc signature) h0 h1 /\
(let sgnt = S.ecdsa_signature_agile alg (v msg_len)
(as_seq h0 msg) (as_seq h0 private_key) (as_seq h0 nonce) in
(flag <==> Some? sgnt) /\ (flag ==> (as_seq h1 signature == Some?.v sgnt))))
inline_for_extraction noextract | false | true | Hacl.P256.fsti | {
"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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ecdsa_verify_p256_st : alg: Spec.P256.hash_alg_ecdsa -> Type0 | [] | Hacl.P256.ecdsa_verify_p256_st | {
"file_name": "code/ecdsap256/Hacl.P256.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | alg: Spec.P256.hash_alg_ecdsa -> Type0 | {
"end_col": 77,
"end_line": 49,
"start_col": 4,
"start_line": 39
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ecdsa_sign_p256_st (alg:S.hash_alg_ecdsa) =
signature:lbuffer uint8 64ul
-> msg_len:size_t{v msg_len >= S.min_input_length alg}
-> msg:lbuffer uint8 msg_len
-> private_key:lbuffer uint8 32ul
-> nonce:lbuffer uint8 32ul ->
Stack bool
(requires fun h ->
live h signature /\ live h msg /\ live h private_key /\ live h nonce /\
disjoint signature msg /\ disjoint signature private_key /\ disjoint signature nonce)
(ensures fun h0 flag h1 -> modifies (loc signature) h0 h1 /\
(let sgnt = S.ecdsa_signature_agile alg (v msg_len)
(as_seq h0 msg) (as_seq h0 private_key) (as_seq h0 nonce) in
(flag <==> Some? sgnt) /\ (flag ==> (as_seq h1 signature == Some?.v sgnt)))) | let ecdsa_sign_p256_st (alg: S.hash_alg_ecdsa) = | false | null | false |
signature: lbuffer uint8 64ul ->
msg_len: size_t{v msg_len >= S.min_input_length alg} ->
msg: lbuffer uint8 msg_len ->
private_key: lbuffer uint8 32ul ->
nonce: lbuffer uint8 32ul
-> Stack bool
(requires
fun h ->
live h signature /\ live h msg /\ live h private_key /\ live h nonce /\
disjoint signature msg /\ disjoint signature private_key /\ disjoint signature nonce)
(ensures
fun h0 flag h1 ->
modifies (loc signature) h0 h1 /\
(let sgnt =
S.ecdsa_signature_agile alg
(v msg_len)
(as_seq h0 msg)
(as_seq h0 private_key)
(as_seq h0 nonce)
in
(flag <==> Some? sgnt) /\ (flag ==> (as_seq h1 signature == Some?.v sgnt)))) | {
"checked_file": "Hacl.P256.fsti.checked",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.P256.fsti"
} | [
"total"
] | [
"Spec.P256.hash_alg_ecdsa",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Spec.P256.min_input_length",
"Prims.bool",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.l_iff",
"FStar.Pervasives.Native.uu___is_Some",
"Lib.ByteSequence.lbytes",
"Prims.l_imp",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"FStar.Pervasives.Native.__proj__Some__item__v",
"FStar.Pervasives.Native.option",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.P256.ecdsa_signature_agile"
] | [] | module Hacl.P256
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Spec.Hash.Definitions
module S = Spec.P256
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 30 --fuel 0 --ifuel 0"
// TODO?: change API for `ecdsa_verify`, namely, take `signature` as an argument
inline_for_extraction noextract | false | true | Hacl.P256.fsti | {
"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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ecdsa_sign_p256_st : alg: Spec.P256.hash_alg_ecdsa -> Type0 | [] | Hacl.P256.ecdsa_sign_p256_st | {
"file_name": "code/ecdsap256/Hacl.P256.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | alg: Spec.P256.hash_alg_ecdsa -> Type0 | {
"end_col": 81,
"end_line": 34,
"start_col": 4,
"start_line": 22
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let shift_subst = shift_subst_n 1 | let shift_subst = | false | null | false | shift_subst_n 1 | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.shift_subst_n"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val shift_subst : x: Prims.list FStar.Reflection.Typing.subst_elt -> Prims.list FStar.Reflection.Typing.subst_elt | [] | FStar.Reflection.Typing.shift_subst | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.list FStar.Reflection.Typing.subst_elt -> Prims.list FStar.Reflection.Typing.subst_elt | {
"end_col": 33,
"end_line": 201,
"start_col": 18,
"start_line": 201
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tm_type u = pack_ln (Tv_Type u) | let tm_type u = | false | null | false | pack_ln (Tv_Type u) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.universe",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Type",
"FStar.Reflection.Types.term"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2]) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tm_type : u118: FStar.Reflection.Types.universe -> FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.tm_type | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | u118: FStar.Reflection.Types.universe -> FStar.Reflection.Types.term | {
"end_col": 35,
"end_line": 540,
"start_col": 16,
"start_line": 540
} |
|
Prims.Tot | val sort_default:sort_t | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun | val sort_default:sort_t
let sort_default:sort_t = | false | null | false | FStar.Sealed.Inhabited.seal tun | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Sealed.Inhabited.seal",
"FStar.Reflection.Types.term",
"FStar.Reflection.Typing.tun"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sort_default:sort_t | [] | FStar.Reflection.Typing.sort_default | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Typing.sort_t | {
"end_col": 59,
"end_line": 135,
"start_col": 28,
"start_line": 135
} |
Prims.Tot | val lookup_fvar (e: env) (x: fv) : option term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_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_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x [] | val lookup_fvar (e: env) (x: fv) : option term
let lookup_fvar (e: env) (x: fv) : option term = | false | null | false | lookup_fvar_uinst e x [] | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.env",
"FStar.Reflection.Types.fv",
"FStar.Reflection.Typing.lookup_fvar_uinst",
"Prims.Nil",
"FStar.Reflection.Types.universe",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Types.term"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lookup_fvar (e: env) (x: fv) : option term | [] | FStar.Reflection.Typing.lookup_fvar | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | e: FStar.Reflection.Types.env -> x: FStar.Reflection.Types.fv
-> FStar.Pervasives.Native.option FStar.Reflection.Types.term | {
"end_col": 71,
"end_line": 126,
"start_col": 47,
"start_line": 126
} |
Prims.Tot | val pp_name_default:pp_name_t | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x" | val pp_name_default:pp_name_t
let pp_name_default:pp_name_t = | false | null | false | FStar.Sealed.Inhabited.seal "x" | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Sealed.Inhabited.seal",
"Prims.string"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x [] | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pp_name_default:pp_name_t | [] | FStar.Reflection.Typing.pp_name_default | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Typing.pp_name_t | {
"end_col": 65,
"end_line": 129,
"start_col": 34,
"start_line": 129
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_ghost t = pack_comp (C_GTotal t) | let mk_ghost t = | false | null | false | pack_comp (C_GTotal t) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.typ",
"FStar.Reflection.V2.Builtins.pack_comp",
"FStar.Reflection.V2.Data.C_GTotal",
"FStar.Reflection.Types.comp"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_ghost : t: FStar.Reflection.Types.typ -> FStar.Reflection.Types.comp | [] | FStar.Reflection.Typing.mk_ghost | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.typ -> FStar.Reflection.Types.comp | {
"end_col": 39,
"end_line": 296,
"start_col": 17,
"start_line": 296
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let binder_of_t_q t q = mk_binder pp_name_default t q | let binder_of_t_q t q = | false | null | false | mk_binder pp_name_default t q | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Data.aqualv",
"FStar.Reflection.Typing.mk_binder",
"FStar.Reflection.Typing.pp_name_default",
"FStar.Reflection.Types.binder"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v)) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val binder_of_t_q : t: FStar.Reflection.Types.term -> q: FStar.Reflection.V2.Data.aqualv
-> FStar.Reflection.Types.binder | [] | FStar.Reflection.Typing.binder_of_t_q | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.term -> q: FStar.Reflection.V2.Data.aqualv
-> FStar.Reflection.Types.binder | {
"end_col": 53,
"end_line": 293,
"start_col": 24,
"start_line": 293
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bool_ty = pack_ln (Tv_FVar bool_fv) | let bool_ty = | false | null | false | pack_ln (Tv_FVar bool_fv) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_FVar",
"FStar.Reflection.Typing.bool_fv"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bool_ty : FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.bool_ty | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.term | {
"end_col": 39,
"end_line": 535,
"start_col": 14,
"start_line": 535
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let subst = list subst_elt | let subst = | false | null | false | list subst_elt | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.list",
"FStar.Reflection.Typing.subst_elt"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val subst : Type0 | [] | FStar.Reflection.Typing.subst | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 26,
"end_line": 197,
"start_col": 12,
"start_line": 197
} |
|
Prims.Tot | val b2t_fv:R.fv | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let b2t_fv : R.fv = R.pack_fv b2t_lid | val b2t_fv:R.fv
let b2t_fv:R.fv = | false | null | false | R.pack_fv b2t_lid | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Builtins.pack_fv",
"FStar.Reflection.Typing.b2t_lid"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2 | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val b2t_fv:R.fv | [] | FStar.Reflection.Typing.b2t_fv | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.fv | {
"end_col": 37,
"end_line": 558,
"start_col": 20,
"start_line": 558
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u_max u1 u2 = pack_universe (Uv_Max [u1; u2]) | let u_max u1 u2 = | false | null | false | pack_universe (Uv_Max [u1; u2]) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.universe",
"FStar.Reflection.V2.Builtins.pack_universe",
"FStar.Reflection.V2.Data.Uv_Max",
"Prims.Cons",
"Prims.Nil"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u_max : u1: FStar.Reflection.Types.universe -> u2: FStar.Reflection.Types.universe
-> FStar.Reflection.Types.universe | [] | FStar.Reflection.Typing.u_max | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | u1: FStar.Reflection.Types.universe -> u2: FStar.Reflection.Types.universe
-> FStar.Reflection.Types.universe | {
"end_col": 49,
"end_line": 538,
"start_col": 18,
"start_line": 538
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv) | let tm_prop = | false | null | false | let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_FVar",
"FStar.Reflection.Types.fv",
"FStar.Reflection.V2.Builtins.pack_fv",
"FStar.Reflection.Const.prop_qn"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tm_prop : FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.tm_prop | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.term | {
"end_col": 29,
"end_line": 543,
"start_col": 13,
"start_line": 541
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let unit_exp = constant_as_term C_Unit | let unit_exp = | false | null | false | constant_as_term C_Unit | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.constant_as_term",
"FStar.Reflection.V2.Data.C_Unit"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))] | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val unit_exp : FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.unit_exp | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.term | {
"end_col": 38,
"end_line": 531,
"start_col": 15,
"start_line": 531
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bool_fv = pack_fv bool_lid | let bool_fv = | false | null | false | pack_fv bool_lid | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Builtins.pack_fv",
"FStar.Reflection.Const.bool_lid"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bool_fv : FStar.Reflection.Types.fv | [] | FStar.Reflection.Typing.bool_fv | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.fv | {
"end_col": 30,
"end_line": 534,
"start_col": 14,
"start_line": 534
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let constant_as_term (v:vconst) = pack_ln (Tv_Const v) | let constant_as_term (v: vconst) = | false | null | false | pack_ln (Tv_Const v) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Data.vconst",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Const",
"FStar.Reflection.Types.term"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))] | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val constant_as_term : v: FStar.Reflection.V2.Data.vconst -> FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.constant_as_term | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | v: FStar.Reflection.V2.Data.vconst -> FStar.Reflection.Types.term | {
"end_col": 54,
"end_line": 530,
"start_col": 34,
"start_line": 530
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ln_comp (c:comp) = ln'_comp c (-1) | let ln_comp (c: comp) = | false | null | false | ln'_comp c (- 1) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.comp",
"FStar.Reflection.Typing.ln'_comp",
"Prims.op_Minus",
"Prims.bool"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_ | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ln_comp : c: FStar.Reflection.Types.comp -> Prims.bool | [] | FStar.Reflection.Typing.ln_comp | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | c: FStar.Reflection.Types.comp -> Prims.bool | {
"end_col": 38,
"end_line": 858,
"start_col": 23,
"start_line": 858
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ] | let close_comp_typ' (c: comp_typ) (x: var) (i: nat) = | false | null | false | fst c, subst_term (snd c) [ND x i] | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.comp_typ",
"FStar.Reflection.V2.Data.var",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"FStar.Reflection.Types.term",
"FStar.Pervasives.Native.fst",
"FStar.Reflection.Types.typ",
"FStar.Reflection.Typing.subst_term",
"FStar.Pervasives.Native.snd",
"Prims.Cons",
"FStar.Reflection.Typing.subst_elt",
"FStar.Reflection.Typing.ND",
"Prims.Nil",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_comp_typ' : c: FStar.Reflection.Typing.comp_typ -> x: FStar.Reflection.V2.Data.var -> i: Prims.nat
-> FStar.Stubs.TypeChecker.Core.tot_or_ghost * FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.close_comp_typ' | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | c: FStar.Reflection.Typing.comp_typ -> x: FStar.Reflection.V2.Data.var -> i: Prims.nat
-> FStar.Stubs.TypeChecker.Core.tot_or_ghost * FStar.Reflection.Types.term | {
"end_col": 38,
"end_line": 992,
"start_col": 2,
"start_line": 992
} |
|
Prims.Tot | val close_term_vs (vs: list var) (t: term) : term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t | val close_term_vs (vs: list var) (t: term) : term
let close_term_vs (vs: list var) (t: term) : term = | false | null | false | __close_term_vs 0 vs t | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.list",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.Types.term",
"FStar.Reflection.Typing.__close_term_vs"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i] | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_term_vs (vs: list var) (t: term) : term | [] | FStar.Reflection.Typing.close_term_vs | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | vs: Prims.list FStar.Reflection.V2.Data.var -> t: FStar.Reflection.Types.term
-> FStar.Reflection.Types.term | {
"end_col": 24,
"end_line": 1045,
"start_col": 2,
"start_line": 1045
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let freevars_comp_typ (c:comp_typ) = freevars (snd c) | let freevars_comp_typ (c: comp_typ) = | false | null | false | freevars (snd c) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.comp_typ",
"FStar.Reflection.Typing.freevars",
"FStar.Pervasives.Native.snd",
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"FStar.Reflection.Types.typ",
"FStar.Set.set",
"FStar.Reflection.V2.Data.var"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0 | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val freevars_comp_typ : c: FStar.Reflection.Typing.comp_typ -> FStar.Set.set FStar.Reflection.V2.Data.var | [] | FStar.Reflection.Typing.freevars_comp_typ | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | c: FStar.Reflection.Typing.comp_typ -> FStar.Set.set FStar.Reflection.V2.Data.var | {
"end_col": 53,
"end_line": 1003,
"start_col": 37,
"start_line": 1003
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fstar_env_fvs (g:R.env) =
lookup_fvar g unit_fv == Some (tm_type u_zero) /\
lookup_fvar g bool_fv == Some (tm_type u_zero) /\
lookup_fvar g b2t_fv == Some b2t_ty | let fstar_env_fvs (g: R.env) = | false | null | false | lookup_fvar g unit_fv == Some (tm_type u_zero) /\ lookup_fvar g bool_fv == Some (tm_type u_zero) /\
lookup_fvar g b2t_fv == Some b2t_ty | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.env",
"Prims.l_and",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Types.term",
"FStar.Reflection.Typing.lookup_fvar",
"FStar.Reflection.Typing.unit_fv",
"FStar.Pervasives.Native.Some",
"FStar.Reflection.Typing.tm_type",
"FStar.Reflection.Typing.u_zero",
"FStar.Reflection.Typing.bool_fv",
"FStar.Reflection.Typing.b2t_fv",
"FStar.Reflection.Typing.b2t_ty",
"Prims.logical"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs
let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs
[@@ no_auto_projectors]
noeq
type non_informative : env -> term -> Type0 =
| Non_informative_type:
g:env ->
u:universe ->
non_informative g (pack_ln (Tv_Type u))
| Non_informative_fv:
g:env ->
x:fv{is_non_informative_fv x} ->
non_informative g (pack_ln (Tv_FVar x))
| Non_informative_uinst:
g:env ->
x:fv{is_non_informative_fv x} ->
us:list universe ->
non_informative g (pack_ln (Tv_UInst x us))
| Non_informative_app:
g:env ->
t:term ->
arg:argv ->
non_informative g t ->
non_informative g (pack_ln (Tv_App t arg))
| Non_informative_total_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g t1 ->
non_informative g (mk_arrow_ct t0 q (T.E_Total, t1))
| Non_informative_ghost_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g (mk_arrow_ct t0 q (T.E_Ghost, t1))
| Non_informative_token:
g:env ->
t:typ ->
squash (T.non_informative_token g t) ->
non_informative g t
val bindings_ok_for_pat : env -> list R.binding -> pattern -> Type0
val bindings_ok_pat_constant :
g:env -> c:R.vconst -> Lemma (bindings_ok_for_pat g [] (Pat_Constant c))
let bindings_ok_for_branch (g:env) (bs : list R.binding) (br : branch) : Type0 =
bindings_ok_for_pat g bs (fst br)
let bindings_ok_for_branch_N (g:env) (bss : list (list R.binding)) (brs : list branch) =
zip2prop (bindings_ok_for_branch g) bss brs
let binding_to_namedv (b:R.binding) : Tot namedv =
pack_namedv {
RD.uniq = b.uniq;
RD.sort = seal b.sort;
RD.ppname = b.ppname;
}
(* Elaborates the p pattern into a term, using the bs bindings for the
pattern variables. The resulting term is properly scoped only on an
environment which contains all of bs. See for instance the branch_typing
judg. Returns an option, since this can fail if e.g. there are not
enough bindings, and returns the list of unused binders as well, which
should be empty if the list of binding was indeed ok. *)
let rec elaborate_pat (p : pattern) (bs : list R.binding) : Tot (option (term & list R.binding)) (decreases p) =
match p, bs with
| Pat_Constant c, _ -> Some (pack_ln (Tv_Const c), bs)
| Pat_Cons fv univs subpats, bs ->
let head = pack_ln (Tv_FVar fv) in
fold_left_dec
(Some (head, bs))
subpats
(fun st pi ->
let (p,i) = pi in
match st with | None -> None | Some (head, bs) ->
match elaborate_pat p bs with | None -> None | Some (t, bs') -> Some (pack_ln (Tv_App head (t, (if i then Q_Implicit else Q_Explicit))), bs'))
| Pat_Var _ _, b::bs ->
Some (pack_ln (Tv_Var (binding_to_namedv b)), bs)
| Pat_Dot_Term (Some t), _ -> Some (t, bs)
| Pat_Dot_Term None, _ -> None
| _ -> None
[@@ no_auto_projectors]
noeq
type typing : env -> term -> comp_typ -> Type0 =
| T_Token :
g:env ->
e:term ->
c:comp_typ ->
squash (T.typing_token g e c) ->
typing g e c
| T_Var :
g:env ->
x:namedv { Some? (lookup_bvar g (namedv_uniq x)) } ->
typing g (pack_ln (Tv_Var x)) (T.E_Total, Some?.v (lookup_bvar g (namedv_uniq x)))
| T_FVar :
g:env ->
x:fv { Some? (lookup_fvar g x) } ->
typing g (pack_ln (Tv_FVar x)) (T.E_Total, Some?.v (lookup_fvar g x))
| T_UInst :
g:env ->
x:fv ->
us:list universe { Some? (lookup_fvar_uinst g x us) } ->
typing g (pack_ln (Tv_UInst x us)) (T.E_Total, Some?.v (lookup_fvar_uinst g x us))
| T_Const:
g:env ->
v:vconst ->
t:term ->
constant_typing v t ->
typing g (constant_as_term v) (T.E_Total, t)
| T_Abs :
g:env ->
x:var { None? (lookup_bvar g x) } ->
ty:term ->
body:term { ~(x `Set.mem` freevars body) } ->
body_c:comp_typ ->
u:universe ->
pp_name:pp_name_t ->
q:aqualv ->
ty_eff:T.tot_or_ghost ->
typing g ty (ty_eff, tm_type u) ->
typing (extend_env g x ty) (open_term body x) body_c ->
typing g (pack_ln (Tv_Abs (mk_binder pp_name ty q) body))
(T.E_Total,
pack_ln (Tv_Arrow (mk_binder pp_name ty q)
(mk_comp (close_comp_typ body_c x))))
| T_App :
g:env ->
e1:term ->
e2:term ->
x:binder ->
t:term ->
eff:T.tot_or_ghost ->
typing g e1 (eff, pack_ln (Tv_Arrow x (mk_comp (eff, t)))) ->
typing g e2 (eff, binder_sort x) ->
typing g (pack_ln (Tv_App e1 (e2, binder_qual x)))
(eff, open_with t e2)
| T_Let:
g:env ->
x:var { None? (lookup_bvar g x) } ->
e1:term ->
t1:typ ->
e2:term ->
t2:typ ->
eff:T.tot_or_ghost ->
pp_name:pp_name_t ->
typing g e1 (eff, t1) ->
typing (extend_env g x t1) (open_term e2 x) (eff, t2) ->
typing g (mk_let pp_name e1 t1 e2) (eff, open_with (close_term t2 x) e1)
| T_Arrow:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t1:term ->
t2:term { ~(x `Set.mem` freevars t2) } ->
u1:universe ->
u2:universe ->
pp_name:pp_name_t ->
q:aqualv ->
eff:T.tot_or_ghost ->
t1_eff:T.tot_or_ghost ->
t2_eff:T.tot_or_ghost ->
typing g t1 (t1_eff, tm_type u1) ->
typing (extend_env g x t1) (open_term t2 x) (t2_eff, tm_type u2) ->
typing g (pack_ln (Tv_Arrow (mk_binder pp_name t1 q) (mk_comp (eff, t2))))
(T.E_Total, tm_type (u_max u1 u2))
| T_Refine:
g:env ->
x:var { None? (lookup_bvar g x) } ->
t:term ->
e:term { ~(x `Set.mem` freevars e) } ->
u1:universe ->
u2:universe ->
t_eff:T.tot_or_ghost ->
e_eff:T.tot_or_ghost ->
typing g t (t_eff, tm_type u1) ->
typing (extend_env g x t) (open_term e x) (e_eff, tm_type u2) ->
typing g (pack_ln (Tv_Refine (mk_simple_binder pp_name_default t) e)) (T.E_Total, tm_type u1)
| T_PropIrrelevance:
g:env ->
e:term ->
t:term ->
e_eff:T.tot_or_ghost ->
t_eff:T.tot_or_ghost ->
typing g e (e_eff, t) ->
typing g t (t_eff, tm_prop) ->
typing g (`()) (T.E_Total, t)
| T_Sub:
g:env ->
e:term ->
c:comp_typ ->
c':comp_typ ->
typing g e c ->
sub_comp g c c' ->
typing g e c'
| T_If:
g:env ->
scrutinee:term ->
then_:term ->
else_:term ->
ty:term ->
u_ty:universe ->
hyp:var { None? (lookup_bvar g hyp) /\ ~(hyp `Set.mem` (freevars then_ `Set.union` freevars else_)) } ->
eff:T.tot_or_ghost ->
ty_eff:T.tot_or_ghost ->
typing g scrutinee (eff, bool_ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee true_bool)) then_ (eff, ty) ->
typing (extend_env g hyp (eq2 (pack_universe Uv_Zero) bool_ty scrutinee false_bool)) else_ (eff, ty) ->
typing g ty (ty_eff, tm_type u_ty) -> //typedness of ty cannot rely on hyp
typing g (mk_if scrutinee then_ else_) (eff, ty)
| T_Match:
g:env ->
sc_u : universe ->
sc_ty : typ ->
sc : term ->
ty_eff:T.tot_or_ghost ->
typing g sc_ty (ty_eff, tm_type sc_u) ->
eff:T.tot_or_ghost ->
typing g sc (eff, sc_ty) ->
branches:list branch ->
ty:comp_typ ->
bnds:list (list R.binding) ->
complet : match_is_complete g sc sc_ty (List.Tot.map fst branches) bnds -> // complete patterns
branches_typing g sc_u sc_ty sc ty branches bnds -> // each branch has proper type
typing g (pack_ln (Tv_Match sc None branches)) ty
and related : env -> term -> relation -> term -> Type0 =
| Rel_refl:
g:env ->
t:term ->
rel:relation ->
related g t rel t
| Rel_sym:
g:env ->
t0:term ->
t1:term ->
related g t0 R_Eq t1 ->
related g t1 R_Eq t0
| Rel_trans:
g:env ->
t0:term ->
t1:term ->
t2:term ->
rel:relation ->
related g t0 rel t1 ->
related g t1 rel t2 ->
related g t0 rel t2
| Rel_univ:
g:env ->
u:universe ->
v:universe ->
univ_eq u v ->
related g (tm_type u) R_Eq (tm_type v)
| Rel_beta:
g:env ->
t:typ ->
q:aqualv ->
e:term { ln' e 0 } ->
arg:term { ln arg } ->
related g (R.pack_ln (R.Tv_App (mk_abs t q e) (arg, q)))
R_Eq
(subst_term e [ DT 0 arg ])
| Rel_eq_token:
g:env ->
t0:term ->
t1:term ->
squash (T.equiv_token g t0 t1) ->
related g t0 R_Eq t1
| Rel_subtyping_token:
g:env ->
t0:term ->
t1:term ->
squash (T.subtyping_token g t0 t1) ->
related g t0 R_Sub t1
| Rel_equiv:
g:env ->
t0:term ->
t1:term ->
rel:relation ->
related g t0 R_Eq t1 ->
related g t0 rel t1
| Rel_arrow:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
c1:comp_typ ->
c2:comp_typ ->
rel:relation ->
x:var{
None? (lookup_bvar g x) /\
~ (x `Set.mem` (freevars_comp_typ c1 `Set.union` freevars_comp_typ c2))
} ->
related g t2 rel t1 ->
related_comp (extend_env g x t2)
(open_comp_typ c1 x)
rel
(open_comp_typ c2 x) ->
related g (mk_arrow_ct t1 q c1) rel (mk_arrow_ct t2 q c2)
| Rel_abs:
g:env ->
t1:term ->
t2:term ->
q:aqualv ->
e1:term ->
e2:term ->
x:var{
None? (lookup_bvar g x) /\ ~ (x `Set.mem` (freevars e1 `Set.union` freevars e2))
} ->
related g t1 R_Eq t2 ->
related (extend_env g x t1)
(subst_term e1 (open_with_var x 0))
R_Eq
(subst_term e2 (open_with_var x 0)) ->
related g (mk_abs t1 q e1) R_Eq (mk_abs t2 q e2)
| Rel_ctxt:
g:env ->
t0:term ->
t1:term ->
ctxt:term_ctxt ->
related g t0 R_Eq t1 ->
related g (apply_term_ctxt ctxt t0) R_Eq (apply_term_ctxt ctxt t1)
and related_comp : env -> comp_typ -> relation -> comp_typ -> Type0 =
| Relc_typ:
g:env ->
t0:term ->
t1:term ->
eff:T.tot_or_ghost ->
rel:relation ->
related g t0 rel t1 ->
related_comp g (eff, t0) rel (eff, t1)
| Relc_total_ghost:
g:env ->
t:term ->
related_comp g (T.E_Total, t) R_Sub (T.E_Ghost, t)
| Relc_ghost_total:
g:env ->
t:term ->
non_informative g t ->
related_comp g (T.E_Ghost, t) R_Sub (T.E_Total, t)
and branches_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (brs:list branch) -> (bnds : list (list R.binding)) -> Type0
=
(* This judgement only enforces that branch_typing holds for every
element of brs and its respective bnds (which must have the same
length). *)
| BT_Nil :
branches_typing g sc_u sc_ty sc rty [] []
| BT_S :
br : branch ->
bnds : list R.binding ->
pf : branch_typing g sc_u sc_ty sc rty br bnds ->
rest_br : list branch ->
rest_bnds : list (list R.binding) ->
rest : branches_typing g sc_u sc_ty sc rty rest_br rest_bnds ->
branches_typing g sc_u sc_ty sc rty (br :: rest_br) (bnds :: rest_bnds)
and branch_typing (g:env) (sc_u:universe) (sc_ty:typ) (sc:term) (rty:comp_typ)
: (br : branch) -> (bnds : list R.binding) -> Type0
=
| BO :
pat : pattern ->
bnds : list R.binding{bindings_ok_for_pat g bnds pat} ->
hyp_var:var{None? (lookup_bvar (extend_env_l g (refl_bindings_to_bindings bnds)) hyp_var)} ->
body:term ->
_ : squash (Some? (elaborate_pat pat bnds)) ->
typing (extend_env
(extend_env_l g (refl_bindings_to_bindings bnds))
hyp_var (eq2 sc_u sc_ty sc (fst (Some?.v (elaborate_pat pat bnds))))
)
body rty ->
branch_typing g sc_u sc_ty sc rty
(pat, close_term_bs (refl_bindings_to_bindings bnds) body)
bnds
and match_is_complete : env -> term -> typ -> list pattern -> list (list R.binding) -> Type0 =
| MC_Tok :
env:_ ->
sc:_ ->
ty:_ ->
pats:_ ->
bnds:_ ->
squash (T.match_complete_token env sc ty pats bnds) -> match_is_complete env sc ty pats bnds
and sub_typing (g:env) (t1 t2:term) = related g t1 R_Sub t2
and sub_comp (g:env) (c1 c2:comp_typ) = related_comp g c1 R_Sub c2
and equiv (g:env) (t1 t2:term) = related g t1 R_Eq t2
type tot_typing (g:env) (e:term) (t:term) = typing g e (T.E_Total, t)
type ghost_typing (g:env) (e:term) (t:term) = typing g e (T.E_Ghost, t)
val subtyping_token_renaming (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(y:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) y) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (rename_bindings bs1 x y@(y,t)::bs0))
(rename t0 x y)
(rename t1 x y)
val subtyping_token_weakening (g:env)
(bs0:bindings)
(bs1:bindings)
(x:var { None? (lookup_bvar (extend_env_l g (bs1@bs0)) x) })
(t:term)
(t0 t1:term)
(d:T.subtyping_token (extend_env_l g (bs1@bs0)) t0 t1)
: T.subtyping_token (extend_env_l g (bs1@(x,t)::bs0)) t0 t1
let simplify_umax (#g:R.env) (#t:R.term) (#u:R.universe)
(d:typing g t (T.E_Total, tm_type (u_max u u)))
: typing g t (T.E_Total, tm_type u)
= let ue
: univ_eq (u_max u u) u
= UN_MaxLeq u u (UNLEQ_Refl u)
in
let du : related g (tm_type (u_max u u)) R_Eq (tm_type u)
= Rel_univ g (u_max u u) u ue in
let du : related g (tm_type (u_max u u)) R_Sub (tm_type u)
= Rel_equiv _ _ _ _ du in
T_Sub _ _ _ _ d (Relc_typ _ _ _ T.E_Total _ du)
val well_typed_terms_are_ln (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: Lemma (ensures ln e /\ ln (snd c))
val type_correctness (g:R.env) (e:R.term) (c:comp_typ) (_:typing g e c)
: GTot (u:R.universe & typing g (snd c) (T.E_Total, tm_type u))
val binder_offset_pattern_invariant (p:pattern) (ss:subst)
: Lemma (binder_offset_pattern p == binder_offset_pattern (subst_pattern p ss))
val binder_offset_patterns_invariant (p:list (pattern & bool)) (ss:subst)
: Lemma (binder_offset_patterns p == binder_offset_patterns (subst_patterns p ss))
val open_close_inverse' (i:nat) (t:term { ln' t (i - 1) }) (x:var)
: Lemma
(ensures subst_term
(subst_term t [ ND x i ])
(open_with_var x i)
== t)
val open_close_inverse'_binder (i:nat) (b:binder { ln'_binder b (i - 1) }) (x:var)
: Lemma (ensures subst_binder
(subst_binder b [ ND x i ])
(open_with_var x i)
== b)
val open_close_inverse'_terms (i:nat) (ts:list term { ln'_terms ts (i - 1) }) (x:var)
: Lemma (ensures subst_terms
(subst_terms ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_comp (i:nat) (c:comp { ln'_comp c (i - 1) }) (x:var)
: Lemma
(ensures subst_comp
(subst_comp c [ ND x i ])
(open_with_var x i)
== c)
val open_close_inverse'_args (i:nat)
(ts:list argv { ln'_args ts (i - 1) })
(x:var)
: Lemma
(ensures subst_args
(subst_args ts [ ND x i ])
(open_with_var x i)
== ts)
val open_close_inverse'_patterns (i:nat)
(ps:list (pattern & bool) { ln'_patterns ps (i - 1) })
(x:var)
: Lemma
(ensures subst_patterns
(subst_patterns ps [ ND x i ])
(open_with_var x i)
== ps)
val open_close_inverse'_pattern (i:nat) (p:pattern{ln'_pattern p (i - 1)}) (x:var)
: Lemma
(ensures subst_pattern
(subst_pattern p [ ND x i ])
(open_with_var x i)
== p)
val open_close_inverse'_branch (i:nat) (br:branch{ln'_branch br (i - 1)}) (x:var)
: Lemma
(ensures subst_branch
(subst_branch br [ ND x i ])
(open_with_var x i)
== br)
val open_close_inverse'_branches (i:nat)
(brs:list branch { ln'_branches brs (i - 1) })
(x:var)
: Lemma
(ensures subst_branches
(subst_branches brs [ ND x i ])
(open_with_var x i)
== brs)
val open_close_inverse'_match_returns (i:nat)
(m:match_returns_ascription { ln'_match_returns m (i - 1) })
(x:var)
: Lemma
(ensures subst_match_returns
(subst_match_returns m [ ND x i ])
(open_with_var x i)
== m)
val open_close_inverse (e:R.term { ln e }) (x:var)
: Lemma (open_term (close_term e x) x == e)
val close_open_inverse' (i:nat)
(t:term)
(x:var { ~(x `Set.mem` freevars t) })
: Lemma
(ensures subst_term
(subst_term t (open_with_var x i))
[ ND x i ]
== t)
val close_open_inverse'_comp (i:nat)
(c:comp)
(x:var{ ~(x `Set.mem` freevars_comp c) })
: Lemma
(ensures subst_comp
(subst_comp c (open_with_var x i))
[ ND x i ]
== c)
val close_open_inverse'_args (i:nat) (args:list argv) (x:var{ ~(x `Set.mem` freevars_args args) })
: Lemma
(ensures subst_args
(subst_args args (open_with_var x i))
[ ND x i]
== args)
val close_open_inverse'_binder (i:nat) (b:binder) (x:var{ ~(x `Set.mem` freevars_binder b) })
: Lemma
(ensures subst_binder
(subst_binder b (open_with_var x i))
[ ND x i ]
== b)
val close_open_inverse'_terms (i:nat) (ts:list term) (x:var{ ~(x `Set.mem` freevars_terms ts) })
: Lemma
(ensures subst_terms
(subst_terms ts (open_with_var x i))
[ ND x i ]
== ts)
val close_open_inverse'_branches (i:nat) (brs:list branch)
(x:var{ ~(x `Set.mem` freevars_branches brs) })
: Lemma
(ensures subst_branches
(subst_branches brs (open_with_var x i))
[ ND x i ]
== brs)
val close_open_inverse'_branch (i:nat)
(br:branch)
(x:var{ ~(x `Set.mem` freevars_branch br) })
: Lemma
(ensures subst_branch
(subst_branch br (open_with_var x i))
[ ND x i ]
== br)
val close_open_inverse'_pattern (i:nat)
(p:pattern)
(x:var{ ~(x `Set.mem` freevars_pattern p) })
: Lemma
(ensures subst_pattern
(subst_pattern p (open_with_var x i))
[ ND x i ]
== p)
val close_open_inverse'_patterns (i:nat)
(ps:list (pattern & bool))
(x:var {~ (x `Set.mem` freevars_patterns ps) })
: Lemma
(ensures subst_patterns
(subst_patterns ps (open_with_var x i))
[ ND x i ]
== ps)
val close_open_inverse'_match_returns (i:nat) (m:match_returns_ascription)
(x:var{ ~(x `Set.mem` freevars_match_returns m) })
: Lemma
(ensures subst_match_returns
(subst_match_returns m (open_with_var x i))
[ ND x i ]
== m)
val close_open_inverse (e:R.term) (x:var {~ (x `Set.mem` freevars e) })
: Lemma (close_term (open_term e x) x == e)
//
// fst has corresponding lemmas for other syntax classes
//
val close_with_not_free_var (t:R.term) (x:var) (i:nat)
: Lemma
(requires ~ (Set.mem x (freevars t)))
(ensures subst_term t [ ND x i ] == t)
// this also requires x to be not in freevars e1 `Set.union` freevars e2
val equiv_arrow (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var { None? (lookup_bvar g x) })
(eq:equiv (extend_env g x ty)
(subst_term e1 (open_with_var x 0))
(subst_term e2 (open_with_var x 0)))
: equiv g (mk_arrow ty q e1)
(mk_arrow ty q e2)
// the proof for this requires e1 and e2 to be ln
val equiv_abs_close (#g:R.env) (#e1 #e2:R.term) (ty:R.typ) (q:R.aqualv)
(x:var{None? (lookup_bvar g x)})
(eq:equiv (extend_env g x ty) e1 e2)
: equiv g (mk_abs ty q (subst_term e1 [ ND x 0 ]))
(mk_abs ty q (subst_term e2 [ ND x 0 ]))
val open_with_gt_ln (e:term) (i:nat) (t:term) (j:nat)
: Lemma
(requires ln' e i /\ i < j)
(ensures subst_term e [ DT j t ] == e)
[SMTPat (ln' e i); SMTPat (subst_term e [ DT j t ])]
//
// Type of the top-level tactic that would splice-in the definitions
// | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fstar_env_fvs : g: FStar.Reflection.Types.env -> Prims.logical | [] | FStar.Reflection.Typing.fstar_env_fvs | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | g: FStar.Reflection.Types.env -> Prims.logical | {
"end_col": 38,
"end_line": 1741,
"start_col": 2,
"start_line": 1739
} |
|
Prims.Tot | val namedv_uniq (x: namedv) : var | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq | val namedv_uniq (x: namedv) : var
let namedv_uniq (x: namedv) : var = | false | null | false | (inspect_namedv x).uniq | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.namedv",
"FStar.Reflection.V2.Data.__proj__Mknamedv_view__item__uniq",
"FStar.Reflection.V2.Builtins.inspect_namedv",
"FStar.Reflection.V2.Data.var"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val namedv_uniq (x: namedv) : var | [] | FStar.Reflection.Typing.namedv_uniq | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Reflection.Types.namedv -> FStar.Reflection.V2.Data.var | {
"end_col": 27,
"end_line": 178,
"start_col": 4,
"start_line": 178
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tun = pack_ln Tv_Unknown | let tun = | false | null | false | pack_ln Tv_Unknown | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Unknown"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tun : FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.tun | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.term | {
"end_col": 28,
"end_line": 132,
"start_col": 10,
"start_line": 132
} |
|
Prims.Tot | val open_with_var (x: var) (i: nat) : subst | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i] | val open_with_var (x: var) (i: nat) : subst
let open_with_var (x: var) (i: nat) : subst = | false | null | false | [open_with_var_elt x i] | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Data.var",
"Prims.nat",
"Prims.Cons",
"FStar.Reflection.Typing.subst_elt",
"FStar.Reflection.Typing.open_with_var_elt",
"Prims.Nil",
"FStar.Reflection.Typing.subst"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt = | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_with_var (x: var) (i: nat) : subst | [] | FStar.Reflection.Typing.open_with_var | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Reflection.V2.Data.var -> i: Prims.nat -> FStar.Reflection.Typing.subst | {
"end_col": 67,
"end_line": 307,
"start_col": 44,
"start_line": 307
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None | let maybe_uniq_of_term (x: term) = | false | null | false | match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.inspect_ln",
"FStar.Reflection.Types.namedv",
"FStar.Pervasives.Native.Some",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.Typing.namedv_uniq",
"FStar.Reflection.V2.Data.term_view",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1 | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val maybe_uniq_of_term : x: FStar.Reflection.Types.term -> FStar.Pervasives.Native.option FStar.Reflection.V2.Data.var | [] | FStar.Reflection.Typing.maybe_uniq_of_term | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Reflection.Types.term -> FStar.Pervasives.Native.option FStar.Reflection.V2.Data.var | {
"end_col": 13,
"end_line": 206,
"start_col": 2,
"start_line": 204
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let binder_sort (b:binder) =
(inspect_binder b).sort | let binder_sort (b: binder) = | false | null | false | (inspect_binder b).sort | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.binder",
"FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__sort",
"FStar.Reflection.V2.Builtins.inspect_binder",
"FStar.Reflection.Types.typ"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val binder_sort : b: FStar.Reflection.Types.binder -> FStar.Reflection.Types.typ | [] | FStar.Reflection.Typing.binder_sort | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Reflection.Types.binder -> FStar.Reflection.Types.typ | {
"end_col": 25,
"end_line": 181,
"start_col": 2,
"start_line": 181
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q | let binder_qual (b: binder) = | false | null | false | let { qual = q } = inspect_binder b in
q | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.binder",
"FStar.Reflection.Types.typ",
"FStar.Reflection.V2.Data.aqualv",
"Prims.list",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Data.ppname_t",
"FStar.Reflection.V2.Data.binder_view",
"Prims.precedes",
"FStar.Reflection.V2.Builtins.inspect_binder"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val binder_qual : b: FStar.Reflection.Types.binder -> FStar.Reflection.V2.Data.aqualv | [] | FStar.Reflection.Typing.binder_qual | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Reflection.Types.binder -> FStar.Reflection.V2.Data.aqualv | {
"end_col": 42,
"end_line": 184,
"start_col": 28,
"start_line": 183
} |
|
Prims.Tot | val bv_index (x: bv) : var | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bv_index (x:bv)
: var
= (inspect_bv x).index | val bv_index (x: bv) : var
let bv_index (x: bv) : var = | false | null | false | (inspect_bv x).index | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.bv",
"FStar.Reflection.V2.Data.__proj__Mkbv_view__item__index",
"FStar.Reflection.V2.Builtins.inspect_bv",
"FStar.Reflection.V2.Data.var"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bv_index (x: bv) : var | [] | FStar.Reflection.Typing.bv_index | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Reflection.Types.bv -> FStar.Reflection.V2.Data.var | {
"end_col": 24,
"end_line": 174,
"start_col": 4,
"start_line": 174
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let shift_subst_n (n:nat) = L.map (shift_subst_elt n) | let shift_subst_n (n: nat) = | false | null | false | L.map (shift_subst_elt n) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.nat",
"FStar.List.Tot.Base.map",
"FStar.Reflection.Typing.subst_elt",
"FStar.Reflection.Typing.shift_subst_elt",
"Prims.list"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val shift_subst_n : n: Prims.nat -> x: Prims.list FStar.Reflection.Typing.subst_elt
-> Prims.list FStar.Reflection.Typing.subst_elt | [] | FStar.Reflection.Typing.shift_subst_n | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | n: Prims.nat -> x: Prims.list FStar.Reflection.Typing.subst_elt
-> Prims.list FStar.Reflection.Typing.subst_elt | {
"end_col": 53,
"end_line": 199,
"start_col": 28,
"start_line": 199
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let var_as_bv (v:nat) = pack_bv (make_bv v) | let var_as_bv (v: nat) = | false | null | false | pack_bv (make_bv v) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.nat",
"FStar.Reflection.V2.Builtins.pack_bv",
"FStar.Reflection.Typing.make_bv",
"FStar.Reflection.Types.bv"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
} | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val var_as_bv : v: Prims.nat -> FStar.Reflection.Types.bv | [] | FStar.Reflection.Typing.var_as_bv | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | v: Prims.nat -> FStar.Reflection.Types.bv | {
"end_col": 43,
"end_line": 270,
"start_col": 24,
"start_line": 270
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sort_t = FStar.Sealed.Inhabited.sealed tun | let sort_t = | false | null | false | FStar.Sealed.Inhabited.sealed tun | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Sealed.Inhabited.sealed",
"FStar.Reflection.Types.term",
"FStar.Reflection.Typing.tun"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sort_t : Type0 | [] | FStar.Reflection.Typing.sort_t | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 46,
"end_line": 134,
"start_col": 13,
"start_line": 134
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pp_name_t = FStar.Sealed.Inhabited.sealed "x" | let pp_name_t = | false | null | false | FStar.Sealed.Inhabited.sealed "x" | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Sealed.Inhabited.sealed",
"Prims.string"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x [] | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pp_name_t : Type0 | [] | FStar.Reflection.Typing.pp_name_t | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 49,
"end_line": 128,
"start_col": 16,
"start_line": 128
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_total t = pack_comp (C_Total t) | let mk_total t = | false | null | false | pack_comp (C_Total t) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.typ",
"FStar.Reflection.V2.Builtins.pack_comp",
"FStar.Reflection.V2.Data.C_Total",
"FStar.Reflection.Types.comp"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_total : t: FStar.Reflection.Types.typ -> FStar.Reflection.Types.comp | [] | FStar.Reflection.Typing.mk_total | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.typ -> FStar.Reflection.Types.comp | {
"end_col": 38,
"end_line": 295,
"start_col": 17,
"start_line": 295
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let unit_fv = pack_fv unit_lid | let unit_fv = | false | null | false | pack_fv unit_lid | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Builtins.pack_fv",
"FStar.Reflection.Const.unit_lid"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val unit_fv : FStar.Reflection.Types.fv | [] | FStar.Reflection.Typing.unit_fv | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.fv | {
"end_col": 30,
"end_line": 532,
"start_col": 14,
"start_line": 532
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2) | let mk_let ppname (e1: R.term) (t1: R.term) (e2: R.term) = | false | null | false | R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.pp_name_t",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Let",
"Prims.Nil",
"FStar.Reflection.Typing.mk_simple_binder"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i))) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_let : ppname: FStar.Reflection.Typing.pp_name_t ->
e1: FStar.Reflection.Types.term ->
t1: FStar.Reflection.Types.term ->
e2: FStar.Reflection.Types.term
-> FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.mk_let | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
ppname: FStar.Reflection.Typing.pp_name_t ->
e1: FStar.Reflection.Types.term ->
t1: FStar.Reflection.Types.term ->
e2: FStar.Reflection.Types.term
-> FStar.Reflection.Types.term | {
"end_col": 66,
"end_line": 303,
"start_col": 2,
"start_line": 303
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let unit_ty = pack_ln (Tv_FVar unit_fv) | let unit_ty = | false | null | false | pack_ln (Tv_FVar unit_fv) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_FVar",
"FStar.Reflection.Typing.unit_fv"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val unit_ty : FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.unit_ty | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.term | {
"end_col": 39,
"end_line": 533,
"start_col": 14,
"start_line": 533
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u_zero = pack_universe Uv_Zero | let u_zero = | false | null | false | pack_universe Uv_Zero | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Builtins.pack_universe",
"FStar.Reflection.V2.Data.Uv_Zero"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u_zero : FStar.Reflection.Types.universe | [] | FStar.Reflection.Typing.u_zero | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.universe | {
"end_col": 34,
"end_line": 537,
"start_col": 13,
"start_line": 537
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v)) | let var_as_term (v: var) = | false | null | false | pack_ln (Tv_Var (var_as_namedv v)) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Var",
"FStar.Reflection.Typing.var_as_namedv",
"FStar.Reflection.Types.term"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
} | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val var_as_term : v: FStar.Reflection.V2.Data.var -> FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.var_as_term | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | v: FStar.Reflection.V2.Data.var -> FStar.Reflection.Types.term | {
"end_col": 60,
"end_line": 291,
"start_col": 26,
"start_line": 291
} |
|
Prims.Tot | val open_with_var_elt (x: var) (i: nat) : subst_elt | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x))) | val open_with_var_elt (x: var) (i: nat) : subst_elt
let open_with_var_elt (x: var) (i: nat) : subst_elt = | false | null | false | DT i (pack_ln (Tv_Var (var_as_namedv x))) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Data.var",
"Prims.nat",
"FStar.Reflection.Typing.DT",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Var",
"FStar.Reflection.Typing.var_as_namedv",
"FStar.Reflection.Typing.subst_elt"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_with_var_elt (x: var) (i: nat) : subst_elt | [] | FStar.Reflection.Typing.open_with_var_elt | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.Reflection.V2.Data.var -> i: Prims.nat -> FStar.Reflection.Typing.subst_elt | {
"end_col": 43,
"end_line": 306,
"start_col": 2,
"start_line": 306
} |
Prims.Tot | val mk_simple_binder (pp_name: pp_name_t) (ty: term) : simple_binder | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty} | val mk_simple_binder (pp_name: pp_name_t) (ty: term) : simple_binder
let mk_simple_binder (pp_name: pp_name_t) (ty: term) : simple_binder = | false | null | false | pack_binder ({ ppname = pp_name; qual = Q_Explicit; attrs = []; sort = ty }) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.pp_name_t",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.pack_binder",
"FStar.Reflection.V2.Data.Mkbinder_view",
"FStar.Reflection.V2.Data.Q_Explicit",
"Prims.Nil",
"FStar.Reflection.V2.Data.simple_binder"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty} | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_simple_binder (pp_name: pp_name_t) (ty: term) : simple_binder | [] | FStar.Reflection.Typing.mk_simple_binder | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | pp_name: FStar.Reflection.Typing.pp_name_t -> ty: FStar.Reflection.Types.term
-> FStar.Reflection.V2.Data.simple_binder | {
"end_col": 20,
"end_line": 150,
"start_col": 4,
"start_line": 146
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n) | let shift_subst_elt (n: nat) = | false | null | false | function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.nat",
"FStar.Reflection.Typing.subst_elt",
"FStar.Reflection.Types.term",
"FStar.Reflection.Typing.DT",
"Prims.op_Addition",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.Typing.NT",
"FStar.Reflection.Typing.ND"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val shift_subst_elt : n: Prims.nat -> _: FStar.Reflection.Typing.subst_elt -> FStar.Reflection.Typing.subst_elt | [] | FStar.Reflection.Typing.shift_subst_elt | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | n: Prims.nat -> _: FStar.Reflection.Typing.subst_elt -> FStar.Reflection.Typing.subst_elt | {
"end_col": 26,
"end_line": 195,
"start_col": 30,
"start_line": 192
} |
|
Prims.Tot | val make_namedv_with_name (s: pp_name_t) (n: nat) : namedv_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
} | val make_namedv_with_name (s: pp_name_t) (n: nat) : namedv_view
let make_namedv_with_name (s: pp_name_t) (n: nat) : namedv_view = | false | null | false | { ppname = s; uniq = n; sort = sort_default } | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.pp_name_t",
"Prims.nat",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Reflection.Typing.sort_default",
"FStar.Reflection.V2.Data.namedv_view"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
} | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_namedv_with_name (s: pp_name_t) (n: nat) : namedv_view | [] | FStar.Reflection.Typing.make_namedv_with_name | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Reflection.Typing.pp_name_t -> n: Prims.nat -> FStar.Reflection.V2.Data.namedv_view | {
"end_col": 24,
"end_line": 281,
"start_col": 2,
"start_line": 279
} |
Prims.Tot | val var_as_namedv (v: nat) : namedv | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
} | val var_as_namedv (v: nat) : namedv
let var_as_namedv (v: nat) : namedv = | false | null | false | pack_namedv ({ uniq = v; sort = sort_default; ppname = pp_name_default }) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.nat",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Reflection.Typing.sort_default",
"FStar.Reflection.Typing.pp_name_default",
"FStar.Reflection.Types.namedv"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
} | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val var_as_namedv (v: nat) : namedv | [] | FStar.Reflection.Typing.var_as_namedv | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | v: Prims.nat -> FStar.Reflection.Types.namedv | {
"end_col": 3,
"end_line": 289,
"start_col": 2,
"start_line": 285
} |
Prims.Tot | val zip2prop (#a #b: _) (f: (a -> b -> Type0)) (xs: list a) (ys: list b) : Type0 | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_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 zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False | val zip2prop (#a #b: _) (f: (a -> b -> Type0)) (xs: list a) (ys: list b) : Type0
let rec zip2prop #a #b (f: (a -> b -> Type0)) (xs: list a) (ys: list b) : Type0 = | false | null | false | match xs, ys with
| [], [] -> True
| x :: xx, y :: yy -> f x y /\ zip2prop f xx yy
| _ -> False | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.list",
"FStar.Pervasives.Native.Mktuple2",
"Prims.l_True",
"Prims.l_and",
"FStar.Reflection.Typing.zip2prop",
"FStar.Pervasives.Native.tuple2",
"Prims.l_False"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f | false | false | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val zip2prop (#a #b: _) (f: (a -> b -> Type0)) (xs: list a) (ys: list b) : Type0 | [
"recursion"
] | FStar.Reflection.Typing.zip2prop | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: b -> Type0) -> xs: Prims.list a -> ys: Prims.list b -> Type0 | {
"end_col": 14,
"end_line": 61,
"start_col": 2,
"start_line": 58
} |
Prims.Tot | val fold_left_dec (#a #b: _) (acc: a) (l: list b) (f: (a -> x: b{x << l} -> a))
: Tot a (decreases l) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_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 fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f | val fold_left_dec (#a #b: _) (acc: a) (l: list b) (f: (a -> x: b{x << l} -> a))
: Tot a (decreases l)
let rec fold_left_dec #a #b (acc: a) (l: list b) (f: (a -> x: b{x << l} -> a)) : Tot a (decreases l) = | false | null | false | match l with
| [] -> acc
| x :: xs -> fold_left_dec (f acc x) xs f | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total",
""
] | [
"Prims.list",
"Prims.precedes",
"FStar.Reflection.Typing.fold_left_dec"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l) | false | false | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fold_left_dec (#a #b: _) (acc: a) (l: list b) (f: (a -> x: b{x << l} -> a))
: Tot a (decreases l) | [
"recursion"
] | FStar.Reflection.Typing.fold_left_dec | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | acc: a -> l: Prims.list b -> f: (_: a -> x: b{x << l} -> a) -> Prims.Tot a | {
"end_col": 41,
"end_line": 46,
"start_col": 2,
"start_line": 44
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u_succ u = pack_universe (Uv_Succ u) | let u_succ u = | false | null | false | pack_universe (Uv_Succ u) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.universe",
"FStar.Reflection.V2.Builtins.pack_universe",
"FStar.Reflection.V2.Data.Uv_Succ"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u_succ : u117: FStar.Reflection.Types.universe -> FStar.Reflection.Types.universe | [] | FStar.Reflection.Typing.u_succ | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | u117: FStar.Reflection.Types.universe -> FStar.Reflection.Types.universe | {
"end_col": 40,
"end_line": 539,
"start_col": 15,
"start_line": 539
} |
|
Prims.Tot | val subst_var (v: namedv) (s: subst) : term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v) | val subst_var (v: namedv) (s: subst) : term
let subst_var (v: namedv) (s: subst) : term = | false | null | false | match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k -> pack_ln (Tv_Var (pack_namedv ({ inspect_namedv v with uniq = k }))))
| Some (ND _ i) ->
let bv =
pack_bv ({ sort = (inspect_namedv v).sort; ppname = (inspect_namedv v).ppname; index = i })
in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.namedv",
"FStar.Reflection.Typing.subst",
"FStar.Reflection.Typing.find_matching_subst_elt_var",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.Types.term",
"FStar.Reflection.Typing.maybe_uniq_of_term",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Var",
"FStar.Reflection.V2.Builtins.pack_namedv",
"FStar.Reflection.V2.Data.Mknamedv_view",
"FStar.Reflection.V2.Data.__proj__Mknamedv_view__item__sort",
"FStar.Reflection.V2.Data.__proj__Mknamedv_view__item__ppname",
"FStar.Reflection.V2.Data.namedv_view",
"Prims.precedes",
"FStar.Reflection.V2.Builtins.inspect_namedv",
"Prims.nat",
"FStar.Reflection.V2.Data.Tv_BVar",
"FStar.Reflection.Types.bv",
"FStar.Reflection.V2.Builtins.pack_bv",
"FStar.Reflection.V2.Data.Mkbv_view",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Typing.subst_elt"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val subst_var (v: namedv) (s: subst) : term | [] | FStar.Reflection.Typing.subst_var | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | v: FStar.Reflection.Types.namedv -> s: FStar.Reflection.Typing.subst -> FStar.Reflection.Types.term | {
"end_col": 27,
"end_line": 256,
"start_col": 2,
"start_line": 243
} |
Prims.Tot | val make_bv (n: nat) : bv_view | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
} | val make_bv (n: nat) : bv_view
let make_bv (n: nat) : bv_view = | false | null | false | { ppname = pp_name_default; index = n; sort = sort_default } | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.nat",
"FStar.Reflection.V2.Data.Mkbv_view",
"FStar.Reflection.Typing.sort_default",
"FStar.Reflection.Typing.pp_name_default",
"FStar.Reflection.V2.Data.bv_view"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_bv (n: nat) : bv_view | [] | FStar.Reflection.Typing.make_bv | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | n: Prims.nat -> FStar.Reflection.V2.Data.bv_view | {
"end_col": 22,
"end_line": 261,
"start_col": 2,
"start_line": 259
} |
Prims.Tot | val __close_term_vs (i: nat) (vs: list var) (t: term) : Tot term (decreases vs) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i] | val __close_term_vs (i: nat) (vs: list var) (t: term) : Tot term (decreases vs)
let rec __close_term_vs (i: nat) (vs: list var) (t: term) : Tot term (decreases vs) = | false | null | false | match vs with
| [] -> t
| v :: vs -> subst_term (__close_term_vs (i + 1) vs t) [ND v i] | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total",
""
] | [
"Prims.nat",
"Prims.list",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.Types.term",
"FStar.Reflection.Typing.subst_term",
"FStar.Reflection.Typing.__close_term_vs",
"Prims.op_Addition",
"Prims.Cons",
"FStar.Reflection.Typing.subst_elt",
"FStar.Reflection.Typing.ND",
"Prims.Nil"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val __close_term_vs (i: nat) (vs: list var) (t: term) : Tot term (decreases vs) | [
"recursion"
] | FStar.Reflection.Typing.__close_term_vs | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | i: Prims.nat -> vs: Prims.list FStar.Reflection.V2.Data.var -> t: FStar.Reflection.Types.term
-> Prims.Tot FStar.Reflection.Types.term | {
"end_col": 52,
"end_line": 1042,
"start_col": 2,
"start_line": 1039
} |
Prims.Tot | val extend_env_l (g: env) (bs: bindings) : env | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_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 extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t | val extend_env_l (g: env) (bs: bindings) : env
let rec extend_env_l (g: env) (bs: bindings) : env = | false | null | false | match bs with
| [] -> g
| (x, t) :: bs -> extend_env (extend_env_l g bs) x t | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.env",
"FStar.Reflection.Typing.bindings",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Reflection.Typing.binding",
"FStar.Reflection.Typing.extend_env",
"FStar.Reflection.Typing.extend_env_l"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val extend_env_l (g: env) (bs: bindings) : env | [
"recursion"
] | FStar.Reflection.Typing.extend_env_l | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | g: FStar.Reflection.Types.env -> bs: FStar.Reflection.Typing.bindings -> FStar.Reflection.Types.env | {
"end_col": 53,
"end_line": 1025,
"start_col": 4,
"start_line": 1023
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let true_bool = pack_ln (Tv_Const C_True) | let true_bool = | false | null | false | pack_ln (Tv_Const C_True) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Const",
"FStar.Reflection.V2.Data.C_True"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"] | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val true_bool : FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.true_bool | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.term | {
"end_col": 41,
"end_line": 546,
"start_col": 16,
"start_line": 546
} |
|
Prims.Tot | val eq2 (u: universe) (t v0 v1: term) : term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2 | val eq2 (u: universe) (t v0 v1: term) : term
let eq2 (u: universe) (t v0 v1: term) : term = | false | null | false | let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2 | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.universe",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_App",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V2.Data.aqualv",
"FStar.Reflection.V2.Data.Q_Explicit",
"FStar.Reflection.V2.Data.Q_Implicit",
"FStar.Reflection.V2.Data.Tv_UInst",
"Prims.Cons",
"Prims.Nil",
"FStar.Reflection.Types.fv",
"FStar.Reflection.V2.Builtins.pack_fv",
"FStar.Reflection.Const.eq2_qn"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val eq2 (u: universe) (t v0 v1: term) : term | [] | FStar.Reflection.Typing.eq2 | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
u122: FStar.Reflection.Types.universe ->
t: FStar.Reflection.Types.term ->
v0: FStar.Reflection.Types.term ->
v1: FStar.Reflection.Types.term
-> FStar.Reflection.Types.term | {
"end_col": 6,
"end_line": 555,
"start_col": 3,
"start_line": 550
} |
Prims.Tot | val eqtype_lid:R.name | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let eqtype_lid : R.name = ["Prims"; "eqtype"] | val eqtype_lid:R.name
let eqtype_lid:R.name = | false | null | false | ["Prims"; "eqtype"] | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.Cons",
"Prims.string",
"Prims.Nil"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val eqtype_lid:R.name | [] | FStar.Reflection.Typing.eqtype_lid | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.name | {
"end_col": 45,
"end_line": 544,
"start_col": 26,
"start_line": 544
} |
Prims.Tot | val b2t_lid:R.name | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let b2t_lid : R.name = ["Prims"; "b2t"] | val b2t_lid:R.name
let b2t_lid:R.name = | false | null | false | ["Prims"; "b2t"] | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.Cons",
"Prims.string",
"Prims.Nil"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2 | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val b2t_lid:R.name | [] | FStar.Reflection.Typing.b2t_lid | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.name | {
"end_col": 39,
"end_line": 557,
"start_col": 23,
"start_line": 557
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let false_bool = pack_ln (Tv_Const C_False) | let false_bool = | false | null | false | pack_ln (Tv_Const C_False) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Const",
"FStar.Reflection.V2.Data.C_False"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"] | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val false_bool : FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.false_bool | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | FStar.Reflection.Types.term | {
"end_col": 43,
"end_line": 547,
"start_col": 17,
"start_line": 547
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ln (t:term) = ln' t (-1) | let ln (t: term) = | false | null | false | ln' t (- 1) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.Typing.ln'",
"Prims.op_Minus",
"Prims.bool"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_ | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ln : t: FStar.Reflection.Types.term -> Prims.bool | [] | FStar.Reflection.Typing.ln | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.Reflection.Types.term -> Prims.bool | {
"end_col": 28,
"end_line": 857,
"start_col": 18,
"start_line": 857
} |
|
Prims.Tot | val elaborate_pat (p: pattern) (bs: list R.binding)
: Tot (option (term & list R.binding)) (decreases p) | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_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 elaborate_pat (p : pattern) (bs : list R.binding) : Tot (option (term & list R.binding)) (decreases p) =
match p, bs with
| Pat_Constant c, _ -> Some (pack_ln (Tv_Const c), bs)
| Pat_Cons fv univs subpats, bs ->
let head = pack_ln (Tv_FVar fv) in
fold_left_dec
(Some (head, bs))
subpats
(fun st pi ->
let (p,i) = pi in
match st with | None -> None | Some (head, bs) ->
match elaborate_pat p bs with | None -> None | Some (t, bs') -> Some (pack_ln (Tv_App head (t, (if i then Q_Implicit else Q_Explicit))), bs'))
| Pat_Var _ _, b::bs ->
Some (pack_ln (Tv_Var (binding_to_namedv b)), bs)
| Pat_Dot_Term (Some t), _ -> Some (t, bs)
| Pat_Dot_Term None, _ -> None
| _ -> None | val elaborate_pat (p: pattern) (bs: list R.binding)
: Tot (option (term & list R.binding)) (decreases p)
let rec elaborate_pat (p: pattern) (bs: list R.binding)
: Tot (option (term & list R.binding)) (decreases p) = | false | null | false | match p, bs with
| Pat_Constant c, _ -> Some (pack_ln (Tv_Const c), bs)
| Pat_Cons fv univs subpats, bs ->
let head = pack_ln (Tv_FVar fv) in
fold_left_dec (Some (head, bs))
subpats
(fun st pi ->
let p, i = pi in
match st with
| None -> None
| Some (head, bs) ->
match elaborate_pat p bs with
| None -> None
| Some (t, bs') ->
Some (pack_ln (Tv_App head (t, (if i then Q_Implicit else Q_Explicit))), bs'))
| Pat_Var _ _, b :: bs -> Some (pack_ln (Tv_Var (binding_to_namedv b)), bs)
| Pat_Dot_Term (Some t), _ -> Some (t, bs)
| Pat_Dot_Term None, _ -> None
| _ -> None | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total",
""
] | [
"FStar.Reflection.V2.Data.pattern",
"Prims.list",
"FStar.Reflection.V2.Data.binding",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V2.Data.vconst",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Const",
"FStar.Reflection.Types.fv",
"FStar.Pervasives.Native.option",
"FStar.Reflection.V2.Data.universes",
"Prims.bool",
"FStar.Reflection.Typing.fold_left_dec",
"Prims.precedes",
"FStar.Pervasives.Native.None",
"FStar.Reflection.Typing.elaborate_pat",
"FStar.Reflection.V2.Data.Tv_App",
"FStar.Reflection.V2.Data.aqualv",
"FStar.Reflection.V2.Data.Q_Implicit",
"FStar.Reflection.V2.Data.Q_Explicit",
"FStar.Reflection.V2.Data.Tv_FVar",
"FStar.Sealed.sealed",
"FStar.Reflection.V2.Data.ppname_t",
"FStar.Reflection.V2.Data.Tv_Var",
"FStar.Reflection.Typing.binding_to_namedv"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs
let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs
[@@ no_auto_projectors]
noeq
type non_informative : env -> term -> Type0 =
| Non_informative_type:
g:env ->
u:universe ->
non_informative g (pack_ln (Tv_Type u))
| Non_informative_fv:
g:env ->
x:fv{is_non_informative_fv x} ->
non_informative g (pack_ln (Tv_FVar x))
| Non_informative_uinst:
g:env ->
x:fv{is_non_informative_fv x} ->
us:list universe ->
non_informative g (pack_ln (Tv_UInst x us))
| Non_informative_app:
g:env ->
t:term ->
arg:argv ->
non_informative g t ->
non_informative g (pack_ln (Tv_App t arg))
| Non_informative_total_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g t1 ->
non_informative g (mk_arrow_ct t0 q (T.E_Total, t1))
| Non_informative_ghost_arrow:
g:env ->
t0:term ->
q:aqualv ->
t1:term ->
non_informative g (mk_arrow_ct t0 q (T.E_Ghost, t1))
| Non_informative_token:
g:env ->
t:typ ->
squash (T.non_informative_token g t) ->
non_informative g t
val bindings_ok_for_pat : env -> list R.binding -> pattern -> Type0
val bindings_ok_pat_constant :
g:env -> c:R.vconst -> Lemma (bindings_ok_for_pat g [] (Pat_Constant c))
let bindings_ok_for_branch (g:env) (bs : list R.binding) (br : branch) : Type0 =
bindings_ok_for_pat g bs (fst br)
let bindings_ok_for_branch_N (g:env) (bss : list (list R.binding)) (brs : list branch) =
zip2prop (bindings_ok_for_branch g) bss brs
let binding_to_namedv (b:R.binding) : Tot namedv =
pack_namedv {
RD.uniq = b.uniq;
RD.sort = seal b.sort;
RD.ppname = b.ppname;
}
(* Elaborates the p pattern into a term, using the bs bindings for the
pattern variables. The resulting term is properly scoped only on an
environment which contains all of bs. See for instance the branch_typing
judg. Returns an option, since this can fail if e.g. there are not
enough bindings, and returns the list of unused binders as well, which
should be empty if the list of binding was indeed ok. *) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val elaborate_pat (p: pattern) (bs: list R.binding)
: Tot (option (term & list R.binding)) (decreases p) | [
"recursion"
] | FStar.Reflection.Typing.elaborate_pat | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: FStar.Reflection.V2.Data.pattern -> bs: Prims.list FStar.Reflection.V2.Data.binding
-> Prims.Tot
(FStar.Pervasives.Native.option (FStar.Reflection.Types.term *
Prims.list FStar.Reflection.V2.Data.binding)) | {
"end_col": 13,
"end_line": 1144,
"start_col": 2,
"start_line": 1128
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i) | let open_comp_typ' (c: comp_typ) (x: var) (i: nat) = | false | null | false | fst c, subst_term (snd c) (open_with_var x i) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.comp_typ",
"FStar.Reflection.V2.Data.var",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"FStar.Reflection.Types.term",
"FStar.Pervasives.Native.fst",
"FStar.Reflection.Types.typ",
"FStar.Reflection.Typing.subst_term",
"FStar.Pervasives.Native.snd",
"FStar.Reflection.Typing.open_with_var",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0 | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_comp_typ' : c: FStar.Reflection.Typing.comp_typ -> x: FStar.Reflection.V2.Data.var -> i: Prims.nat
-> FStar.Stubs.TypeChecker.Core.tot_or_ghost * FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.open_comp_typ' | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | c: FStar.Reflection.Typing.comp_typ -> x: FStar.Reflection.V2.Data.var -> i: Prims.nat
-> FStar.Stubs.TypeChecker.Core.tot_or_ghost * FStar.Reflection.Types.term | {
"end_col": 47,
"end_line": 998,
"start_col": 2,
"start_line": 998
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0 | let close_comp_typ (c: comp_typ) (x: var) = | false | null | false | close_comp_typ' c x 0 | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.comp_typ",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.Typing.close_comp_typ'",
"FStar.Pervasives.Native.tuple2",
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"FStar.Reflection.Types.term"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ] | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_comp_typ : c: FStar.Reflection.Typing.comp_typ -> x: FStar.Reflection.V2.Data.var
-> FStar.Stubs.TypeChecker.Core.tot_or_ghost * FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.close_comp_typ | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | c: FStar.Reflection.Typing.comp_typ -> x: FStar.Reflection.V2.Data.var
-> FStar.Stubs.TypeChecker.Core.tot_or_ghost * FStar.Reflection.Types.term | {
"end_col": 23,
"end_line": 995,
"start_col": 2,
"start_line": 995
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0 | let open_comp_typ (c: comp_typ) (x: var) = | false | null | false | open_comp_typ' c x 0 | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Typing.comp_typ",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.Typing.open_comp_typ'",
"FStar.Pervasives.Native.tuple2",
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"FStar.Reflection.Types.term"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val open_comp_typ : c: FStar.Reflection.Typing.comp_typ -> x: FStar.Reflection.V2.Data.var
-> FStar.Stubs.TypeChecker.Core.tot_or_ghost * FStar.Reflection.Types.term | [] | FStar.Reflection.Typing.open_comp_typ | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | c: FStar.Reflection.Typing.comp_typ -> x: FStar.Reflection.V2.Data.var
-> FStar.Stubs.TypeChecker.Core.tot_or_ghost * FStar.Reflection.Types.term | {
"end_col": 22,
"end_line": 1001,
"start_col": 2,
"start_line": 1001
} |
|
Prims.Tot | val mk_if (scrutinee then_ else_: R.term) : R.term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)]) | val mk_if (scrutinee then_ else_: R.term) : R.term
let mk_if (scrutinee then_ else_: R.term) : R.term = | false | null | false | pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_); (Pat_Constant C_False, else_)]) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Builtins.pack_ln",
"FStar.Reflection.V2.Data.Tv_Match",
"FStar.Pervasives.Native.None",
"FStar.Reflection.Types.match_returns_ascription",
"Prims.Cons",
"FStar.Reflection.V2.Data.branch",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V2.Data.pattern",
"FStar.Reflection.V2.Data.Pat_Constant",
"FStar.Reflection.V2.Data.C_True",
"FStar.Reflection.V2.Data.C_False",
"Prims.Nil"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v) | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mk_if (scrutinee then_ else_: R.term) : R.term | [] | FStar.Reflection.Typing.mk_if | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
scrutinee: FStar.Reflection.Types.term ->
then_: FStar.Reflection.Types.term ->
else_: FStar.Reflection.Types.term
-> FStar.Reflection.Types.term | {
"end_col": 67,
"end_line": 985,
"start_col": 2,
"start_line": 984
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs | let rename_bindings bs x y = | false | null | false | FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.Types.term",
"FStar.Reflection.V2.Data.var",
"FStar.List.Tot.Base.map",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.Typing.rename"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term | false | false | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val rename_bindings : bs: Prims.list (_ * FStar.Reflection.Types.term) ->
x: FStar.Reflection.V2.Data.var ->
y: FStar.Reflection.V2.Data.var
-> Prims.list (_ * FStar.Reflection.Types.term) | [] | FStar.Reflection.Typing.rename_bindings | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
bs: Prims.list (_ * FStar.Reflection.Types.term) ->
x: FStar.Reflection.V2.Data.var ->
y: FStar.Reflection.V2.Data.var
-> Prims.list (_ * FStar.Reflection.Types.term) | {
"end_col": 84,
"end_line": 1019,
"start_col": 29,
"start_line": 1019
} |
|
Prims.Tot | val close_term_bs (bs: list binding) (t: term) : term | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t | val close_term_bs (bs: list binding) (t: term) : term
let close_term_bs (bs: list binding) (t: term) : term = | false | null | false | close_term_vs (List.Tot.map fst bs) t | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.list",
"FStar.Reflection.Typing.binding",
"FStar.Reflection.Types.term",
"FStar.Reflection.Typing.close_term_vs",
"FStar.List.Tot.Base.map",
"FStar.Reflection.V2.Data.var",
"FStar.Pervasives.Native.fst"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val close_term_bs (bs: list binding) (t: term) : term | [] | FStar.Reflection.Typing.close_term_bs | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Reflection.Typing.binding -> t: FStar.Reflection.Types.term
-> FStar.Reflection.Types.term | {
"end_col": 39,
"end_line": 1048,
"start_col": 2,
"start_line": 1048
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bindings = list binding | let bindings = | false | null | false | list binding | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.list",
"FStar.Reflection.Typing.binding"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bindings : Type0 | [] | FStar.Reflection.Typing.bindings | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 27,
"end_line": 1018,
"start_col": 15,
"start_line": 1018
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let binding = var & term | let binding = | false | null | false | var & term | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.V2.Data.var",
"FStar.Reflection.Types.term"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val binding : Type0 | [] | FStar.Reflection.Typing.binding | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 24,
"end_line": 1017,
"start_col": 14,
"start_line": 1017
} |
|
Prims.Tot | val is_non_informative_fv (f: fv) : bool | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f) | val is_non_informative_fv (f: fv) : bool
let is_non_informative_fv (f: fv) : bool = | false | null | false | is_non_informative_name (inspect_fv f) | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"FStar.Reflection.Types.fv",
"FStar.Reflection.Typing.is_non_informative_name",
"FStar.Reflection.V2.Builtins.inspect_fv",
"Prims.bool"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"] | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_non_informative_fv (f: fv) : bool | [] | FStar.Reflection.Typing.is_non_informative_fv | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: FStar.Reflection.Types.fv -> Prims.bool | {
"end_col": 40,
"end_line": 1036,
"start_col": 2,
"start_line": 1036
} |
Prims.Tot | val refl_bindings_to_bindings (bs: list R.binding) : list binding | [
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let refl_bindings_to_bindings (bs : list R.binding) : list binding =
L.map (fun b -> b.uniq, b.sort) bs | val refl_bindings_to_bindings (bs: list R.binding) : list binding
let refl_bindings_to_bindings (bs: list R.binding) : list binding = | false | null | false | L.map (fun b -> b.uniq, b.sort) bs | {
"checked_file": "FStar.Reflection.Typing.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.Inhabited.fst.checked",
"FStar.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Reflection.Typing.fsti"
} | [
"total"
] | [
"Prims.list",
"FStar.Reflection.V2.Data.binding",
"FStar.List.Tot.Base.map",
"FStar.Pervasives.Native.tuple2",
"Prims.nat",
"FStar.Reflection.Types.typ",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V2.Data.__proj__Mkbinding__item__uniq",
"FStar.Reflection.V2.Data.__proj__Mkbinding__item__sort",
"FStar.Reflection.Typing.binding"
] | [] | (*
Copyright 2008-2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Reflection.Typing
(** This module defines a typing judgment for (parts of) the total
and ghost fragment of F*.
We are using it in the meta DSL framework as an
official specification for the F* type system.
We expect it to grow to cover more of the F* language.
IT IS HIGHLY EXPERIMENTAL AND NOT YET READY TO USE.
*)
open FStar.List.Tot
open FStar.Reflection.V2
module L = FStar.List.Tot
module R = FStar.Reflection.V2
module T = FStar.Tactics.V2
module RD = FStar.Reflection.V2.Data
(* MOVE to some helper module *)
let rec fold_left_dec #a #b
(acc : a)
(l : list b)
(f : a -> (x:b{x << l}) -> a)
: Tot a (decreases l)
=
match l with
| [] -> acc
| x::xs -> fold_left_dec (f acc x) xs f
let rec map_dec #a #b
(l : list a)
(f : (x:a{x << l}) -> b)
: Tot (list b) (decreases l)
=
match l with
| [] -> []
| x::xs -> f x :: map_dec xs f
let rec zip2prop #a #b (f : a -> b -> Type0) (xs : list a) (ys : list b) : Type0 =
match xs, ys with
| [], [] -> True
| x::xx, y::yy -> f x y /\ zip2prop f xx yy
| _ -> False
(* / MOVE *)
val inspect_pack (t:R.term_view)
: Lemma (ensures R.(inspect_ln (pack_ln t) == t))
[SMTPat R.(inspect_ln (pack_ln t))]
val pack_inspect (t:R.term)
: Lemma (requires ~(Tv_Unsupp? (inspect_ln t)))
(ensures R.(pack_ln (inspect_ln t) == t))
[SMTPat R.(pack_ln (inspect_ln t))]
val inspect_pack_namedv (t:R.namedv_view)
: Lemma (ensures R.(inspect_namedv (pack_namedv t) == t))
[SMTPat R.(inspect_namedv (pack_namedv t))]
val pack_inspect_namedv (t:R.namedv)
: Lemma (ensures R.(pack_namedv (inspect_namedv t) == t))
[SMTPat R.(pack_namedv (inspect_namedv t))]
val inspect_pack_bv (t:R.bv_view)
: Lemma (ensures R.(inspect_bv (pack_bv t) == t))
[SMTPat R.(inspect_bv (pack_bv t))]
val pack_inspect_bv (t:R.bv)
: Lemma (ensures R.(pack_bv (inspect_bv t) == t))
[SMTPat R.(pack_bv (inspect_bv t))]
val inspect_pack_binder (bview:R.binder_view)
: Lemma (ensures R.(R.inspect_binder (R.pack_binder bview) == bview))
[SMTPat R.(inspect_binder (pack_binder bview))]
val pack_inspect_binder (t:R.binder)
: Lemma (ensures (R.pack_binder (R.inspect_binder t) == t))
[SMTPat (R.pack_binder (R.inspect_binder t))]
val inspect_pack_comp (t:R.comp_view)
: Lemma (ensures (R.inspect_comp (R.pack_comp t) == t))
[SMTPat (R.inspect_comp (R.pack_comp t))]
val pack_inspect_comp (t:R.comp)
: Lemma (ensures (R.pack_comp (R.inspect_comp t) == t))
[SMTPat (R.pack_comp (R.inspect_comp t))]
val inspect_pack_fv (nm:R.name)
: Lemma (ensures R.inspect_fv (R.pack_fv nm) == nm)
[SMTPat (R.inspect_fv (R.pack_fv nm))]
val pack_inspect_fv (fv:R.fv)
: Lemma (ensures R.pack_fv (R.inspect_fv fv) == fv)
[SMTPat (R.pack_fv (R.inspect_fv fv))]
val inspect_pack_universe (u:R.universe_view)
: Lemma (ensures R.inspect_universe (R.pack_universe u) == u)
[SMTPat (R.inspect_universe (R.pack_universe u))]
val pack_inspect_universe (u:R.universe)
: Lemma (requires ~(Uv_Unk? (inspect_universe u)))
(ensures R.pack_universe (R.inspect_universe u) == u)
[SMTPat (R.pack_universe (R.inspect_universe u))]
val lookup_bvar (e:env) (x:int) : option term
val lookup_fvar_uinst (e:R.env) (x:R.fv) (us:list R.universe) : option R.term
let lookup_fvar (e:env) (x:fv) : option term = lookup_fvar_uinst e x []
let pp_name_t = FStar.Sealed.Inhabited.sealed "x"
let pp_name_default : pp_name_t = FStar.Sealed.Inhabited.seal "x"
let seal_pp_name x : pp_name_t = FStar.Sealed.Inhabited.seal x
let tun = pack_ln Tv_Unknown
let sort_t = FStar.Sealed.Inhabited.sealed tun
let sort_default : sort_t = FStar.Sealed.Inhabited.seal tun
let seal_sort x : sort_t = FStar.Sealed.Inhabited.seal x
let mk_binder (pp_name:pp_name_t) (ty:term) (q:aqualv) : binder
= pack_binder
{ ppname = pp_name;
qual = q;
attrs = [];
sort = ty}
let mk_simple_binder (pp_name:pp_name_t) (ty:term) : simple_binder
= pack_binder
{ ppname = pp_name;
qual = Q_Explicit;
attrs = [];
sort = ty}
let extend_env (e:env) (x:var) (ty:term) : env =
R.push_binding e ({
ppname = seal_pp_name "x";
uniq = x;
sort = ty;
})
val lookup_bvar_extend_env (g:env) (x y:var) (ty:term)
: Lemma
(ensures (
if x = y
then lookup_bvar (extend_env g x ty) y == Some ty
else lookup_bvar (extend_env g x ty) y == lookup_bvar g y))
[SMTPat (lookup_bvar (extend_env g x ty) y)]
val lookup_fvar_extend_env (g:env) (x:fv) (us:universes) (y:var) (ty:term)
: Lemma
(ensures lookup_fvar_uinst (extend_env g y ty) x us == lookup_fvar_uinst g x us)
[SMTPat (lookup_fvar_uinst (extend_env g y ty) x us)]
let bv_index (x:bv)
: var
= (inspect_bv x).index
let namedv_uniq (x:namedv)
: var
= (inspect_namedv x).uniq
let binder_sort (b:binder) =
(inspect_binder b).sort
let binder_qual (b:binder) =
let { qual = q } = inspect_binder b in q
noeq
type subst_elt =
| DT : nat -> term -> subst_elt
| NT : var -> term -> subst_elt
| ND : var -> nat -> subst_elt
let shift_subst_elt (n:nat) = function
| DT i t -> DT (i + n) t
| NT x t -> NT x t
| ND x i -> ND x (i + n)
let subst = list subst_elt
let shift_subst_n (n:nat) = L.map (shift_subst_elt n)
let shift_subst = shift_subst_n 1
let maybe_uniq_of_term (x:term) =
match inspect_ln x with
| Tv_Var namedv -> Some (namedv_uniq namedv)
| _ -> None
let rec find_matching_subst_elt_bv (s:subst) (bv:bv) : option subst_elt =
match s with
| [] -> None
| (DT j t)::ss ->
if j = bv_index bv
then Some (DT j t)
else find_matching_subst_elt_bv ss bv
| _::ss -> find_matching_subst_elt_bv ss bv
let subst_db (bv:bv) (s:subst) : term =
match find_matching_subst_elt_bv s bv with
| Some (DT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
//if we're substituting a name j for a name k, retain the pp_name of j
let v : namedv = pack_namedv {
sort = (inspect_bv bv).sort;
ppname = (inspect_bv bv).ppname;
uniq = k;
} in
pack_ln (Tv_Var v))
| _ -> pack_ln (Tv_BVar bv)
let rec find_matching_subst_elt_var (s:subst) (v:namedv) : option subst_elt =
match s with
| [] -> None
| (NT y _)::rest
| (ND y _)::rest ->
if y = namedv_uniq v
then Some (L.hd s)
else find_matching_subst_elt_var rest v
| _::rest -> find_matching_subst_elt_var rest v
let subst_var (v:namedv) (s:subst) : term =
match find_matching_subst_elt_var s v with
| Some (NT _ t) ->
(match maybe_uniq_of_term t with
| None -> t
| Some k ->
pack_ln (Tv_Var (pack_namedv { inspect_namedv v with uniq = k })))
| Some (ND _ i) ->
let bv = pack_bv {
sort = (inspect_namedv v).sort;
ppname = (inspect_namedv v).ppname;
index = i;
} in
pack_ln (Tv_BVar bv)
| _ -> pack_ln (Tv_Var v)
let make_bv (n:nat) : bv_view = {
ppname = pp_name_default;
index = n;
sort = sort_default;
}
let make_bv_with_name (s:pp_name_t) (n:nat) : bv_view = {
ppname = s;
index = n;
sort = sort_default;
}
let var_as_bv (v:nat) = pack_bv (make_bv v)
let make_namedv (n:nat) : namedv_view = {
ppname = pp_name_default;
uniq = n;
sort = sort_default;
}
let make_namedv_with_name (s:pp_name_t) (n:nat) : namedv_view = {
ppname = s;
uniq = n;
sort = sort_default;
}
let var_as_namedv (v:nat) : namedv =
pack_namedv {
uniq = v;
sort = sort_default;
ppname = pp_name_default;
}
let var_as_term (v:var) = pack_ln (Tv_Var (var_as_namedv v))
let binder_of_t_q t q = mk_binder pp_name_default t q
let mk_abs ty qual t : R.term = R.pack_ln (R.Tv_Abs (binder_of_t_q ty qual) t)
let mk_total t = pack_comp (C_Total t)
let mk_ghost t = pack_comp (C_GTotal t)
let mk_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_total t))
let mk_ghost_arrow ty qual t : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_ghost t))
let bound_var i : R.term = R.pack_ln (R.Tv_BVar (R.pack_bv (make_bv i)))
let mk_let ppname (e1 t1 e2:R.term) =
R.pack_ln (R.Tv_Let false [] (mk_simple_binder ppname t1) e1 e2)
let open_with_var_elt (x:var) (i:nat) : subst_elt =
DT i (pack_ln (Tv_Var (var_as_namedv x)))
let open_with_var (x:var) (i:nat) : subst = [open_with_var_elt x i]
val subst_ctx_uvar_and_subst (c:ctx_uvar_and_subst) (ss:subst)
: ctx_uvar_and_subst
let rec binder_offset_patterns (ps:list (pattern & bool))
: nat
= match ps with
| [] -> 0
| (p, b)::ps ->
let n = binder_offset_pattern p in
let m = binder_offset_patterns ps in
n + m
and binder_offset_pattern (p:pattern)
: nat
= match p with
| Pat_Constant _
| Pat_Dot_Term _ -> 0
| Pat_Var _ _ -> 1
| Pat_Cons head univs subpats ->
binder_offset_patterns subpats
let rec subst_term (t:term) (ss:subst)
: Tot term (decreases t)
= match inspect_ln t with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unsupp
| Tv_Unknown -> t
| Tv_Var x -> subst_var x ss
| Tv_BVar j -> subst_db j ss
| Tv_App hd argv ->
pack_ln (Tv_App (subst_term hd ss)
(subst_term (fst argv) ss, snd argv))
| Tv_Abs b body ->
let b' = subst_binder b ss in
pack_ln (Tv_Abs b' (subst_term body (shift_subst ss)))
| Tv_Arrow b c ->
let b' = subst_binder b ss in
pack_ln (Tv_Arrow b' (subst_comp c (shift_subst ss)))
| Tv_Refine b f ->
let b = subst_binder b ss in
pack_ln (Tv_Refine b (subst_term f (shift_subst ss)))
| Tv_Uvar j c ->
pack_ln (Tv_Uvar j (subst_ctx_uvar_and_subst c ss))
| Tv_Let recf attrs b def body ->
let b = subst_binder b ss in
pack_ln (Tv_Let recf
(subst_terms attrs ss)
b
(if recf
then subst_term def (shift_subst ss)
else subst_term def ss)
(subst_term body (shift_subst ss)))
| Tv_Match scr ret brs ->
pack_ln (Tv_Match (subst_term scr ss)
(match ret with
| None -> None
| Some m -> Some (subst_match_returns m ss))
(subst_branches brs ss))
| Tv_AscribedT e t tac b ->
pack_ln (Tv_AscribedT (subst_term e ss)
(subst_term t ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
| Tv_AscribedC e c tac b ->
pack_ln (Tv_AscribedC (subst_term e ss)
(subst_comp c ss)
(match tac with
| None -> None
| Some tac -> Some (subst_term tac ss))
b)
and subst_binder (b:binder) (ss:subst)
: Tot (b':binder{binder_is_simple b ==> binder_is_simple b'}) (decreases b)
= let bndr = inspect_binder b in
pack_binder {
ppname = bndr.ppname;
qual = bndr.qual;
attrs = subst_terms bndr.attrs ss;
sort = subst_term bndr.sort ss
}
and subst_comp (c:comp) (ss:subst)
: Tot comp (decreases c)
= match inspect_comp c with
| C_Total t ->
pack_comp (C_Total (subst_term t ss))
| C_GTotal t ->
pack_comp (C_GTotal (subst_term t ss))
| C_Lemma pre post pats ->
pack_comp (C_Lemma (subst_term pre ss)
(subst_term post ss)
(subst_term pats ss))
| C_Eff us eff_name res args decrs ->
pack_comp (C_Eff us eff_name
(subst_term res ss)
(subst_args args ss)
(subst_terms decrs ss))
and subst_terms (ts:list term) (ss:subst)
: Tot (ts':list term{Nil? ts ==> Nil? ts'}) // property useful for subst_binder
(decreases ts)
= match ts with
| [] -> []
| t::ts -> subst_term t ss :: subst_terms ts ss
and subst_args (ts:list argv) (ss:subst)
: Tot (list argv) (decreases ts)
= match ts with
| [] -> []
| (t,q)::ts -> (subst_term t ss,q) :: subst_args ts ss
and subst_patterns (ps:list (pattern & bool)) (ss:subst)
: Tot (list (pattern & bool))
(decreases ps)
= match ps with
| [] -> ps
| (p, b)::ps ->
let n = binder_offset_pattern p in
let p = subst_pattern p ss in
let ps = subst_patterns ps (shift_subst_n n ss) in
(p,b)::ps
and subst_pattern (p:pattern) (ss:subst)
: Tot pattern
(decreases p)
= match p with
| Pat_Constant _ -> p
| Pat_Cons fv us pats ->
let pats = subst_patterns pats ss in
Pat_Cons fv us pats
| Pat_Var bv s ->
Pat_Var bv s
| Pat_Dot_Term topt ->
Pat_Dot_Term (match topt with
| None -> None
| Some t -> Some (subst_term t ss))
and subst_branch (br:branch) (ss:subst)
: Tot branch (decreases br)
= let p, t = br in
let p = subst_pattern p ss in
let j = binder_offset_pattern p in
let t = subst_term t (shift_subst_n j ss) in
p, t
and subst_branches (brs:list branch) (ss:subst)
: Tot (list branch) (decreases brs)
= match brs with
| [] -> []
| br::brs -> subst_branch br ss :: subst_branches brs ss
and subst_match_returns (m:match_returns_ascription) (ss:subst)
: Tot match_returns_ascription (decreases m)
= let b, (ret, as_, eq) = m in
let b = subst_binder b ss in
let ret =
match ret with
| Inl t -> Inl (subst_term t (shift_subst ss))
| Inr c -> Inr (subst_comp c (shift_subst ss))
in
let as_ =
match as_ with
| None -> None
| Some t -> Some (subst_term t (shift_subst ss))
in
b, (ret, as_, eq)
val open_with (t:term) (v:term) : term
val open_with_spec (t v:term)
: Lemma (open_with t v ==
subst_term t [ DT 0 v ])
val open_term (t:term) (v:var) : term
val open_term_spec (t:term) (v:var)
: Lemma (open_term t v ==
subst_term t (open_with_var v 0))
val close_term (t:term) (v:var) : term
val close_term_spec (t:term) (v:var)
: Lemma (close_term t v ==
subst_term t [ ND v 0 ])
val rename (t:term) (x y:var) : term
val rename_spec (t:term) (x y:var)
: Lemma (rename t x y ==
subst_term t [ NT x (var_as_term y)])
val bv_index_of_make_bv (n:nat)
: Lemma (ensures bv_index (pack_bv (make_bv n)) == n)
[SMTPat (bv_index (pack_bv (make_bv n)))]
val namedv_uniq_of_make_namedv (n:nat)
: Lemma (ensures namedv_uniq (pack_namedv (make_namedv n)) == n)
[SMTPat (namedv_uniq (pack_namedv (make_namedv n)))]
let constant_as_term (v:vconst) = pack_ln (Tv_Const v)
let unit_exp = constant_as_term C_Unit
let unit_fv = pack_fv unit_lid
let unit_ty = pack_ln (Tv_FVar unit_fv)
let bool_fv = pack_fv bool_lid
let bool_ty = pack_ln (Tv_FVar bool_fv)
let u_zero = pack_universe Uv_Zero
let u_max u1 u2 = pack_universe (Uv_Max [u1; u2])
let u_succ u = pack_universe (Uv_Succ u)
let tm_type u = pack_ln (Tv_Type u)
let tm_prop =
let prop_fv = R.pack_fv R.prop_qn in
R.pack_ln (Tv_FVar prop_fv)
let eqtype_lid : R.name = ["Prims"; "eqtype"]
let true_bool = pack_ln (Tv_Const C_True)
let false_bool = pack_ln (Tv_Const C_False)
let eq2 (u:universe) (t v0 v1:term)
: term
= let eq2 = pack_fv eq2_qn in
let eq2 = pack_ln (Tv_UInst eq2 [u]) in
let h = pack_ln (Tv_App eq2 (t, Q_Implicit)) in
let h1 = pack_ln (Tv_App h (v0, Q_Explicit)) in
let h2 = pack_ln (Tv_App h1 (v1, Q_Explicit)) in
h2
let b2t_lid : R.name = ["Prims"; "b2t"]
let b2t_fv : R.fv = R.pack_fv b2t_lid
let b2t_ty : R.term = R.pack_ln (R.Tv_Arrow (mk_binder (seal "x") bool_ty Q_Explicit) (mk_total (tm_type u_zero)))
////////////////////////////////////////////////////////////////////////////////
// freevars
////////////////////////////////////////////////////////////////////////////////
let rec freevars (e:term)
: FStar.Set.set var
= match inspect_ln e with
| Tv_Uvar _ _ -> Set.complement Set.empty
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_BVar _ -> Set.empty
| Tv_Var x -> Set.singleton (namedv_uniq x)
| Tv_App e1 (e2, _) ->
Set.union (freevars e1) (freevars e2)
| Tv_Abs b body ->
Set.union (freevars_binder b) (freevars body)
| Tv_Arrow b c ->
Set.union (freevars_binder b) (freevars_comp c)
| Tv_Refine b f ->
freevars (binder_sort b) `Set.union`
freevars f
| Tv_Let recf attrs b def body ->
freevars_terms attrs `Set.union`
freevars (binder_sort b) `Set.union`
freevars def `Set.union`
freevars body
| Tv_Match scr ret brs ->
freevars scr `Set.union`
freevars_opt ret freevars_match_returns `Set.union`
freevars_branches brs
| Tv_AscribedT e t tac b ->
freevars e `Set.union`
freevars t `Set.union`
freevars_opt tac freevars
| Tv_AscribedC e c tac b ->
freevars e `Set.union`
freevars_comp c `Set.union`
freevars_opt tac freevars
and freevars_opt (#a:Type0) (o:option a) (f: (x:a { x << o } -> FStar.Set.set var))
: FStar.Set.set var
= match o with
| None -> Set.empty
| Some x -> f x
and freevars_comp (c:comp)
: FStar.Set.set var
= match inspect_comp c with
| C_Total t
| C_GTotal t ->
freevars t
| C_Lemma pre post pats ->
freevars pre `Set.union`
freevars post `Set.union`
freevars pats
| C_Eff us eff_name res args decrs ->
freevars res `Set.union`
freevars_args args `Set.union`
freevars_terms decrs
and freevars_args (ts:list argv)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| (t,q)::ts ->
freevars t `Set.union`
freevars_args ts
and freevars_terms (ts:list term)
: FStar.Set.set var
= match ts with
| [] -> Set.empty
| t::ts ->
freevars t `Set.union`
freevars_terms ts
and freevars_binder (b:binder)
: Tot (Set.set var) (decreases b)
= let bndr = inspect_binder b in
freevars bndr.sort `Set.union`
freevars_terms bndr.attrs
and freevars_pattern (p:pattern)
: Tot (Set.set var) (decreases p)
= match p with
| Pat_Constant _ ->
Set.empty
| Pat_Cons head univs subpats ->
freevars_patterns subpats
| Pat_Var bv s -> Set.empty
| Pat_Dot_Term topt ->
freevars_opt topt freevars
and freevars_patterns (ps:list (pattern & bool))
: Tot (Set.set var) (decreases ps)
= match ps with
| [] -> Set.empty
| (p, b)::ps ->
freevars_pattern p `Set.union`
freevars_patterns ps
and freevars_branch (br:branch)
: Tot (Set.set var) (decreases br)
= let p, t = br in
freevars_pattern p `Set.union`
freevars t
and freevars_branches (brs:list branch)
: Tot (Set.set var) (decreases brs)
= match brs with
| [] -> Set.empty
| hd::tl -> freevars_branch hd `Set.union` freevars_branches tl
and freevars_match_returns (m:match_returns_ascription)
: Tot (Set.set var) (decreases m)
= let b, (ret, as_, eq) = m in
let b = freevars_binder b in
let ret =
match ret with
| Inl t -> freevars t
| Inr c -> freevars_comp c
in
let as_ = freevars_opt as_ freevars in
b `Set.union` ret `Set.union` as_
let rec ln' (e:term) (n:int)
: Tot bool (decreases e)
= match inspect_ln e with
| Tv_UInst _ _
| Tv_FVar _
| Tv_Type _
| Tv_Const _
| Tv_Unknown
| Tv_Unsupp
| Tv_Var _ -> true
| Tv_BVar m -> bv_index m <= n
| Tv_App e1 (e2, _) -> ln' e1 n && ln' e2 n
| Tv_Abs b body ->
ln'_binder b n &&
ln' body (n + 1)
| Tv_Arrow b c ->
ln'_binder b n &&
ln'_comp c (n + 1)
| Tv_Refine b f ->
ln'_binder b n &&
ln' f (n + 1)
| Tv_Uvar _ _ ->
false
| Tv_Let recf attrs b def body ->
ln'_terms attrs n &&
ln'_binder b n &&
(if recf then ln' def (n + 1) else ln' def n) &&
ln' body (n + 1)
| Tv_Match scr ret brs ->
ln' scr n &&
(match ret with
| None -> true
| Some m -> ln'_match_returns m n) &&
ln'_branches brs n
| Tv_AscribedT e t tac b ->
ln' e n &&
ln' t n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
| Tv_AscribedC e c tac b ->
ln' e n &&
ln'_comp c n &&
(match tac with
| None -> true
| Some tac -> ln' tac n)
and ln'_comp (c:comp) (i:int)
: Tot bool (decreases c)
= match inspect_comp c with
| C_Total t
| C_GTotal t -> ln' t i
| C_Lemma pre post pats ->
ln' pre i &&
ln' post i &&
ln' pats i
| C_Eff us eff_name res args decrs ->
ln' res i &&
ln'_args args i &&
ln'_terms decrs i
and ln'_args (ts:list argv) (i:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| (t,q)::ts ->
ln' t i &&
ln'_args ts i
and ln'_binder (b:binder) (n:int)
: Tot bool (decreases b)
= let bndr = inspect_binder b in
ln' bndr.sort n &&
ln'_terms bndr.attrs n
and ln'_terms (ts:list term) (n:int)
: Tot bool (decreases ts)
= match ts with
| [] -> true
| t::ts -> ln' t n && ln'_terms ts n
and ln'_patterns (ps:list (pattern & bool)) (i:int)
: Tot bool
(decreases ps)
= match ps with
| [] -> true
| (p, b)::ps ->
let b0 = ln'_pattern p i in
let n = binder_offset_pattern p in
let b1 = ln'_patterns ps (i + n) in
b0 && b1
and ln'_pattern (p:pattern) (i:int)
: Tot bool
(decreases p)
= match p with
| Pat_Constant _ -> true
| Pat_Cons head univs subpats ->
ln'_patterns subpats i
| Pat_Var bv s -> true
| Pat_Dot_Term topt ->
(match topt with
| None -> true
| Some t -> ln' t i)
and ln'_branch (br:branch) (i:int)
: Tot bool (decreases br)
= let p, t = br in
let b = ln'_pattern p i in
let j = binder_offset_pattern p in
let b' = ln' t (i + j) in
b&&b'
and ln'_branches (brs:list branch) (i:int)
: Tot bool (decreases brs)
= match brs with
| [] -> true
| br::brs ->
ln'_branch br i &&
ln'_branches brs i
and ln'_match_returns (m:match_returns_ascription) (i:int)
: Tot bool (decreases m)
= let b, (ret, as_, eq) = m in
let b = ln'_binder b i in
let ret =
match ret with
| Inl t -> ln' t (i + 1)
| Inr c -> ln'_comp c (i + 1)
in
let as_ =
match as_ with
| None -> true
| Some t -> ln' t (i + 1)
in
b && ret && as_
let ln (t:term) = ln' t (-1)
let ln_comp (c:comp) = ln'_comp c (-1)
//
// term_ctxt is used to define the equiv relation later,
// basically putting two equiv terms in a hole gives equiv terms
//
// The abs, arrow, refine, and let cases don't seem right here,
// since to prove their equiv, we need to extend gamma for their bodies
//
// If this is useful only for app, then may be we should remove it,
// and add app rules to the equiv relation itself
[@@ no_auto_projectors]
noeq
type term_ctxt =
| Ctxt_hole : term_ctxt
| Ctxt_app_head : term_ctxt -> argv -> term_ctxt
| Ctxt_app_arg : term -> aqualv -> term_ctxt -> term_ctxt
// | Ctxt_abs_binder : binder_ctxt -> term -> term_ctxt
// | Ctxt_abs_body : binder -> term_ctxt -> term_ctxt
// | Ctxt_arrow_binder : binder_ctxt -> comp -> term_ctxt
// | Ctxt_arrow_comp : binder -> comp_ctxt -> term_ctxt
// | Ctxt_refine_sort : bv -> term_ctxt -> term -> term_ctxt
// | Ctxt_refine_ref : bv -> typ -> term_ctxt -> term_ctxt
// | Ctxt_let_sort : bool -> list term -> bv -> term_ctxt -> term -> term -> term_ctxt
// | Ctxt_let_def : bool -> list term -> bv -> term -> term_ctxt -> term -> term_ctxt
// | Ctxt_let_body : bool -> list term -> bv -> term -> term -> term_ctxt -> term_ctxt
// | Ctxt_match_scrutinee : term_ctxt -> option match_returns_ascription -> list branch -> term_ctxt
// and bv_ctxt =
// | Ctxt_bv : sealed string -> nat -> term_ctxt -> bv_ctxt
// and binder_ctxt =
// | Ctxt_binder : bv -> aqualv -> list term -> term_ctxt -> binder_ctxt
// and comp_ctxt =
// | Ctxt_total : term_ctxt -> comp_ctxt
// | Ctxt_gtotal : term_ctxt -> comp_ctxt
let rec apply_term_ctxt (e:term_ctxt) (t:term) : Tot term (decreases e) =
match e with
| Ctxt_hole -> t
| Ctxt_app_head e arg -> pack_ln (Tv_App (apply_term_ctxt e t) arg)
| Ctxt_app_arg hd q e -> pack_ln (Tv_App hd (apply_term_ctxt e t, q))
// | Ctxt_abs_binder b body -> pack_ln (Tv_Abs (apply_binder_ctxt b t) body)
// | Ctxt_abs_body b e -> pack_ln (Tv_Abs b (apply_term_ctxt e t))
// | Ctxt_arrow_binder b c -> pack_ln (Tv_Arrow (apply_binder_ctxt b t) c)
// | Ctxt_arrow_comp b c -> pack_ln (Tv_Arrow b (apply_comp_ctxt c t))
// | Ctxt_refine_sort b sort phi -> pack_ln (Tv_Refine b (apply_term_ctxt sort t) phi)
// | Ctxt_refine_ref b sort phi -> pack_ln (Tv_Refine b sort (apply_term_ctxt phi t))
// | Ctxt_let_sort b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv (apply_term_ctxt sort t) def body)
// | Ctxt_let_def b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort (apply_term_ctxt def t) body)
// | Ctxt_let_body b attrs bv sort def body ->
// pack_ln (Tv_Let b attrs bv sort def (apply_term_ctxt body t))
// | Ctxt_match_scrutinee sc ret brs ->
// pack_ln (Tv_Match (apply_term_ctxt sc t) ret brs)
// and apply_binder_ctxt (b:binder_ctxt) (t:term) : Tot binder (decreases b) =
// let Ctxt_binder binder_bv binder_qual binder_attrs ctxt = b in
// pack_binder {binder_bv; binder_qual; binder_attrs; binder_sort=apply_term_ctxt ctxt t}
// and apply_comp_ctxt (c:comp_ctxt) (t:term) : Tot comp (decreases c) =
// match c with
// | Ctxt_total e -> pack_comp (C_Total (apply_term_ctxt e t))
// | Ctxt_gtotal e -> pack_comp (C_GTotal (apply_term_ctxt e t))
noeq
type constant_typing: vconst -> term -> Type0 =
| CT_Unit: constant_typing C_Unit unit_ty
| CT_True: constant_typing C_True bool_ty
| CT_False: constant_typing C_False bool_ty
[@@ no_auto_projectors]
noeq
type univ_eq : universe -> universe -> Type0 =
| UN_Refl :
u:universe ->
univ_eq u u
| UN_MaxCongL :
u:universe ->
u':universe ->
v:universe ->
univ_eq u u' ->
univ_eq (u_max u v) (u_max u' v)
| UN_MaxCongR :
u:universe ->
v:universe ->
v':universe ->
univ_eq v v' ->
univ_eq (u_max u v) (u_max u v')
| UN_MaxComm:
u:universe ->
v:universe ->
univ_eq (u_max u v) (u_max v u)
| UN_MaxLeq:
u:universe ->
v:universe ->
univ_leq u v ->
univ_eq (u_max u v) v
and univ_leq : universe -> universe -> Type0 =
| UNLEQ_Refl:
u:universe ->
univ_leq u u
| UNLEQ_Succ:
u:universe ->
v:universe ->
univ_leq u v ->
univ_leq u (u_succ v)
| UNLEQ_Max:
u:universe ->
v:universe ->
univ_leq u (u_max u v)
let mk_if (scrutinee then_ else_:R.term) : R.term =
pack_ln (Tv_Match scrutinee None [(Pat_Constant C_True, then_);
(Pat_Constant C_False, else_)])
// effect and type
type comp_typ = T.tot_or_ghost & typ
let close_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) [ ND x i ]
let close_comp_typ (c:comp_typ) (x:var) =
close_comp_typ' c x 0
let open_comp_typ' (c:comp_typ) (x:var) (i:nat) =
fst c, subst_term (snd c) (open_with_var x i)
let open_comp_typ (c:comp_typ) (x:var) =
open_comp_typ' c x 0
let freevars_comp_typ (c:comp_typ) = freevars (snd c)
let mk_comp (c:comp_typ) : R.comp =
match fst c with
| T.E_Total -> mk_total (snd c)
| T.E_Ghost -> mk_ghost (snd c)
let mk_arrow_ct ty qual (c:comp_typ) : R.term =
R.pack_ln (R.Tv_Arrow (binder_of_t_q ty qual) (mk_comp c))
type relation =
| R_Eq
| R_Sub
let binding = var & term
let bindings = list binding
let rename_bindings bs x y = FStar.List.Tot.map (fun (v, t) -> (v, rename t x y)) bs
let rec extend_env_l (g:env) (bs:bindings)
: env
= match bs with
| [] -> g
| (x,t)::bs -> extend_env (extend_env_l g bs) x t
//
// TODO: support for erasable attribute
//
let is_non_informative_name (l:name) : bool =
l = R.unit_lid ||
l = R.squash_qn ||
l = ["FStar"; "Ghost"; "erased"]
let is_non_informative_fv (f:fv) : bool =
is_non_informative_name (inspect_fv f)
let rec __close_term_vs (i:nat) (vs : list var) (t : term) : Tot term (decreases vs) =
match vs with
| [] -> t
| v::vs ->
subst_term (__close_term_vs (i+1) vs t) [ND v i]
let close_term_vs (vs : list var) (t : term) : term =
__close_term_vs 0 vs t
let close_term_bs (bs : list binding) (t : term) : term =
close_term_vs (List.Tot.map fst bs) t
let bindings_to_refl_bindings (bs : list binding) : list R.binding =
L.map (fun (v, ty) -> {uniq=v; sort=ty; ppname = pp_name_default}) bs | false | true | FStar.Reflection.Typing.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val refl_bindings_to_bindings (bs: list R.binding) : list binding | [] | FStar.Reflection.Typing.refl_bindings_to_bindings | {
"file_name": "ulib/experimental/FStar.Reflection.Typing.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | bs: Prims.list FStar.Reflection.V2.Data.binding -> Prims.list FStar.Reflection.Typing.binding | {
"end_col": 36,
"end_line": 1054,
"start_col": 2,
"start_line": 1054
} |
Subsets and Splits