Projectional Editing in Two Steps

1. Normal Form

I favour a normal form consisting of triples.

See https://guitarvydas.github.io/2021/03/16/Triples.html

2. Rules

You want to perform exhaustive search over all of the triples.

A rule is just a group of related searches.

Such searching can be done manually, using loops within loops.

Or, one could use a tool — a search engine — to do the searching. One such search engine is PROLOG. Another engine might be miniKanren.

PROLOG uses backtracking to perform exhaustive search.

PROLOG uses something called logic variables to hold the results of successful matches.

There might be more than one match that succeeds in satisfying all of the search constraints. In such cases, PROLOG re-binds the values of the logic variables and presents you, the programmer, with a set of consistent matches (as one set of bound logic variables).

MiniKanren, on the other hand, does not use the above method and keeps a running list of all possible matches, then presents you, the programmer, with a list of all matches that consistently solve the set of given match constraints.

Unification

PROLOG uses an algorithm, called unification, to re-bind logic variables.

One set of bindings describes one solution to all of the match constraints.

In essence, PROLOG clears its logic variables before calculating another solution. In essence, PROLOG memorizes previous solutions and does not present already-seen solutions again.

[Note, that this does not mean that duplicate solutions cannot be displayed — PROLOG remembers the route that it used to find a solution, if it finds a different route which results in the same set of bindings, PROLOG will be happy to show you that solution as a possibility (much to the chagrin of PROLOG newbies).]

Tools

I would suggest:

PEG

https://guitarvydas.github.io/2020/12/27/PEG.html

https://guitarvydas.github.io/2021/03/17/PEG-vs.-Other-Pattern-Matchers.html

https://guitarvydas.github.io/2021/03/19/Racket-PEG.html

https://guitarvydas.github.io/2021/03/24/REGEX-vs-PEG.html

https://guitarvydas.github.io/2020/12/09/OhmInSmallSteps.html

https://guitarvydas.github.io/2021/02/28/DSL-in-a-Day.html

Factbases

https://guitarvydas.github.io/2021/01/17/Factbases.html

https://guitarvydas.github.io/2021/03/02/Universal-Datatype.html

PROLOG

https://www.youtube.com/watch?v=QOYAHoLiyg0&t=3s