mirror of
https://github.com/ProgramSnail/pass_strategy_synthesis.git
synced 2026-04-29 09:14:35 +00:00
model description fixes & additions, correct memoisation in synthesizer (rec test passed)
This commit is contained in:
parent
0b261943db
commit
036322903b
3 changed files with 39 additions and 10 deletions
|
|
@ -9,6 +9,19 @@
|
||||||
|
|
||||||
*TODO: проблемы с добавлением if в будущем: как записать write and not write ?*
|
*TODO: проблемы с добавлением if в будущем: как записать write and not write ?*
|
||||||
|
|
||||||
|
Нужно будет добавить во write-flag модальности: `not write` | `may write` | `always write`
|
||||||
|
|
||||||
|
Добавление condition-исполнения - выбор из нескольких блоков. Варианты:
|
||||||
|
- & of | of & -вложенные блоки ?
|
||||||
|
- добавить несколько альтернативны тел функциям. Но тогда придётся при трансляции if-блоки выносить в функции
|
||||||
|
|
||||||
|
Лямбды - нужно тоже будет как-то находить лямбды и ля них тоже синтезировать атрибуты
|
||||||
|
вызов лямбд будет нужен в модели?
|
||||||
|
- lambda-аргумент - вложенные теги?, должна быть одна и та же сигнтура
|
||||||
|
можно ввести отдельные сигнатуры-определения?
|
||||||
|
|
||||||
|
проблема простой семантики: вызов лямбд: могут быть модифицируемые функции
|
||||||
|
|
||||||
== Синтаксис
|
== Синтаксис
|
||||||
|
|
||||||
#h(10pt)
|
#h(10pt)
|
||||||
|
|
@ -146,7 +159,7 @@ $d space @ space overline(x)$ - запись применения функции
|
||||||
name: [ is correct],
|
name: [ is correct],
|
||||||
$isOut tag -> isWrite tag$, // NOTE; strong requirment should write
|
$isOut tag -> isWrite tag$, // NOTE; strong requirment should write
|
||||||
$isRead tag -> isIn tag$,
|
$isRead tag -> isIn tag$,
|
||||||
$isWrite tag -> isWrite sigma(x)$, // NOTE: may tag => should sigma(x)
|
$isWrite tag and (isOut tag or not isCopy tag) -> isWrite sigma(x)$, // NOTE: may tag => should sigma(x)
|
||||||
$isRead tag -> mu (sigma(x)) != bot$, // NOTE: may tag -> ...
|
$isRead tag -> mu (sigma(x)) != bot$, // NOTE: may tag -> ...
|
||||||
|
|
||||||
$isCorrect_(cl sigma, mu cr) (tag, x)$,
|
$isCorrect_(cl sigma, mu cr) (tag, x)$,
|
||||||
|
|
|
||||||
|
|
@ -520,6 +520,14 @@ struct
|
||||||
list_dropo n' ys xs' }
|
list_dropo n' ys xs' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let rec list_not_membero xs x = ocanren {
|
||||||
|
xs == [] |
|
||||||
|
{ fresh x', xs' in
|
||||||
|
xs == x' :: xs' &
|
||||||
|
x' =/= x &
|
||||||
|
list_not_membero xs' x }
|
||||||
|
}
|
||||||
|
|
||||||
let visited_checko state f_id =
|
let visited_checko state f_id =
|
||||||
let open St in
|
let open St in
|
||||||
ocanren {
|
ocanren {
|
||||||
|
|
@ -528,8 +536,13 @@ struct
|
||||||
List.membero visited f_id
|
List.membero visited f_id
|
||||||
}
|
}
|
||||||
|
|
||||||
(* TODO *)
|
let not_visited_checko state f_id =
|
||||||
(* let visited_not_checko state f_id = ??? *)
|
let open St in
|
||||||
|
ocanren {
|
||||||
|
fresh _env, _mem, _mem_len, visited in
|
||||||
|
state == St (_env, _mem, _mem_len, visited) &
|
||||||
|
list_not_membero visited f_id
|
||||||
|
}
|
||||||
|
|
||||||
let visited_addo state f_id state' =
|
let visited_addo state f_id state' =
|
||||||
let open St in
|
let open St in
|
||||||
|
|
@ -546,16 +559,21 @@ struct
|
||||||
let open FunDecl in
|
let open FunDecl in
|
||||||
let open Tag in
|
let open Tag in
|
||||||
ocanren {
|
ocanren {
|
||||||
{ fresh f_id, args, f, args', state_after_call, state_with_visited, arg_tags, _body in
|
{ fresh f_id, args, f, args', state_after_call, arg_tags, _body in
|
||||||
stmt == Call (f_id, args) &
|
stmt == Call (f_id, args) &
|
||||||
list_ntho prog f_id f &
|
list_ntho prog f_id f &
|
||||||
FunDecl (arg_tags, _body) == f &
|
FunDecl (arg_tags, _body) == f &
|
||||||
List.mapo arg_to_lvalueo args args' &
|
List.mapo arg_to_lvalueo args args' &
|
||||||
(* TODO: FIXME: memoisation, do not do calls on check successfull *)
|
(* TODO: FIXME: memoisation, do not do calls on check successfull *)
|
||||||
eval_funo state prog f args' state_after_call &
|
|
||||||
(* NOTE: tmp simplification for less branching (TODO?) *)
|
(* NOTE: tmp simplification for less branching (TODO?) *)
|
||||||
visited_addo state_after_call f_id state_with_visited &
|
{ { fresh state_with_visited in
|
||||||
st_spoil_by_argso state_with_visited arg_tags args state' } |
|
not_visited_checko state f_id &
|
||||||
|
visited_addo state f_id state_with_visited &
|
||||||
|
eval_funo state_with_visited prog f args' state_after_call } |
|
||||||
|
{ visited_checko state f_id &
|
||||||
|
state_after_call == state } } &
|
||||||
|
st_spoil_by_argso state_after_call arg_tags args state' } |
|
||||||
{ fresh id in stmt == Read id & mem_checko state id & state == state' } |
|
{ fresh id in stmt == Read id & mem_checko state id & state == state' } |
|
||||||
{ fresh id, tag, _mem_id in
|
{ fresh id, tag, _mem_id in
|
||||||
stmt == Write id &
|
stmt == Write id &
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,5 @@ let%expect_test "synthesis test 7" = print_endline (synt_t7 ()); [%expect {| [[V
|
||||||
let%expect_test "synthesis test 8" = print_endline (synt_t8 ()); [%expect {| [[Val; Val]; [Val; Ref]] |}]
|
let%expect_test "synthesis test 8" = print_endline (synt_t8 ()); [%expect {| [[Val; Val]; [Val; Ref]] |}]
|
||||||
let%expect_test "synthesis test 9" = print_endline (synt_t9 ()); [%expect {| [[Val; Ref]; [Val; Val]] |}]
|
let%expect_test "synthesis test 9" = print_endline (synt_t9 ()); [%expect {| [[Val; Ref]; [Val; Val]] |}]
|
||||||
|
|
||||||
(* TODO: FIXME: implement memoization cuts *)
|
let%expect_test "recursive eval test" = print_endline (rec_eval_t ()); [%expect {| [St ([], [], O, [O])] |}]
|
||||||
(* NOTE: inf test in current model (without additional functional interfaces and ) *)
|
|
||||||
(* let%expect_test "recursive eval test" = print_endline (rec_eval_t ()); [%expect {| [St ([], [], O, [])] |}] *)
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue