We denote
We denote
We denote
We denote
We denote
As such we have a pipeline of
Remembering that
Remembering that
Therefore we can simplify our notation by ignoring the intermerdiate representations
For a given
where
Suppose we want to mutate a document
where <div> after the third child of <body>."
The problem: we do not author documents directly. We author source code. The document is a derived artifact. So we need to find a corresponding source mutation:
such that applying
Or equivalently:
As a commuting diagram:
Reading it: "mutating the source then rendering = rendering then mutating the document."
We call
In general, lifting
We avoid both problems by restricting the allowed mutations. We require:
-
Every
$\delta$ is liftable:$\delta$ only produces documents in$\text{im}(f_\alpha)$ . -
Every
$\delta$ lifts uniquely: for each$\delta$ , there is exactly one$\sigma$ satisfying the commuting square.
In other words, we design our mutation sets
This is a strong constraint. It means the document mutations are "source-aware" — they carry enough structure to unambiguously determine a source edit.
We call the set of allowed source edits
- There is a "do nothing" operation. Applying it changes nothing.
- Any two operations can be chained into one. "Move node A" followed by "delete node B" is itself a single operation "move A then delete B."
-
Chaining is associative.
$(a \circ b) \circ c = a \circ (b \circ c)$ — grouping doesn't matter, only order.
Each operation in
For the mathematically inclined: a set with these three properties is called a monoid, and the way it transforms a space is called a monoid action.
Because of our design constraint, every document mutation
The critical property: lifting respects chaining. If you chain two document mutations and then lift, you get the same result as lifting each one and then chaining the source edits:
And lifting "do nothing" gives "do nothing":
For the mathematically inclined: this makes $\text{lift}\alpha$ a monoid homomorphism — a structure-preserving map between the two operation sets._
This gives us two properties for free:
- Composability: a sequence of document mutations lifts to a sequence of source edits. The order is preserved and the result is the same whether you compose then lift, or lift then compose.
-
Optimistic application: we can apply
$\delta$ to the document immediately and know that a deterministic$\sigma$ exists. The source edit can be computed asynchronously.
Since the mapping is 1:1, the two operation sets are structurally identical — they differ only in whether they speak in terms of documents or source code.