Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STLC specification could be more precise #47

Open
Pat-Lafon opened this issue Nov 3, 2024 · 0 comments
Open

STLC specification could be more precise #47

Pat-Lafon opened this issue Nov 3, 2024 · 0 comments

Comments

@Pat-Lafon
Copy link
Contributor

Pat-Lafon commented Nov 3, 2024

let (num_app_func : int) = int_range_inex 0 num in
let (num_app_arg : int) = int_range_inex 0 (num - num_app_func) in
let (func_ty : stlc_ty) = Stlc_ty_arr (arg_tau, tau) in
let (num_arr_func_ty : int) = get_num_arr func_ty in
let (func : stlc_term) =
gen_term_size num_arr_func_ty num_app_func gamma
(Stlc_ty_arr (arg_tau, tau))
in
let (num_arr_arg_ty : int) = get_num_arr arg_tau in
let (arg : stlc_term) =
gen_term_size num_arr_arg_ty num_app_arg gamma arg_tau
in
Stlc_app (func, arg)
else
match tau with
| Stlc_ty_nat -> Err
| Stlc_ty_arr (tau1, tau2) ->
let (num_arr_tau2 : int) = get_num_arr tau2 in
let (body : stlc_term) =
gen_term_size num_arr_tau2 num (Stlc_tyctx_cons (tau1, gamma)) tau2
in
Stlc_abs (tau1, body)
let[@assert] gen_term_size =
let num_arr_tau = (v >= 0 : [%v: int]) [@over] in
let num = (v >= 0 : [%v: int]) [@over] in
let gamma = (true : [%v: stlc_tyctx]) [@over] in
let tau = (num_arr v num_arr_tau : [%v: stlc_ty]) [@over] in
(typing gamma v tau && num_app v num : [%v: stlc_term]) [@under]

where num_app_func and num_app_arg are sum so something <= num -1 which plus the eventual application covers all numbers of applications <= num. The specification says typing gamma v tau && num_app v num which is covering applications equal to num.

One can either change

let (num_app_arg : int) = int_range_inex 0 (num - num_app_func) in
to be num - num_app_func - 1 or change the top level specification to fun (n[@exists]: int) -> typing gamma v tau && num_app v n && n <= num

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant