structures: grammar fixes

This commit is contained in:
ProgramSnail 2026-04-28 11:17:15 +00:00
parent 4eb3dea966
commit 967d213f54

View file

@ -73,7 +73,7 @@
Prod( Prod(
`mode`, `mode`,
{ {
Or[$inTag space outTag$][] Or[$inTag outTag$][]
} }
), ),
Prod( Prod(
@ -112,7 +112,7 @@
{ {
Or[$()$][value of simple type] // `Unit` Or[$()$][value of simple type] // `Unit`
Or[$path$][value from variable] // `Path` Or[$path$][value from variable] // `Path`
// TODO: FIXME: decide what is the result of ref expr eval // TODO: decide what is the result of ref expr eval
// Or[$rf expr$][reference expr] // `Ref` // Or[$rf expr$][reference expr] // `Ref`
Or[$[expr+]$][tuple expr] // `Prod` Or[$[expr+]$][tuple expr] // `Prod`
} }
@ -225,9 +225,6 @@ $sigma : envt := X -> type, space types : envt$ - #[ типы значений
// $d in decl, $ // $d in decl, $
$s in stmt, f in X, x in X, a in X$ $s in stmt, f in X, x in X, a in X$
// FIXME ??
// $d space @ space overline(x)$ - запись применения функции (вида #decl) к аргументам
=== Path Accessors === Path Accessors
Набор частично определённых фунций для работы с путями. Набор частично определённых фунций для работы с путями.
@ -373,85 +370,61 @@ $s in stmt, f in X, x in X, a in X$
// TODO: introduce spep env argument ?? // TODO: introduce spep env argument ??
=== Moded Type Correctness // --- >>> ---
// === Moded Type Correctness
*NOTE: скорее всего не нужна в таком виде, перенесено в spoil* // *NOTE: скорее всего не нужна в таком виде, перенесено в spoil*
// #let tcorrect = $attach(tack.r, br: #[correct])$
#let tcorrect = $attach(tack.r, br: #[correct])$ // $ vals in envv, types in envt, space mu in mem, space m in mode,
// space c in copyTag, space r, r' in readTag, space w, w' in writeTag,
// TODO: FIXME: well formatness for mode, extract // space v in value, space t, t' in type $
// TODO: FIXME: check for mode, is recursion required ?? // #h(10pt)
// TODO: FIXME: check mode & access corectness in os correct // // TODO: FIXME: complete rule check
// // + add part about ref -> not copy later
$ vals in envv, types in envt, space mu in mem, space m in mode, // #align(center, prooftree(
space c in copyTag, space r, r' in readTag, space w, w' in writeTag, // vertical-spacing: 4pt,
space v in value, space t, t' in type $ // rule(
// name: [ unit assignment tags correctness],
#h(10pt) // $r = Read => m = (In, \_)$,
// $m = (\_, Out) => w = AlwaysWrite$,
// TODO: FIXME: complete rule check // // $sigma temode x -> cr r' space w' cl$, // NOTE: not required, value passed
// + add part about ref -> not copy later // $(w = AlwaysWrite or w = MaybeWrite) and (m = (\_, Out) or c = Ref) => w' = AlwaysWrite$,
#align(center, prooftree( // // $sigma, mu teval x eqmu v$, // NOTE: not required, value passed
vertical-spacing: 4pt, // $v in {0, \#, bot}$,
rule( // $r = Read => v = 0$,
name: [ unit assignment tags correctness], // $types, vals, mu, m, c tcorrect v : cl r', w' cr -> cl r, w cr$,
// )
$r = Read => m = (In, \_)$, // ))
$m = (\_, Out) => w = AlwaysWrite$, // #h(10pt)
// $sigma temode x -> cr r' space w' cl$, // NOTE: not required, value passed // #align(center, prooftree(
$(w = AlwaysWrite or w = MaybeWrite) and (m = (\_, Out) or c = Ref) => w' = AlwaysWrite$, // vertical-spacing: 4pt,
// rule(
// $sigma, mu teval x eqmu v$, // NOTE: not required, value passed // name: [ function pointer tags correctness],
$v in {0, \#, bot}$, // $types, vals, mu, m, c tcorrect lambda : lambda space overline(t) -> lambda space overline(t)$,
$r = Read => v = 0$, // )
// ))
$types, vals, mu, m, c tcorrect v : cl r', w' cr -> cl r, w cr$, // #h(10pt)
) // #align(center, prooftree(
)) // vertical-spacing: 4pt,
// rule(
#h(10pt) // name: [ ref assignment tags correctness],
// $types, vals, mu, m, c_r tcorrect v : t -> t'$,
#align(center, prooftree( // // TODO: FIXME: which tag translations are correct ?? <- only assignee?
vertical-spacing: 4pt, // $types, vals, mu, m, c tcorrect rf space v : rf c' space t -> rf c_r space t'$,
rule( // )
name: [ function pointer tags correctness], // ))
// #h(10pt)
$types, vals, mu, m, c tcorrect lambda : lambda space overline(t) -> lambda space overline(t)$, // #align(center, prooftree(
) // vertical-spacing: 4pt,
)) // rule(
// name: [ tuple assignmenttags correctness],
#h(10pt) // $types, vals, mu, m, c tcorrect v_1 : t_1 -> t'_1$,
// $...$,
#align(center, prooftree( // $types, vals, mu, m, c tcorrect v_n : t_n -> t'_n$,
vertical-spacing: 4pt, // $types, vals, mu, m, c tcorrect [v_1, ... v_n] : [t_1, ..., t_n] -> [t'_1, ... t'_n]$,
rule( // )
name: [ ref assignment tags correctness], // ))
// #h(10pt)
$types, vals, mu, m, c_r tcorrect v : t -> t'$, // --- <<< ---
// 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'$,
)
))
#h(10pt)
#align(center, prooftree(
vertical-spacing: 4pt,
rule(
name: [ tuple assignmenttags correctness],
$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]$,
)
))
#h(10pt)
=== Value Construction === Value Construction
@ -475,7 +448,7 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
name: [ new trivial $not$ read value], name: [ new trivial $not$ read value],
$v in {0, \#, bot}$, $v in {0, \#, bot}$,
$cl v, mu cr xarrowSquiggly(cl Read \, w cr)_new cl bot, mu cr$, $cl v, mu cr xarrowSquiggly(cl not Read \, w cr)_new cl bot, mu cr$,
) )
)) ))
@ -484,7 +457,7 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
rule( rule(
name: [ new funciton pointer value], name: [ new funciton pointer value],
$cl lambda overline(t) s, mu cr xarrowSquiggly(space)_new cl lambda overline(t) s, mu cr$, $cl lambda overline(t) s, mu cr xarrowSquiggly(lambda space c space overline(t))_new cl lambda overline(t) s, mu cr$,
) )
)) ))
@ -494,7 +467,7 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
name: [ new reference ref value], name: [ new reference ref value],
// TODO: FIXME: recursive copy ?? (what heppens if ref field has copy substructure ??) // TODO: FIXME: recursive copy ?? (what heppens if ref field has copy substructure ??)
// frbidden ?? // <- forbidden ??
$cl rf l, mu cr xarrowSquiggly(rf Ref t)_new cl rf l, mu cr$, $cl rf l, mu cr xarrowSquiggly(rf Ref t)_new cl rf l, mu cr$,
) )
@ -579,14 +552,15 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
=== Value Combination === Value Combination
#let combine = `combine`
#align(center, prooftree( #align(center, prooftree(
vertical-spacing: 4pt, vertical-spacing: 4pt,
rule( rule(
name: [ combine trivial $0$ values], name: [ combine same trivial values],
$cl mu_1, mu_2, mu cr xarrowSquiggly(cl 0 \, 0 cr)_combine cl 0, mu cr$ $v_1 in {0, \#, bot}$,
$v_2 in {0, \#, bot}$,
$v_1 = v_2$,
$v_1 plus.o v_2 = v_1$
) )
)) ))
@ -595,23 +569,12 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
#align(center, prooftree( #align(center, prooftree(
vertical-spacing: 4pt, vertical-spacing: 4pt,
rule( rule(
name: [ combine trivial $bot$ values], name: [ combine different trivial values],
$cl mu_1, mu_2, mu cr 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_1 in {0, \#, bot}$,
$v_2 in {0, \#, bot}$, $v_2 in {0, \#, bot}$,
$v_1 != v_2$, $v_1 != v_2$,
$cl mu_1, mu_2, mu cr xarrowSquiggly(cl v_1 \, v_2 cr)_combine cl \#, mu cr$ $v_1 plus.o v_2 = \#$
) )
)) ))
@ -622,7 +585,7 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
rule( rule(
name: [ combine lambda values], name: [ combine lambda values],
$cl mu_1, mu_2, mu cr xarrowSquiggly(cl lambda \, lambda cr)_combine cl lambda, mu cr$ $lambda plus.o lambda = lambda$
) )
)) ))
@ -640,7 +603,7 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
// NOTE: version to use with "combine all" // NOTE: version to use with "combine all"
$l_1 = l_2$, $l_1 = l_2$,
$cl mu_1, mu_2, mu cr xarrowSquiggly(cl rf l_1 \, rf l_2 cr)_combine cl rf l_1, mu cr$ $rf l_1 plus.o rf l_2 = rf l_1$
) )
)) ))
@ -651,28 +614,23 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
rule( rule(
name: [ combine tuple values], name: [ combine tuple values],
$cl mu_1, mu_2, mu'_0 cr xarrowSquiggly(cl v^1_1 \, v^2_1 cr)_combine cl v'_1, mu'_1 cr$, $v^1_1 plus.o v^2_1 = v'_1$,
$...$, $...$,
$cl mu_1, mu_2, mu'_(n - 1) cr xarrowSquiggly(cl v^1_n \, v^2_n cr)_combine cl v'_n, mu'_n cr$, $v^1_n plus.o v^2_n = v'_n$,
$cl mu_1, mu_2, mu'_0 cr xarrowSquiggly(cl [v^1_1, ... v^1_n] \, [v^2_1 ... v^2_n] cr)_combine cl [v'_1, ... v'_n], mu'_n cr$ $[v^1_1, ... v^1_n] plus.o [v^2_1 ... v^2_n] = [v'_1, ... v'_n]$
) )
)) ))
#let dom = `dom`
#align(center, prooftree( #align(center, prooftree(
vertical-spacing: 4pt, vertical-spacing: 4pt,
rule( rule(
name: [ combine tuple values], name: [ combine memory],
$mu'_0 = []$, $dom mu_1 = dom mu_2$,
// NOTE: same labels required
$mu_1 = {l_1 -> v^1_1, ... l_n -> v^1_n}$,
$mu_2 = {l_1 -> v^2_1, ... l_n -> v^2_n}$,
$cl mu_1, mu_2, mu'_0 cr xarrowSquiggly(cl v^1_1 \, v^2_1 cr)_combine cl v'_1, mu'_1 cr$, $mu_1 plus.o mu_2 = l -> mu_1[l] plus.o mu_2[l]$
$...$,
$cl mu_1, mu_2, mu'_(n - 1) cr xarrowSquiggly(cl v^1_n \, v^2_n cr)_combine cl v'_n, mu'_n cr$,
$cl mu_1, mu_2 cr xarrowSquiggly(space)_#[combine all] mu'_n cr$
) )
)) ))
@ -920,8 +878,9 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
$vals, mu tval p eqmu v$, $vals, mu tval p eqmu v$,
$types ttype p : t'$, $types ttype p : t'$,
// TODO: FIXME: check type compatibility for t and type for path p (?) // TODO: check type compatibility for t and type for path p (?)
[*TODO: check t ~ t' in sme way (?)*], // [*TODO: check t ~ t' in sme way (?)*],
// <- programs considired to be well-typed
$cl v', mu cr xarrowSquiggly(t)_new cl v, mu' cr$, $cl v', mu cr xarrowSquiggly(t)_new cl v, mu' cr$,
@ -1047,7 +1006,7 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
$types_s = types_t$, $types_s = types_t$,
$vals_s = vals_t$, $vals_s = vals_t$,
$cl mu_s, mu_t cr xarrowSquiggly(space)_#[combine all] mu'$, $mu_s plus.o mu_t = mu'$,
// TODO changes ?? two ways ?? // TODO changes ?? two ways ??
$cl types, vals, mu cr $cl types, vals, mu cr