You can download the awk file
and play with chemlambda with the priority choice “viral”.
This priority choice privileges the moves which increase the number of nodes in favour of those which decrease it.
More concretely DIST>BETA>LOC-PR. It is one of the priority choices from the post When priority matters.
How to use it:
- a g-pattern (or molecule) is in file.mol, as a list of graphical elements (i.e. nodes with ports), but with the characters “[" "," and "]” replaced by spaces ” “. That means T[a] appears as “T a”, Arrow[a,b] appears as “Arrow a b” and L[a,b,c] appears as “L a b c”.
Look at data_8.mol , which is the file for the initial pattern from the post When priority matters. Here is also data_7.mol, which is the file containing the initial pattern from the post When priority does not matter.
- Download the check_and_balance_18_09.awk . Download one of the data_7.mol or data_8.mol, or create your own mol file.
- open a terminal (presuming you have linux, or mac with Xcode installed, I suppose) and type
awk -f check_and_balance.awk data_7.mol
to play with data_7.mol. Then type ls to find a number of files, each one starting with “temp_”.
The file temp_nodes_before is basically the same as the input file.
The file temp_proposed_moves has the proposed moves :) , before any priority choice and before any COMB moves.
The file temp_final_nodes has the result after one reduction step.
You may remark the apparition of new nodes, like
which is a “invisible” node which has only one port (in this case named “17”) which is an “out” port. It signals that port 17 is free (and it appears as a free “in” port, that is why FRIN, which caps it, has to have a paired “out” port).
which is a invisible node with only one port (named “0” in this case) which is a “in” port. For similar reasons as before, it signals that 0 is a free “out” port.
This may change slightly the aspect of g-patterns, in the only sense that arrow elements with both ends free are replaced by pairs FRIN and FROUT, for example if
Arrow[ 17 , 0 ]
has both ports free, you shall see it in the temp_final_nodes as
Otherwise the FRIN-FROUT thing helps the understanding, in the sense that it makes visible the free ports.
- if you want to go further with the reduction then type
awk -f check_and_balance.awk temp_final_nodes
and look again at
temp_nodes_before to see where you start in this reduction step
temp_proposed_moves to see the new moves proposed before any priority choice
temp_final_nodes to see the result.
And so on and so forth.
If you use data_7.mol or data_8.mol (or any g-pattern from this blog which is reduced by the “viral” priority choice) then you should see exactly what is described in the respective posts.
There is a small trick, namely that when DIST moves are done, the script has a way to choose new names for the new edges which appear. The trick is that first it computes the max over existing port names ( that is the variable “tutext”) and then it baptizes the new ports with tutext concatenated with “a”, tutext concatenated with “b”, with “c” and with “d”. This way one can be sure that the new ports don’t have names which conflict with the old ports.
I don’t have yet a visualizer for this, but work (mostly to understand) to use d3 for this.
UPDATE (20.09.2014): I can see my first molecule during reduction, basically using this and the json file produced by the script.
I can move and play with it but I have to control the colors, the ports, oriented edges. Soon.
Enjoy! Criticize! Contribute!