Programs and their semantics (docs/roleflow.tex, sec:prog) #
A program has a weight context wts (Θ), an input context ins (I), output sorts outs (O),
a list of lines ys = op(args) and the returned positions ret. Variables are named by their
position: weights, then inputs, then the results of each line in order. The body
let ys = o(xs) in e of the design is the list of lines followed by ret.
Well-formedness (Prog.WF, decidable) asks that every argument is in scope with the sort its
operation expects and that the returned variables have the output sorts. The trace semantics
extends the value of the context line by line (trace); the semantics Prog.sem picks the
returned positions of the final trace, and Prog.logw sums the log-weights of the lines whose
role is spine. All three are measurable jointly in the weights and the inputs.
The role of a line: a spine step or a conditioner.
Instances For
Equations
- RoleFlow.instReprRole.repr RoleFlow.Role.spine prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "RoleFlow.Role.spine")).group prec✝
- RoleFlow.instReprRole.repr RoleFlow.Role.cond prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "RoleFlow.Role.cond")).group prec✝
Instances For
Equations
- RoleFlow.instReprRole = { reprPrec := RoleFlow.instReprRole.repr }
The context after some lines.
Equations
- RoleFlow.ctxAfter x✝ [] = x✝
- RoleFlow.ctxAfter x✝ (l :: ls) = RoleFlow.ctxAfter (x✝ ++ l.bs) ls
Instances For
Every line's arguments are in scope, with the sorts its operation expects.
Equations
- RoleFlow.LinesWF x✝ [] = True
- RoleFlow.LinesWF x✝ (l :: ls) = (RoleFlow.Args x✝ l.args l.as ∧ RoleFlow.LinesWF (x✝ ++ l.bs) ls)
Instances For
Equations
- RoleFlow.decLinesWF x✝ [] = isTrue ⋯
- RoleFlow.decLinesWF x✝ (l :: ls) = RoleFlow.decLinesWF._aux_2 x✝ l ls (RoleFlow.decLinesWF (x✝ ++ l.bs) ls)
Trace semantics #
The trace: run the lines from a value of the context they start in.
Equations
- RoleFlow.trace M [] x_5 x_1 = x_1
- RoleFlow.trace M (l :: ls) h x_1 = RoleFlow.trace M ls ⋯ (RoleFlow.stepLine M l ⋯ x_1)
Instances For
The log-weight of the lines with role spine, from a value of the context they start in.
Missing roles count as conditioners.
Equations
- RoleFlow.logwLines M [] x_6 x_1 x_2 = 0
- RoleFlow.logwLines M (head :: tail) x_6 [] x_1 = 0
- RoleFlow.logwLines M (l :: ls) h (r :: ρ) x_1 = (if r = RoleFlow.Role.spine then M.ℓ l.op (x_1.pick l.args ⋯) else 0) + RoleFlow.logwLines M ls ⋯ ρ (RoleFlow.stepLine M l ⋯ x_1)
Instances For
L_θ(x): the sum of the log-weights of the spine steps under the roles ρ.
Equations
- RoleFlow.Prog.logw M P h ρ θ x = RoleFlow.logwLines M P.lines ⋯ ρ (θ.append x)