r/ProgrammingLanguages • u/Physical_Aside_9343 • Jun 14 '26
Can a transformation pattern be inferred from example input/output pairs?
I'm exploring a problem that feels related to program synthesis, grammar inference, or programming-by-example, and I'm trying to understand where it belongs conceptually.
Suppose we are given only example pairs:
Input A → Output B
For example:
A:
{'name':'John','email':'john@email'}
B:
insert into users (name,email)
values ('John','john@email');
The specific example is not important. It could be arbitrary strings.
The interesting part is this:
Given enough example pairs (A₁→B₁, A₂→B₂, ...), are there known approaches that attempt to infer a reusable transformation rule automatically?
I am not necessarily interested in understanding the semantic meaning of the strings ("user", "email", SQL, etc.). I'm more interested in learning the transformation structure itself.
Some areas I have already looked at:
- Program Synthesis
- Programming by Example (PBE)
- Grammar Inference
- Regex / Pattern Generation
Are there other research areas, papers, tools, or algorithms that tackle this kind of problem?
I'm mainly trying to understand the landscape rather than looking for a specific implementation.
Thanks!
10
u/Gnaxe Jun 14 '26
Yes. Programs in logic languages like Prolog don't distinguish inputs from outputs, so they can be run in reverse. That means an interpreter written in Prolog could be run in reverse on outputs in order to generate programs that produce said outputs. There's always going to be infinite answers as you can keep making the program more complex without changing what it does, but simpler programs tend to be found earlier in the search order.
1
u/Physical_Aside_9343 Jun 18 '26
Thanks to everyone. 😄 I will come back with the next question. 😛
7
u/Ok-Watercress-9624 Jun 14 '26
That is kinda the definition of machine learning
3
u/sciolizer Jun 15 '26
Microsoft flash fill is a great case study in combining program synthesis and neural networks to solve exactly this kind of problem:
https://www.microsoft.com/en-us/research/publication/automating-string-processing-spreadsheets-using-input-output-examples/
1
u/Physical_Aside_9343 Jun 15 '26
THANKS TO YOU. Thanks to everyone. This is, what I need. Some infos. On StackOverflow I get blocked everytime for these kind of questions.
😘
2
u/Pzzlrr Jun 15 '26
You may be interested in Inductive Logic Programming.
2
u/steve_anunknown Jun 16 '26
You may also be interested in model learning, not to be confused with machine learning. You can search for model learning or (active / passive) automata learning as keywords.
1
u/Mickenfox Jun 14 '26
Well I haven't read it, but there is a 1993 book titled Watch What I Do: Programming by Demonstration
1
u/SnooGoats8463 Jun 15 '26
https://en.wikipedia.org/wiki/Solomonoff%27s_theory_of_inductive_inference