Reintent

Prior Arts

The ideas behind Reintent and how we bring them together.

More and more of what software does is decided by models. A model answers with probabilities, and software needs behaviour it can count on. For that gap, Reintent proposes a model of reactive intent programming, built around probabilistic choices and effect handlers.

An intent is a program that leaves choices open. Code supplies possibilities and priors, models supply judgments, and people make decisions. Reintent realizes that program into a concrete computation or structure, and a host executes it in its world. Feedback can change the choices or lead to a proposal to reprogram the intent.

We draw directly on React's rendering model, functional composition, and effect handlers. Probability distributions provide our model of choices. The connections below trace these foundations, the related work that helps explain our design, and the metaphors that make it easier to picture. Understanding Reintent describes the model itself.

Reactive programming

React is a direct inspiration for λ=I(C)\lambda = I(C): change the inputs, evaluate the program again, and update what the host presents. Components compose a description; the host acts on it. React sums this up as UI = f(state), and we say World = f(choices). React first defined render as a method of a class component, and a function component is f itself. An intent is f in the same way. It returns a realization λ, as a component returns an element tree, and the world changes when the host executes λ, as the UI follows when React commits. React's distinction between render and commit also informs Reintent's separation of evaluation from sending requests. A view can read a realization repeatedly; the intent dispatches its requests after the view commits.

Reintent makes probabilistic choices part of those inputs and allows the program itself to evolve through reviewed reprogramming. Its output can be a UI, a scene, or another computation for a host. Elliott and Hudak's Functional Reactive Animation develops reactivity through continuous-time behaviors and events. In Reintent, we organize reactivity around changes to choices and the resulting evaluations.

Recomputing only affected work is a design goal. Self-adjusting computation provides relevant background for dependency tracking and reuse. Our current implementation reuses evaluations of the whole program. Model judgments are associated with program versions, so a program change can trigger fresh judgments across its choices. Finer-grained reuse is a direction for further work.

Functional programming

Functional composition and the separation of computation from external interaction are direct influences. An intent describes what to compute and what to request. Model calls and people's responses happen outside that evaluation; their answers become inputs to a later one. Repeatability assumes the same program, choices, context, and handling policy. In TypeScript, authors maintain this purity by expressing time, randomness, and external changes as inputs to the computation.

The mathematical model of choices is the finite distribution monad: state(x) represents a point mass at x, and flatMap composes a distribution with a function returning another distribution. This lets one choice depend on the value of another. Wadler's work on monads provides background for this style of composition.

useChoose gives intent code a value in direct style. The surrounding handler determines how that value is supplied: for example, by applying a resolution policy or using a preview's hypothesis. The distribution algebra and the policy for realizing a program are separate concerns.

Algebraic effects

The separation between requesting an operation and interpreting it is central to Reintent. Algebraic effects and handlers provide the conceptual model: an operation asks for something, while a handler controls how computation proceeds. Pyro's effect handlers apply this structure to probabilistic programs: trace, replay, condition and do each reinterpret a model's sampling operations.

In Reintent, a choice's question and ask describe a request; reading it with useChoose reports that request. Within a subtree, <World> supplies a resolution policy (minMargin), hypothetical choices (as), enumeration (each), and what happens when a choice cannot settle (onUnresolved). The intent dispatches model requests and stores answers. The JSX components establish scopes and policies; the intent's model callbacks answer external requests. Together they connect the intent's operations to their interpretation.

We apply this idea to the operations of intent programming. Alternative continuations provide the conceptual account of possible paths; scoped evaluation and branch representations give them a concrete form in JavaScript. An effect in Reintent is a request made during intent evaluation, with its handling assigned to the surrounding scope or intent.

Multi-stage programming

Reintent computes in two stages. Realizing an intent under its choices produces λ. The host then executes λ, and the world changes. λ is a term the host interprets. Today it is a tree of host nodes, { kind, props, children }, and each host decides what a kind means. A tree like this can describe an interface, and it can also be the syntax of code, as an abstract syntax tree is. Multi-stage programming gives this structure a precise account. Taha and Sheard's MetaML, and MetaOCaml after it, let a program build code values for a later stage and then run them. Lisp's quote and eval carry the same idea in a simpler form.

The notation follows from this. In the λ-calculus, λ is the binder of an abstraction. We use it for the whole term, because a realization is itself a computation that remains to be evaluated.

Partial evaluation is the closest reading. A partial realizer specializes a program on the inputs known now and leaves a residual program for the inputs that arrive later. Choices are the inputs known now. The intent, specialized on them, leaves λ as its residual. A choice that stays open under fork leaves a branch point in λ, the way a dynamic input stays in a residual program, so λ remains deterministic.

Code can enter λ in two ways. A model can write source text through useGenerate, and a node carries it to the host as data. Host nodes can also form a small language, with kinds for a call, a sequence or a condition, which the host interprets. In the second form the structure of the code stays visible to Reintent, so choices and branch points can sit inside it, as code values do in MetaOCaml. The first form corresponds to eval on a string.

We name the two stages apart. Reintent realizes an intent, and the host executes λ. Requests to models and people arise in the first stage, and their answers lead to a new realization. Changes to the world arise in the second stage, when the host executes λ.

Probabilistic programming

Reintent shares distributions, conditional dependencies, and exploration of alternative executions with probabilistic programming. The field has a substantial semantic foundation: programs describe probability models, and inference computes properties of those models. Gordon et al.'s overview is a useful starting point. The field includes several ways to express these models. For example, Stan's distribution statements contribute to a density description, which its inference algorithms use.

Our focus is using distributions to produce a concrete realization while allowing a person to intervene, withdraw a decision, or request a reprogramming. The default resolution policy uses a margin between leading candidates, with a fallback policy while a choice remains open. Probability modeling and resolution policy together support this ongoing interaction.

Gen's addressed choices and execution traces are a useful comparison for stable choice identities and records of what an evaluation read. A Gen choice map records addresses and chosen values. In Reintent, Choices<T> names a distribution. In these docs, “choice” can also name the persistent question to which judgments and decisions belong. The possibilities, their distribution, a human decision, and the value used in one evaluation are distinct.

Weights express a model's judgment about the question it was asked, and preferences can reweight the effective distribution. Their statistical interpretation depends on the model and its calibration; Bayesian posterior inference and expected-utility calculations bring their own modeling assumptions. We distinguish the model's belief, the person's decision, and the resolution used by the computation. A person's decision acts as an intervention in Pearl's sense. Its causes retain their values, and dependent choices are recomputed from the new value. Pyro's do handler performs the same operation on a probabilistic program.

Quantum computing and collapse

Quantum computing offers a useful conceptual image: distinguish a state that carries possibilities from the concrete outcome of a measurement. The account of quantum states and measurement makes that distinction vivid. For Reintent, the attraction is keeping unresolved possibilities explicit in the program and delaying their resolution until a concrete value is needed.

“Collapse” names this passage from possibilities to a value used in one realization. A card can carry several possible tones; a resolution policy supplies one so that the greeting can be computed. The same intent can be realized under another choice, and previews let people compare those alternatives before deciding. The metaphor helps separate what could be from what this computation uses.

We use this conceptual image with classical probability distributions. Quantum theory describes amplitudes and measurement; Reintent describes weighted candidates and resolution policies. People can revisit a choice because the intent retains the underlying judgments. This gives the image a practical role in an application: possibilities remain available as people explore, decide, and change their minds.

System One and System Two

The two model roles take their names from Daniel Kahneman's Thinking, Fast and Slow, where System 1 is fast and intuitive and System 2 is slow and deliberate. In Reintent they name what a model is asked to do. One model can work in both ways.

System One weighs the possibilities a program lists. TypeSafe's System One models are built for this kind of question. The possible outputs are defined ahead of time, and the model returns a typed value with calibrated probabilities in one fast query. A judgment in Reintent has the same shape: a question, the possibilities in KK, and weights kept as a belief.

System Two reasons in several steps before it answers. Reasoning models such as OpenAI's o1 and DeepSeek-R1 spend more computation on a chain of thought. Reintent gives System Two the work that needs it: writing values the program has not listed, and proposing a new program for a person to review.

“Intents”

“Intent programming” has a rich history. Charles Simonyi's Intentional Programming represents programs through extensible abstractions whose presentation and implementation can evolve. We share this concern for preserving meaning across changes. Reintent approaches it through stable choice identities, retained decisions, and reviewed program versions.

The term also connects to intent adaptation. Intent-driven programming in FAST combines a program with an intent specification that guides intent adaptation, including resource use and accuracy. FAST gives a concrete account of intent as a guide to adaptation. These historical and conceptual connections help place our choice-and-realization model within a broader exploration of intent in programming.

Reintent proposes a model of reactive intent programming. Here an intent is an executable program with open choices. A natural-language goal can guide its creation and evolution. Realizing it produces λ, the concrete computation or structure that the host then executes in its world. The expression λ=I(C)\lambda = I(C) abbreviates a realization with the surrounding context and handlers in place.

We treat the relationship between a person's goal and the program expressing it as an ongoing conversation. People assess how a proposed reprogramming serves their goal and authorize it through review. Explicit choices, decisions, and program versions give that conversation a durable computational form.

Last updated on

Edit on GitHub