2026-03-29 15:32:35 +00:00
|
|
|
|
// #import "@preview/polylux:0.4.0": *
|
|
|
|
|
|
#import "@preview/simplebnf:0.1.1": *
|
|
|
|
|
|
// #import "@preview/zebraw:0.5.0": *
|
|
|
|
|
|
// #show: zebraw
|
|
|
|
|
|
#import "@preview/curryst:0.6.0": rule, prooftree, rule-set
|
2026-04-04 13:07:15 +00:00
|
|
|
|
#import "@preview/xarrow:0.4.0": xarrow, xarrowDashed, xarrowSquiggly
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
= Формальная модель используемого языка
|
|
|
|
|
|
|
2026-04-04 13:07:15 +00:00
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: check correctnes for path, mem & type ??
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-11 13:17:15 +00:00
|
|
|
|
== Syntax
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
2026-04-19 11:10:52 +00:00
|
|
|
|
#let rf = $\& #h(3pt)$
|
|
|
|
|
|
|
2026-03-29 15:32:35 +00:00
|
|
|
|
#let isCorrect = `isCorrect`
|
|
|
|
|
|
|
|
|
|
|
|
#let isRead = `isRead`
|
|
|
|
|
|
#let isAlwaysWrite = `isAlwaysWrite`
|
|
|
|
|
|
#let isPossibleWrite = `isPossibleWrite`
|
|
|
|
|
|
#let isRef = `isRef`
|
|
|
|
|
|
#let isCopy = `isCopy`
|
|
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
#let readTag = `read`
|
|
|
|
|
|
#let writeTag = `write`
|
|
|
|
|
|
#let copyTag = `copy`
|
|
|
|
|
|
#let inTag = `in`
|
|
|
|
|
|
#let outTag = `out`
|
2026-04-11 13:17:15 +00:00
|
|
|
|
#let mode = `mode`
|
2026-04-19 13:13:51 +00:00
|
|
|
|
|
|
|
|
|
|
#let Copy = `Copy`
|
|
|
|
|
|
#let Ref = `Ref`
|
|
|
|
|
|
#let MaybeWrite = [$diamond$ `Write`]
|
|
|
|
|
|
#let AlwaysWrite = [$square$ `Write`]
|
|
|
|
|
|
#let Read = `Read`
|
|
|
|
|
|
#let In = `In`
|
|
|
|
|
|
#let Out = `Out`
|
|
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
#let cl = $chevron.l$
|
|
|
|
|
|
#let cr = $chevron.r$
|
|
|
|
|
|
|
2026-04-11 13:17:15 +00:00
|
|
|
|
#let expr = `expr`
|
2026-03-29 15:32:35 +00:00
|
|
|
|
#let stmt = `stmt`
|
|
|
|
|
|
#let decl = `decl`
|
|
|
|
|
|
#let prog = `prog`
|
|
|
|
|
|
#let path = `path`
|
2026-04-11 13:17:15 +00:00
|
|
|
|
#let type = `type`
|
2026-04-19 13:13:51 +00:00
|
|
|
|
#let modedType = `modedtype`
|
2026-03-29 15:32:35 +00:00
|
|
|
|
#bnf(
|
|
|
|
|
|
Prod(`read`,
|
2026-04-11 13:17:15 +00:00
|
|
|
|
// NOTE: not three modalities for write, because read does not change value
|
|
|
|
|
|
// => it is not important to observe rsult, no differenc between always and maybe
|
2026-03-29 15:32:35 +00:00
|
|
|
|
{ Or[Read][read passed value]
|
2026-04-11 13:17:15 +00:00
|
|
|
|
Or[$not$ Read][] } ),
|
2026-03-29 15:32:35 +00:00
|
|
|
|
Prod(`write`,
|
2026-04-25 13:43:12 +00:00
|
|
|
|
{ Or[$square$ Write][in all cases there is a write to the variable] // always write, requre at least one write in each flow variant
|
|
|
|
|
|
Or[$diamond$ Write][in some cases there is a write to the variable] // possible write, no requirements (?)
|
|
|
|
|
|
Or[$not$ Write][in none cases there is a write to the variable ] } ), // no write, require n owrites in all flow variants
|
2026-03-29 15:32:35 +00:00
|
|
|
|
Prod(`copy`,
|
|
|
|
|
|
{ Or[Ref][pass reference to the value]
|
|
|
|
|
|
Or[Value][pass copy of the value] } ),
|
|
|
|
|
|
Prod(`in`,
|
|
|
|
|
|
{ Or[In][parameter value used as input]
|
2026-04-11 13:17:15 +00:00
|
|
|
|
Or[$not$ In][] } ),
|
2026-03-29 15:32:35 +00:00
|
|
|
|
Prod(`out`,
|
2026-04-11 13:17:15 +00:00
|
|
|
|
{ Or[Out][parameter value returned]
|
|
|
|
|
|
Or[$not$ Out][] } ),
|
2026-03-29 15:32:35 +00:00
|
|
|
|
Prod(
|
2026-04-11 13:17:15 +00:00
|
|
|
|
`mode`,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
{
|
2026-04-19 13:13:51 +00:00
|
|
|
|
Or[$inTag space outTag$][]
|
2026-03-29 15:32:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
Prod(
|
|
|
|
|
|
`path`,
|
|
|
|
|
|
{
|
2026-04-11 13:17:15 +00:00
|
|
|
|
// NOTE: global vars & local vars names could be used with one constructor
|
|
|
|
|
|
// Or[$\#x$][funciton or global variable itself]
|
|
|
|
|
|
Or[$@ X$][function argument or variable itself]
|
2026-04-04 13:07:15 +00:00
|
|
|
|
Or[$* path$][reference insede path]
|
2026-03-29 15:32:35 +00:00
|
|
|
|
Or[$path . n$][access $n$-th cell of the tuple]
|
2026-04-04 13:07:15 +00:00
|
|
|
|
// Or[$path : n$][access $n$-th cell of the union] // TODO: another notation ??
|
2026-03-29 15:32:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
Prod(
|
2026-04-11 13:17:15 +00:00
|
|
|
|
`type`,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
{
|
2026-04-25 13:43:12 +00:00
|
|
|
|
Or[$cl readTag, writeTag cr$][simple type representing all primitive types] // `Unit`
|
|
|
|
|
|
Or[$rf copyTag type$][reference to structure, contains copy / ref choice] // `Ref`
|
2026-04-11 14:51:56 +00:00
|
|
|
|
Or[$[type+]$][tuple type] // `Prod`
|
2026-04-11 13:17:15 +00:00
|
|
|
|
// Or[`type` $times$ `type`][pair type, allows to make tuples] // `Prod`
|
|
|
|
|
|
// Or[`type` $+$ `type`][union type (important in some way ???)] // `Sum` // TODO ?
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: do not use names in type
|
|
|
|
|
|
// Or[$lambda_((x type)+)$][type of lambda or function pointer, defined by function declaration] // `Fun`
|
2026-04-19 13:13:51 +00:00
|
|
|
|
Or[$lambda (modedType)+$][type of lambda or function pointer, defined by function declaration] // `Fun`
|
|
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
Prod(
|
|
|
|
|
|
`modedtype`,
|
|
|
|
|
|
{
|
|
|
|
|
|
Or[$mode type$][type woth in and out modifiers]
|
2026-03-29 15:32:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
Prod(
|
2026-04-11 13:17:15 +00:00
|
|
|
|
`expr`,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
{
|
2026-04-11 13:17:15 +00:00
|
|
|
|
Or[$()$][value of simple type] // `Unit`
|
|
|
|
|
|
Or[$path$][value from variable] // `Path`
|
2026-04-19 11:10:52 +00:00
|
|
|
|
Or[$rf expr$][reference expr] // `Ref`
|
2026-04-11 14:51:56 +00:00
|
|
|
|
Or[$[expr+]$][tuple expr] // `Prod`
|
2026-03-29 15:32:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
Prod(
|
|
|
|
|
|
`stmt`,
|
|
|
|
|
|
{
|
2026-04-19 13:13:51 +00:00
|
|
|
|
Or[`CALL` $path space expr+$][call function]
|
2026-03-29 15:32:35 +00:00
|
|
|
|
Or[`WRITE` $path$][write to variable]
|
|
|
|
|
|
Or[`READ` $path$][read from variable]
|
2026-04-11 13:17:15 +00:00
|
|
|
|
Or[$stmt ; stmt$][control flow operator, xecution ]
|
|
|
|
|
|
Or[$stmt | stmt$][control flow operator, excution of one statements]
|
2026-03-29 15:32:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
Prod(
|
|
|
|
|
|
`decl`,
|
|
|
|
|
|
{
|
2026-04-11 13:17:15 +00:00
|
|
|
|
// TODO: path not allowed ??
|
|
|
|
|
|
Or[$"var" X : type = expr$][global variable declaration]
|
2026-04-19 13:13:51 +00:00
|
|
|
|
Or[$"fun" X ((X : modedType)+) = stmt$][function declaration]
|
2026-03-29 15:32:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
Prod(
|
|
|
|
|
|
`prog`,
|
|
|
|
|
|
{
|
2026-04-11 13:17:15 +00:00
|
|
|
|
Or[$decl stmt$][declarations and executet statement]
|
|
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
== Value Model
|
|
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
#let deepValue = `deepvalue`
|
2026-04-11 13:17:15 +00:00
|
|
|
|
#let value = `value`
|
2026-04-19 13:13:51 +00:00
|
|
|
|
|
2026-04-11 13:17:15 +00:00
|
|
|
|
#bnf(
|
|
|
|
|
|
Prod(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
$deepValue$,
|
2026-04-11 13:17:15 +00:00
|
|
|
|
{
|
2026-04-14 11:32:28 +00:00
|
|
|
|
Or[$0$][valid value of simple type] // `Unit`
|
|
|
|
|
|
Or[$\#$][valid or spoiled value of simple type] // `Unit`
|
|
|
|
|
|
Or[$bot$][spoiled value of simple type] // `Unit`
|
2026-04-25 13:43:12 +00:00
|
|
|
|
Or[$lambda$][function pointer value] // `Fun`
|
2026-04-19 13:13:51 +00:00
|
|
|
|
Or[$rf deepValue$][reference value, contains label of the value in the memory] // `Ref`
|
|
|
|
|
|
Or[$[deepValue+]$][tuple value] // `Prod`
|
2026-04-14 11:32:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
Prod(
|
|
|
|
|
|
$value_mu$,
|
|
|
|
|
|
{
|
|
|
|
|
|
Or[$0$][valid value of simple type] // `Unit`
|
|
|
|
|
|
Or[$\#$][valid or spoiled value of simple type] // `Unit`
|
|
|
|
|
|
Or[$bot$][spoiled value of simple type] // `Unit`
|
2026-04-25 13:43:12 +00:00
|
|
|
|
Or[$lambda$][function pointer value] // `Fun`
|
|
|
|
|
|
Or[$rf LL$][reference value, contains label of the value in the memory] // `Ref`
|
2026-04-11 14:51:56 +00:00
|
|
|
|
Or[$[value+]$][tuple value] // `Prod`
|
2026-03-29 15:32:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
2026-04-11 13:17:15 +00:00
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
#deepValue - полное значение, #value - слой значения, привязан к конкретной памяти $mu$
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
|
|
|
|
|
Значения, могут лежать в переменных и передаваться как аргументы функций (то, во что вычисляется $expr$)
|
|
|
|
|
|
|
|
|
|
|
|
$v in value$ - произвольное значение
|
|
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
Получение #deepValue по #value:
|
2026-04-25 13:43:12 +00:00
|
|
|
|
- $rf l xarrowSquiggly(mu)_#[deep] rf mu[l]$
|
2026-04-14 11:32:28 +00:00
|
|
|
|
- $* xarrowSquiggly(mu)_#[deep] *$
|
2026-04-19 11:10:52 +00:00
|
|
|
|
где $*$ - произвольный конструктор значения, кроме $rf$
|
2026-04-11 13:17:15 +00:00
|
|
|
|
|
|
|
|
|
|
== Memory Model
|
|
|
|
|
|
|
2026-04-11 14:51:56 +00:00
|
|
|
|
#let mem = `mem`
|
2026-04-11 13:17:15 +00:00
|
|
|
|
|
2026-04-14 11:32:28 +00:00
|
|
|
|
- $LL$ - множество меток памяти
|
|
|
|
|
|
- $mem := LL -> value, space mu : mem$ - память, частично определённая функция
|
|
|
|
|
|
- $l in LL$ - новый тег памяти (ранее не использованный)
|
2026-04-19 11:10:52 +00:00
|
|
|
|
- `next` - получение следующей неиспользованной метки в памяти
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ add value to memory],
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-19 11:10:52 +00:00
|
|
|
|
$l = #[next] (mu)$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-19 11:10:52 +00:00
|
|
|
|
$cl mu cr xarrowSquiggly(v)_#[add] cl l, mu [l <- v] cr$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-11 14:51:56 +00:00
|
|
|
|
== Semantics
|
|
|
|
|
|
|
2026-04-11 14:54:39 +00:00
|
|
|
|
// $V := memelem$ - значения памяти
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
$X$ - можество переменных
|
|
|
|
|
|
|
2026-04-14 11:32:28 +00:00
|
|
|
|
// FIXME: TMP
|
|
|
|
|
|
#let valuemem = `valuemem`
|
|
|
|
|
|
#let memelem = `memelem`
|
|
|
|
|
|
#let pathenvmode = `pathenvmode`
|
|
|
|
|
|
#let pathenvval = `pathenvval`
|
|
|
|
|
|
#let pathenvmem = `pathenvmem`
|
|
|
|
|
|
#let pathenvtype = `pathenvtype`
|
|
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
#let vals = $Sigma$
|
|
|
|
|
|
#let types = $Gamma$
|
|
|
|
|
|
#let envv = $#[env]_Sigma$
|
|
|
|
|
|
#let envt = $#[env]_Gamma$
|
|
|
|
|
|
$sigma : envv := X -> LL, space vals : envv$ - #[ метки памяти перменных контекста, частично определённая функция ]
|
|
|
|
|
|
$sigma : envt := X -> type, space types : envt$ - #[ типы значений перменных контекста, частично определённая функция ]
|
2026-04-11 13:17:15 +00:00
|
|
|
|
|
2026-04-14 11:32:28 +00:00
|
|
|
|
// $DD : X -> decl$ - глобальные определения, частично определённая функция
|
2026-04-11 13:17:15 +00:00
|
|
|
|
|
2026-04-14 11:32:28 +00:00
|
|
|
|
// $d in decl, $
|
|
|
|
|
|
$s in stmt, f in X, x in X, a in X$
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-14 11:32:28 +00:00
|
|
|
|
// FIXME ??
|
|
|
|
|
|
// $d space @ space overline(x)$ - запись применения функции (вида #decl) к аргументам
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-11 14:51:56 +00:00
|
|
|
|
=== Path Accessors
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-11 14:51:56 +00:00
|
|
|
|
Набор частично определённых фунций для работы с путями.
|
|
|
|
|
|
Для удобства значение, получаемое из текущего применением пути, будем называть полем.
|
|
|
|
|
|
// Все эти функции используются с префиксом `path.`.
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-14 11:32:28 +00:00
|
|
|
|
#let eqmu = $attach(=, br: mu)$
|
|
|
|
|
|
#let arrmu = $attach(->, br: mu)$
|
|
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
#let arrpath = $xarrowSquiggly(mu)_path$
|
|
|
|
|
|
|
2026-04-14 11:32:28 +00:00
|
|
|
|
#let ttype = $attach(tack.r, br: type)$
|
|
|
|
|
|
#let tmode = $attach(tack.r, br: mode)$
|
|
|
|
|
|
|
|
|
|
|
|
#let val = `val`
|
|
|
|
|
|
#let label = `label`
|
|
|
|
|
|
#let tval = $attach(tack.r, br: val)$
|
|
|
|
|
|
#let tlabel = $attach(tack.r, br: label)$
|
|
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
// TODO: TMP, deprecated
|
|
|
|
|
|
// #let tetype = $attach(tack.r.double, br: type)$
|
|
|
|
|
|
// #let temode = $attach(tack.r.double, br: mode)$
|
|
|
|
|
|
// #let telabel = $attach(tack.r.double, br: label)$
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
|
|
|
|
|
#let teval = $attach(tack.r.double, br: val)$
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: env mem label ??, env mem value ??
|
|
|
|
|
|
|
|
|
|
|
|
- #[ Конструирование путей по переменой
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ variable path],
|
|
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$@x arrpath x$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ reference path],
|
|
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$p arrpath x$,
|
|
|
|
|
|
$rf p arrpath x$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ tuple access path],
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$p arrpath x$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$p.i arrpath x$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
]
|
2026-04-11 14:51:56 +00:00
|
|
|
|
|
|
|
|
|
|
- #[ Получение типа поля
|
2026-04-14 11:32:28 +00:00
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ variable type access],
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$x : t_x in types$,
|
|
|
|
|
|
$types ttype @x : t_x$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ reference type access],
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$types ttype p : rf mode t_p$,
|
|
|
|
|
|
$types ttype *p : t_p$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ tuple type access],
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$types ttype p : [t_1, ... t_n]$,
|
|
|
|
|
|
$types ttype p.i : t_i$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
2026-04-11 14:51:56 +00:00
|
|
|
|
]
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
// TODO: not required (trivial) ??
|
|
|
|
|
|
// - #[ Получение read-write тега поля
|
|
|
|
|
|
// #align(center, prooftree(
|
|
|
|
|
|
// vertical-spacing: 4pt,
|
|
|
|
|
|
// rule(
|
|
|
|
|
|
// name: [ rw tag access],
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
// $types ttype p : cl r, w cr$,
|
|
|
|
|
|
// $types tmode p -> cl r, w cr$,
|
|
|
|
|
|
// )
|
|
|
|
|
|
// ))
|
|
|
|
|
|
// ]
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
|
|
|
|
|
- #[ Получение значения поля
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ variable value access],
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$x -> l in vals$,
|
|
|
|
|
|
$mu[l] = v$,
|
|
|
|
|
|
$vals, mu tval x eqmu v$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ reference value access],
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$vals, mu tval p eqmu rf l$,
|
|
|
|
|
|
$vals, mu tval *p eqmu mu[l]$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ tuple value access],
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$vals, mu tval p eqmu [v_1, ... v_n]$,
|
|
|
|
|
|
$vals, mu tval p.i eqmu v_i$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
2026-04-11 14:51:56 +00:00
|
|
|
|
]
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
// TODO: FIXME: not required (trivial) ??
|
|
|
|
|
|
// - #[ Получение метки поля
|
|
|
|
|
|
// #align(center, prooftree(
|
|
|
|
|
|
// vertical-spacing: 4pt,
|
|
|
|
|
|
// rule(
|
|
|
|
|
|
// name: [ access],
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
// $vals, mu tval p eqmu rf l$,
|
|
|
|
|
|
// $vals, mu tmode p arrmu l$,
|
|
|
|
|
|
// )
|
|
|
|
|
|
// ))
|
|
|
|
|
|
// ]
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: not required (trivial) ??
|
|
|
|
|
|
// - #[ Получение read-write тега поля по окружению
|
|
|
|
|
|
// #align(center, prooftree(
|
|
|
|
|
|
// vertical-spacing: 4pt,
|
|
|
|
|
|
// rule(
|
|
|
|
|
|
// name: [ access],
|
|
|
|
|
|
|
|
|
|
|
|
// $x : types[x] tmode p -> cr r space w cl$,
|
|
|
|
|
|
// $sigma temode p -> cr r space w cl$,
|
|
|
|
|
|
// )
|
|
|
|
|
|
// ))
|
|
|
|
|
|
// ]
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
|
|
|
|
|
- #[ Получение значения поля по окружению
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ access],
|
2026-04-14 11:32:28 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$x eqmu vals[x] tval p eqmu v$,
|
|
|
|
|
|
$types, vals, mu teval p eqmu x$,
|
2026-04-14 11:32:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
2026-04-11 14:51:56 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
// FIXME: move to new mode model
|
|
|
|
|
|
// === Mode Correctness
|
2026-04-11 14:51:56 +00:00
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
// Функции проверки тегов, имеют тип $mode -> #[bool]$:
|
2026-04-11 14:51:56 +00:00
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
// #let modevar = $(r space w space c space i space o)$
|
2026-04-11 14:51:56 +00:00
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
// $ isRead modevar = r == "Read" $
|
|
|
|
|
|
// $ isAlwaysWrite modevar = w == square "Write" $
|
|
|
|
|
|
// $ isPossibleWrite modevar = w == diamond "Write" || w == square "Write" $
|
|
|
|
|
|
// $ isRef modevar = c == "Ref" $
|
|
|
|
|
|
// $ isCopy modevar = c == "Copy" $
|
|
|
|
|
|
// $ isIn modevar = i == "In" $
|
|
|
|
|
|
// $ isOut modevar = o == "Out" $
|
2026-04-11 14:51:56 +00:00
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
// Требования к тегам:
|
2026-04-11 14:51:56 +00:00
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
// $ isOut mode -> isAlwaysWrite mode $
|
|
|
|
|
|
// $ isRead mode -> isIn mode $
|
2026-04-11 14:51:56 +00:00
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
// TODO: rest conditions ??
|
|
|
|
|
|
|
|
|
|
|
|
=== Eval Rules
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
#let args = `args`
|
|
|
|
|
|
|
|
|
|
|
|
#[
|
|
|
|
|
|
|
|
|
|
|
|
#let ref = `ref`
|
|
|
|
|
|
#let copy = `copy`
|
|
|
|
|
|
#let read = `read`
|
|
|
|
|
|
|
|
|
|
|
|
// #align(center, grid(
|
|
|
|
|
|
// columns: 3,
|
|
|
|
|
|
// gutter: 5%,
|
|
|
|
|
|
// align(bottom, prooftree(
|
|
|
|
|
|
// ...
|
|
|
|
|
|
// )),
|
|
|
|
|
|
// align(bottom, prooftree(
|
|
|
|
|
|
// ...
|
|
|
|
|
|
// )),
|
|
|
|
|
|
// align(bottom, prooftree(
|
|
|
|
|
|
// ...
|
|
|
|
|
|
// )),
|
|
|
|
|
|
// ))
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: introduce spep env argument ??
|
|
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
=== Moded Type Correctness
|
2026-04-04 13:07:15 +00:00
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
#let tcorrect = $attach(tack.r, br: #[correct])$
|
2026-04-19 11:10:52 +00:00
|
|
|
|
|
2026-04-11 13:17:15 +00:00
|
|
|
|
// TODO: FIXME: well formatness for mode, extract
|
|
|
|
|
|
// TODO: FIXME: check for mode, is recursion required ??
|
|
|
|
|
|
// TODO: FIXME: check mode & access corectness in os correct
|
|
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$ vals in envv, types in envt, space mu in mem, space m in mode,
|
2026-04-19 13:13:51 +00:00
|
|
|
|
space c in copyTag, space r, r' in readTag, space w, w' in writeTag,
|
|
|
|
|
|
space v in value, space t, t' in type $
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
// TODO: FIXME: complete rule check
|
|
|
|
|
|
// + add part about ref -> not copy later
|
2026-03-29 15:32:35 +00:00
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ unit assignment tags correctness],
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-25 13:45:24 +00:00
|
|
|
|
$r = Read => m = (In, \_)$,
|
|
|
|
|
|
$m = (\_, Out) => w = AlwaysWrite$,
|
2026-04-19 13:13:51 +00:00
|
|
|
|
// $sigma temode x -> cr r' space w' cl$, // NOTE: not required, value passed
|
2026-04-25 13:45:24 +00:00
|
|
|
|
$(w = AlwaysWrite or w = MaybeWrite) and (m = (\_, Out) or c = Ref) => w' = AlwaysWrite$,
|
2026-04-19 13:13:51 +00:00
|
|
|
|
|
|
|
|
|
|
// $sigma, mu teval x eqmu v$, // NOTE: not required, value passed
|
|
|
|
|
|
$v in {0, \#, bot}$,
|
|
|
|
|
|
$r = Read => v = 0$,
|
|
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$types, vals, mu, m, c tcorrect v : cl r', w' cr -> cl r, w cr$,
|
2026-04-19 13:13:51 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-25 13:43:12 +00:00
|
|
|
|
name: [ function pointer tags correctness],
|
2026-04-19 13:13:51 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$types, vals, mu, m, c tcorrect lambda : lambda space overline(t) -> lambda space overline(t)$,
|
2026-04-19 13:13:51 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-25 13:43:12 +00:00
|
|
|
|
name: [ ref assignment tags correctness],
|
2026-04-19 13:13:51 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$types, vals, mu, m, c_r tcorrect v : t -> t'$,
|
2026-04-19 13:13:51 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
// TODO: FIXME: which tag translations are correct ?? <- only assignee?
|
|
|
|
|
|
$types, vals, mu, m, c tcorrect rf space v : rf c' space t -> rf c_r space t'$,
|
2026-04-19 13:13:51 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-25 13:43:12 +00:00
|
|
|
|
name: [ tuple assignmenttags correctness],
|
2026-04-19 13:13:51 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$types, vals, mu, m, c tcorrect v_1 : t_1 -> t'_1$,
|
|
|
|
|
|
|
|
|
|
|
|
$...$,
|
|
|
|
|
|
|
|
|
|
|
|
$types, vals, mu, m, c tcorrect v_n : t_n -> t'_n$,
|
|
|
|
|
|
|
|
|
|
|
|
$types, vals, mu, m, c tcorrect [v_1, ... v_n] : [t_1, ..., t_n] -> [t'_1, ... t'_n]$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
2026-04-19 11:10:52 +00:00
|
|
|
|
=== Value Construction
|
2026-04-04 13:07:15 +00:00
|
|
|
|
|
2026-04-25 14:51:38 +00:00
|
|
|
|
// TODO: FIXME:add ref / copy modes correctness check ??
|
2026-04-25 13:43:12 +00:00
|
|
|
|
|
2026-04-19 11:10:52 +00:00
|
|
|
|
#let new = `new`
|
2026-04-03 10:05:23 +00:00
|
|
|
|
|
2026-04-19 11:10:52 +00:00
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ new $0$ value],
|
2026-04-03 10:05:23 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl 0, mu cr xarrowSquiggly(cl r\, w cr)_new cl 0, mu cr$,
|
2026-04-19 11:10:52 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
2026-04-04 13:07:15 +00:00
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 11:10:52 +00:00
|
|
|
|
name: [ new $\#$ value],
|
2026-04-04 13:07:15 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl \#, mu cr xarrowSquiggly(cl r\, w cr)_new cl \#, mu cr$,
|
2026-04-04 13:07:15 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 11:10:52 +00:00
|
|
|
|
name: [ new $bot$ value],
|
2026-04-04 13:07:15 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl bot, mu cr xarrowSquiggly(cl r\, w cr)_new cl bot, mu cr$,
|
2026-04-04 13:07:15 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 11:10:52 +00:00
|
|
|
|
name: [ new funciton pointer value],
|
2026-04-04 13:07:15 +00:00
|
|
|
|
|
2026-04-19 11:10:52 +00:00
|
|
|
|
$cl lambda overline(t) s, mu cr xarrowSquiggly(space)_new cl lambda overline(t) s, mu cr$,
|
2026-04-04 13:07:15 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 11:10:52 +00:00
|
|
|
|
name: [ new reference ref value],
|
2026-04-04 13:07:15 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
// TODO: FIXME: recursive copy ?? (what heppens if ref field has copy substructure ??)
|
|
|
|
|
|
// frbidden ??
|
|
|
|
|
|
|
|
|
|
|
|
$cl rf l, mu cr xarrowSquiggly(rf Ref t)_new cl rf l, mu cr$,
|
2026-04-04 13:07:15 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 11:10:52 +00:00
|
|
|
|
name: [ new reference copy value],
|
2026-04-04 13:07:15 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl mu[l], mu cr xarrowSquiggly(t)_new cl v, mu_v cr$,
|
2026-04-19 11:10:52 +00:00
|
|
|
|
|
|
|
|
|
|
$cl mu_v cr xarrowSquiggly(v)_#[add] cl l', mu_a cr$,
|
|
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl rf l, mu cr xarrowSquiggly(rf Copy t)_new cl rf l', mu_a cr$,
|
2026-04-04 13:07:15 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 11:10:52 +00:00
|
|
|
|
name: [ new tuple value],
|
2026-04-04 13:07:15 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl v_1, mu_0 cr xarrowSquiggly(t_1)_new cl lambda v'_1, mu_1 cr$,
|
2026-04-19 11:10:52 +00:00
|
|
|
|
$...$,
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl v_n, mu_(n - 1) cr xarrowSquiggly(t_n)_new cl lambda v'_n, mu_n cr$,
|
2026-04-19 11:10:52 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl [v_1, ... v_n], mu_0 cr xarrowSquiggly([t_1, ... t_n])_new cl [v'_1, ... v'_n], mu_n cr$,
|
2026-04-04 13:07:15 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
=== Value Update
|
|
|
|
|
|
|
2026-04-25 14:51:38 +00:00
|
|
|
|
#let modify = `modify`
|
2026-04-19 13:13:51 +00:00
|
|
|
|
|
2026-04-25 14:51:38 +00:00
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ modify trivial value],
|
|
|
|
|
|
|
|
|
|
|
|
$v in {0, \#, bot}$,
|
|
|
|
|
|
$cl v, mu cr xarrowSquiggly(cl \@ x \, b cr)_modify cl b, mu cr$,
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ new reference copy value],
|
|
|
|
|
|
|
|
|
|
|
|
$cl mu[l], mu cr xarrowSquiggly(cl p \, b cr)_modify cl v', mu' cr$,
|
|
|
|
|
|
$cl rf l, mu cr xarrowSquiggly(cl *p \, b cr)_modify cl rf l, mu'[l <- v'] cr$,
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ modify tuple value],
|
|
|
|
|
|
|
|
|
|
|
|
$v in {0, \#, bot}$,
|
|
|
|
|
|
$cl v_i, mu cr xarrowSquiggly(cl p \, b cr)_modify cl v'_i, mu', cr$,
|
|
|
|
|
|
$cl [v_1, ... v_i, ... v_n], mu cr xarrowSquiggly(cl p.i \, b cr)_modify cl [v_1, ... v'_i, ... v_n], mu' cr$,
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
=== Value Combination
|
|
|
|
|
|
|
|
|
|
|
|
#let combine = `combine`
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ combine trivial $0$ values],
|
|
|
|
|
|
|
|
|
|
|
|
$mu xarrowSquiggly(cl 0 \, 0 cr)_combine cl 0, mu cr$
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ combine trivial $bot$ values],
|
|
|
|
|
|
|
|
|
|
|
|
$mu xarrowSquiggly(cl bot \, bot cr)_combine cl bot, mu cr$
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ combine other trivial values],
|
|
|
|
|
|
|
|
|
|
|
|
$v_1 in {0, \#, bot}$,
|
|
|
|
|
|
$v_2 in {0, \#, bot}$,
|
|
|
|
|
|
$v_1 != v_2$,
|
|
|
|
|
|
$mu xarrowSquiggly(cl v_1 \, v_2 cr)_combine cl \#, mu cr$
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ combine lambda values],
|
|
|
|
|
|
|
|
|
|
|
|
$mu xarrowSquiggly(cl lambda \, lambda cr)_combine cl lambda, mu cr$
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: combine inplace, destroy values (actually only the first value)
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ combine reference values (inplace)],
|
|
|
|
|
|
|
|
|
|
|
|
$mu xarrowSquiggly(cl mu[l_1] \, mu[l_2] cr)_combine cl v', mu' cr$,
|
|
|
|
|
|
// NOTE: not inplace variant // TODO FIXME: choose variant
|
|
|
|
|
|
// $mu' xarrowSquiggly(v')_#[add] cl rf l', mu'' cr$,
|
|
|
|
|
|
// $mu xarrowSquiggly(cl rf l_1 \, rf l_2 cr)_combine cl rf l', mu'' cr$
|
|
|
|
|
|
$mu xarrowSquiggly(cl rf l_1 \, rf l_2 cr)_combine cl rf l_1, mu'[l_1 <- v'] cr$
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ combine tuple values],
|
|
|
|
|
|
|
|
|
|
|
|
$mu_0 xarrowSquiggly(cl v^1_1 \, v^2_1 cr)_combine cl v'_1, mu_1 cr$,
|
|
|
|
|
|
$...$,
|
|
|
|
|
|
$mu_(n - 1) xarrowSquiggly(cl v^1_n \, v^2_n cr)_combine cl v'_n, mu_n cr$,
|
|
|
|
|
|
$mu_0 xarrowSquiggly(cl [v^1_1, ... v^1_n] \, [v^2_1 ... v^2_n] cr)_combine cl [v'_1, ... v'_n], mu_n cr$
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
2026-04-19 13:13:51 +00:00
|
|
|
|
|
2026-04-04 13:07:15 +00:00
|
|
|
|
=== Call Finalization
|
|
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
// FIXME: make connected to syntax
|
|
|
|
|
|
*TODO*
|
|
|
|
|
|
|
2026-03-29 15:32:35 +00:00
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ spoil init],
|
|
|
|
|
|
$mu stretch(=>)^nothing_(cl sigma, mu cr) mu$,
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ spoil step],
|
|
|
|
|
|
|
|
|
|
|
|
$mu stretch(=>)^args_sigma gamma$,
|
|
|
|
|
|
|
2026-04-11 13:17:15 +00:00
|
|
|
|
$isPossibleWrite mode$, // NOTE: weak requirement: may write
|
|
|
|
|
|
$not isCopy mode$,
|
2026-04-25 13:45:24 +00:00
|
|
|
|
$mode = (\_, not Out)$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-11 13:17:15 +00:00
|
|
|
|
$isCorrect_(cl sigma, mu cr) (mode, x)$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
// gamma - memory (as mu)
|
2026-04-11 14:51:56 +00:00
|
|
|
|
$gamma stretch(=>)^((mode, x) : args)_sigma pathenvval(gamma, sigma, x) <- bot]$
|
2026-03-29 15:32:35 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ fix step],
|
|
|
|
|
|
|
|
|
|
|
|
$mu stretch(=>)^args_sigma gamma$,
|
|
|
|
|
|
|
2026-04-11 13:17:15 +00:00
|
|
|
|
$isAlwaysWrite mode$, // NOTE: strong requirement: should write
|
2026-04-25 13:45:24 +00:00
|
|
|
|
$mode = (\_, not Out)$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-11 13:17:15 +00:00
|
|
|
|
$isCorrect_(cl sigma, mu cr) (mode, x)$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
// gamma - memory (as mu)
|
2026-04-11 14:51:56 +00:00
|
|
|
|
$gamma stretch(=>)^((mode, x) : args)_sigma pathenvval(gamma, sigma, x) <- 0]$
|
2026-03-29 15:32:35 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [ skip step],
|
|
|
|
|
|
|
|
|
|
|
|
$mu stretch(=>)^args_sigma gamma$,
|
|
|
|
|
|
|
|
|
|
|
|
$not "spoil step"$,
|
|
|
|
|
|
$not "fix step"$,
|
|
|
|
|
|
|
2026-04-11 13:17:15 +00:00
|
|
|
|
$isCorrect_(cl sigma, mu cr) (mode, x)$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
// mu
|
2026-04-11 13:17:15 +00:00
|
|
|
|
$gamma stretch(=>)^((mode, x) : args)_sigma gamma$
|
2026-03-29 15:32:35 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
2026-04-04 13:07:15 +00:00
|
|
|
|
=== Function Evaluation
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
// FIXME: make connected to syntax
|
|
|
|
|
|
*TODO*
|
|
|
|
|
|
|
2026-03-29 15:32:35 +00:00
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-04 13:07:15 +00:00
|
|
|
|
name: [ $(lambda a : t. d) m$],
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-04 13:07:15 +00:00
|
|
|
|
// TODO: verify that type of m is t ??
|
|
|
|
|
|
|
|
|
|
|
|
$cl sigma [a <- (m, t)], mu, l cr
|
|
|
|
|
|
xarrowSquiggly(t)
|
|
|
|
|
|
cl sigma', mu', l' cr$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
$cl sigma', mu', l' cr
|
|
|
|
|
|
xarrowDashed(d space @ space overline(y))
|
|
|
|
|
|
cl sigma'', mu'', l'' cr$,
|
|
|
|
|
|
|
2026-04-11 13:17:15 +00:00
|
|
|
|
$isRead mode$,
|
|
|
|
|
|
$not isCopy mode$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
// NOTE: correctness checked in CALL f
|
|
|
|
|
|
|
|
|
|
|
|
$cl sigma, mu, l cr
|
|
|
|
|
|
xarrowDashed((lambda a. d) space @ space x space overline(y))
|
|
|
|
|
|
cl sigma'', mu'', l'' cr$,
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
|
|
|
|
|
name: [decl body],
|
|
|
|
|
|
|
|
|
|
|
|
$cl sigma, mu, l cr
|
|
|
|
|
|
attach(stretch(->)^overline(s), tr: *)
|
|
|
|
|
|
cl sigma', mu', l' cr$,
|
|
|
|
|
|
|
|
|
|
|
|
$d = overline(s)$,
|
|
|
|
|
|
|
|
|
|
|
|
$cl sigma, mu, l cr
|
|
|
|
|
|
xarrowDashed(d space @)
|
|
|
|
|
|
cl sigma', mu', l' cr$,
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
2026-04-04 13:07:15 +00:00
|
|
|
|
=== Statement Evaluation
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
// FIXME: make connected to syntax
|
|
|
|
|
|
*TODO: check type of lambda?, args from type?*
|
2026-03-29 15:32:35 +00:00
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ CALL $f space overline(p)$],
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
$cl [], mu, l cr
|
2026-04-19 13:13:51 +00:00
|
|
|
|
xarrowDashed(f space @ space overline(p))
|
2026-03-29 15:32:35 +00:00
|
|
|
|
cl sigma', mu', l' cr$,
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: FIXME define args in some way
|
|
|
|
|
|
$mu attach(stretch(=>)^args_sigma, tr: *) gamma$,
|
|
|
|
|
|
|
|
|
|
|
|
$cl sigma, mu, l cr
|
2026-04-19 13:13:51 +00:00
|
|
|
|
xarrow("CALL" f space overline(p))
|
2026-03-29 15:32:35 +00:00
|
|
|
|
cl sigma, gamma, l cr$,
|
|
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ READ $p$],
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$mu, types, vals teval p eqmu 0$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl types, vals, mu cr
|
2026-04-19 13:13:51 +00:00
|
|
|
|
xarrow("READ" p)
|
2026-04-25 13:43:12 +00:00
|
|
|
|
cl types, vals, mu cr$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ WRITE $x$],
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$types ttype p : cl r, w cr$,
|
|
|
|
|
|
$w = MaybeWrite or w = AlwaysWrite$,
|
|
|
|
|
|
$p arrpath x$,
|
2026-04-25 14:51:38 +00:00
|
|
|
|
$mu[x] xarrowSquiggly(p)_modify v'$,
|
2026-04-19 13:13:51 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl types, vals, mu cr
|
2026-04-19 13:13:51 +00:00
|
|
|
|
xarrow("WRITE" p)
|
2026-04-25 14:51:38 +00:00
|
|
|
|
cl types, vals, mu[x <- v'] cr$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
|
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ $s \; t$],
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl types, vals, mu cr
|
2026-04-19 13:13:51 +00:00
|
|
|
|
stretch(->)^s
|
2026-04-25 13:43:12 +00:00
|
|
|
|
cl types_s, vals_s, mu_s cr$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl types_s, vals_s, mu_s cr
|
2026-04-19 13:13:51 +00:00
|
|
|
|
stretch(->)^t
|
2026-04-25 13:43:12 +00:00
|
|
|
|
cl types_t, vals_t, mu_t cr$,
|
2026-04-19 13:13:51 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl types, vals, mu, cr
|
2026-04-19 13:13:51 +00:00
|
|
|
|
xarrow(s \; t)
|
2026-04-25 13:43:12 +00:00
|
|
|
|
cl types_t, vals_t, mu_t cr$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
#h(10pt)
|
|
|
|
|
|
|
2026-04-19 13:13:51 +00:00
|
|
|
|
*TODO: combine replacement* // FIXME
|
2026-03-29 15:32:35 +00:00
|
|
|
|
#align(center, prooftree(
|
|
|
|
|
|
vertical-spacing: 4pt,
|
|
|
|
|
|
rule(
|
2026-04-19 13:13:51 +00:00
|
|
|
|
name: [ $s | t$],
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl types, vals, mu cr
|
2026-04-19 13:13:51 +00:00
|
|
|
|
stretch(->)^s
|
2026-04-25 13:43:12 +00:00
|
|
|
|
cl types_s, vals_s, mu_s cr$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl types, vals, mu cr
|
2026-04-19 13:13:51 +00:00
|
|
|
|
stretch(->)^t
|
2026-04-25 13:43:12 +00:00
|
|
|
|
cl types_t, vals_t, mu_t cr$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$types_s = types_t$,
|
|
|
|
|
|
$vals_s = vals_t$,
|
2026-04-19 13:13:51 +00:00
|
|
|
|
$mu' = combine(mu_s, mu_t)$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
// TODO changes ?? two ways ??
|
2026-04-25 13:43:12 +00:00
|
|
|
|
$cl types, vals, mu cr
|
2026-04-19 13:13:51 +00:00
|
|
|
|
xarrow(s | t)
|
2026-04-25 13:43:12 +00:00
|
|
|
|
cl types_t, vals_t, mu' cr$,
|
2026-03-29 15:32:35 +00:00
|
|
|
|
)
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
]
|