Below is a structured “reader’s guide” to the ICFP 2023 paper“The Verse Calculus (): A Core Calculus for Deterministic Functional‑Logic Programming.”I focus on (i) what the calculus is, (ii) why each design choice matters, (iii) how the metatheory is proved, and (iv) questions or forks in the road you may want to dig into next time we talk.
1 Positioning and contributions
['Claim in the paper', 'Why it matters']
['A higher‑order, deterministic functional‑logic core language', 'Previous FLP cores (Curry, TOY, λND, …) are usuallyfirst‑orderornondeterministic. VC aims at both higher‑order expressivenessandpredictable search order, which is crucial for real‑time game logic where every client must replay the same choices in lock‑step.Simon Peyton Jones']
['Small‑steprewritesemantics instead of big‑step or magical narrowing rules', 'Programmers can reason by “just applying rewrites,” exactly the selling point of the λ‑calculus; compiler optimisations can rely on confluence.Simon Peyton Jones']
['Confluence for “well‑behaved” terms', 'Gives you referential transparency even in the presence of unification and choice, provided each logic variable appears in at most one equation.Simon Peyton JonesSimon Peyton Jones']
2 The surface of at a glance
────────────────────────────────────────────────────────────────────
goCopy codee = v | v v | e₁ ⎵ e₂ | fail | one{e} | all{e}
v = x | k | op | ⟨v,…,v⟩ | λx.e
t = e | v = e -- “terms” include equations
p = one{e} -- a closed program extracts one result
Logical variables & equations.∃x. …introduces fresh logic variables;v = eunifies avaluewith an expression (only values on the left to preserve confluence).
Choicee₁ ⎵ e₂(“horizontal bar” in the PDF) concatenatesallresults ofe₁followed by those ofe₂, preserving order and duplicates.Simon Peyton Jones
Encapsulationone{e}– take the first value ofe, abandon the rest.all{e}– collect all values ofeinto a tuple so they can be processed functionally.oneisnotdefinable fromallwithout losing termination guarantees.Simon Peyton Jones
one{e}– take the first value ofe, abandon the rest.
all{e}– collect all values ofeinto a tuple so they can be processed functionally.oneisnotdefinable fromallwithout losing termination guarantees.Simon Peyton Jones
Failaborts the current branch but doesnotcancel sibling branches – enabling “negation‑as‑failure” idioms without killing the entire search.
Logical variables & equations.∃x. …introduces fresh logic variables;v = eunifies avaluewith an expression (only values on the left to preserve confluence).
Choicee₁ ⎵ e₂(“horizontal bar” in the PDF) concatenatesallresults ofe₁followed by those ofe₂, preserving order and duplicates.Simon Peyton Jones
Encapsulation
one{e}– take the first value ofe, abandon the rest.
all{e}– collect all values ofeinto a tuple so they can be processed functionally.oneisnotdefinable fromallwithout losing termination guarantees.Simon Peyton Jones
one{e}– take the first value ofe, abandon the rest.
all{e}– collect all values ofeinto a tuple so they can be processed functionally.oneisnotdefinable fromallwithout losing termination guarantees.Simon Peyton Jones
Failaborts the current branch but doesnotcancel sibling branches – enabling “negation‑as‑failure” idioms without killing the entire search.
3 Semantics by rewriting
3.1 Rule families (Figure 3 of the paper)
['Family', 'Intuition', 'Gotchas']
['β‑like rules(app‑beta,app‑tup)', 'Standard function/tuple application, but with explicit∃bindings so unification can turn outputs into inputs.', 'RHS of a β‑step issequencedafter the binding to keep scope correct.']
['Unification rules(subst,eqn‑elim,fail‑elim)', 'Move equations to canonical form and perform substitution only when the RHS is avalue.', 'Prevents “premature” substitution that would destroy sharing.']
['Existential float/swap(exi‑float,exi‑swap)', 'Hoist∃binders outwards to expose redexes; swap neighbouring∃binders to avoid capture.', 'These rules are purely structural but essential for confluence proofs.']
['Choice rules(hnf‑swap, etc.)', 'Ensure that choices bubble up so they interact cleanly withone/all.', 'Interaction with substitution is the tricky part.']
3.2 Lenient evaluation
VC islenient– everything outside λ‑bodies iseventuallyevaluated, but evaluation may proceed in any order until a rule’s pre‑condition is met. It is “between” call‑by‑value and call‑by‑need; crucially, it allows arguments to bepartiallyknown when a function is called, which keeps unification intuitive.Simon Peyton Jones
3.3 Confluence argument (Appendix C)
Label lambdas by de depth to forbid ill‑scoped reductions.
Show that each rule set is locally confluent (critical‑pair analysis).
Proveskew confluenceacross rule families, then compose via Newmann’s Lemma for terminating subsystems.
Finally restrict towell‑behaved terms(no variable appears in more than one equation) – this is enough for all typical programs yet sidesteps the well‑known “extra‑variable” problem.
Label lambdas by de depth to forbid ill‑scoped reductions.
Show that each rule set is locally confluent (critical‑pair analysis).
Proveskew confluenceacross rule families, then compose via Newmann’s Lemma for terminating subsystems.
Finally restrict towell‑behaved terms(no variable appears in more than one equation) – this is enough for all typical programs yet sidesteps the well‑known “extra‑variable” problem.
4 How differs from Curry, Prolog & friends
['Aspect', 'VC', ' / modern FLP', 'Pure Prolog']
['Higher‑order', 'Native(λ in the core)', 'Encoded via defunctionalisation', 'No']
['Search order', 'Deterministicleft‑to‑right', 'Nondeterministic (logic‑complete)', 'Depth‑first, non‑fair']
['Encapsulation', 'one,allbuilt‑in', 'Encapsulated search via external library', 'Cut, findall, setof']
['Semantics', 'Small‑step, confluent', 'Needed‑narrowing, non‑confluent', 'SLD resolution']
Determinism trades offcompletenessforpredictability– very attractive for distributed simulations (Epic’s Verse language) or UI code where you need reproducible behaviour.
5 Open questions & research forks
Typing.The calculus is untyped; adding a dependent or Datalog‑style type system is flagged as future work.
Fairness.Because left branches run before right ones, a left‑infinite branch can starve later solutions. How to add bounded search or breadth‑first strategies without losing confluence?
Effects & observability.VC as presented is pure. Integrating time, I/O or physicsevents(which Verse the language needs) requires effect‑typing or an operational layer on top.
Parallel implementation.Lenience suggests plenty of parallelism, but determinism must be preserved. Techniques from deterministic parallel λ‑calculi could carry over.
Tooling.Equational reasoning and proof automation (à la Liquid Haskell) could let developers verify search‑heavy game logic.
Typing.The calculus is untyped; adding a dependent or Datalog‑style type system is flagged as future work.
Fairness.Because left branches run before right ones, a left‑infinite branch can starve later solutions. How to add bounded search or breadth‑first strategies without losing confluence?
Effects & observability.VC as presented is pure. Integrating time, I/O or physicsevents(which Verse the language needs) requires effect‑typing or an operational layer on top.
Parallel implementation.Lenience suggests plenty of parallelism, but determinism must be preserved. Techniques from deterministic parallel λ‑calculi could carry over.
Tooling.Equational reasoning and proof automation (à la Liquid Haskell) could let developers verify search‑heavy game logic.
6 Talking points for our next discussion
Does deterministic search really buy us enough to justify giving up logical completeness?
Where in your product stack (game‑server, content‑authoring tools, AI scripting) wouldonevsallbe most valuable?
Could we embed atypedVC fragment in a larger dependently‑typed host (F* / Lean) to get lightweight verificationandexecution?
Strategies for mitigating unfairness – time‑slicing, fuel counters, or static analyses to detect diverging left branches.
Does deterministic search really buy us enough to justify giving up logical completeness?
Where in your product stack (game‑server, content‑authoring tools, AI scripting) wouldonevsallbe most valuable?
Could we embed atypedVC fragment in a larger dependently‑typed host (F* / Lean) to get lightweight verificationandexecution?
Strategies for mitigating unfairness – time‑slicing, fuel counters, or static analyses to detect diverging left branches.
Let me know which of these threads you want to pull on, or if we should walk through concrete reduction sequences to get a feel for the calculus in action.