ishanpm / chemlambda-editor

Javascript implementation of Chemlambda
MIT License
3 stars 0 forks source link

Lambda calculus import/export #8

Open ishanpm opened 5 years ago

ishanpm commented 5 years ago

Adding a parser for lambda calculus expressions would make it easier to experiment with for people who aren't familiar with the Chemlambda nodes, or who don't feel like dealing with their specifics at the moment.

Attempting to show the lambda representation of a molecule which has none should fail in a non-obtrusive way.

mbuliga commented 5 years ago

Indeed. There are two different problems here:

1) add a parser from lambda calculus to mol. It should have also some choices, or parameter regarding the FO-trees (for example an option/parameter to choose from left-tree, right-tree, smallest-depth or random).

As you write, this would serve to input from lambda. It should be coupled with a useful form of export/save/add to library/post interesting mol.

2) the inverse problem, namely to add lambda calculus semantics to a mol, is of course not possible in general. But it is in particular cases and this is interesting. There are two reasons for this: (a) the graph not amenable to a DAG (b) how to translate FI and FOE to lambda?

A solution would be to add a translation back to lambda with equations. It all comes to decorate the half-edges (or the ports) with simple rules and to have one equation/edge. Then recursively, starting from FRIN and the port 2 of L, substitute in equations until an edge number (name) appears in both sides of an equation. If there is an unique FROUT, gives the output.

Without the recursive substitution, and with a mock LISP decoration for FI and FOE, that's what is shown in hapax prototype, in the "means" column" http://imar.ro/~mbuliga/ishanpm-example.html