avida-ed-library-build/docs/documentation/Hand-written-Logic-Nine-Pro...

14 KiB

These programs were written as supplementary material for The Evolutionary Origin of Complex Features from 2003: http://myxo.css.msu.edu/papers/nature2003/. Here are programs that will trigger the nine default logic tasks with the default instruction set.

<html><head></head>

The following hand-written programs perform the various one- and two-input logic operations. These programs appear to be the shortest ones to perform these operations that do not depend on the initial content of stacks and registers (whose initial contents are represented by a '?' below). However, it has not been proven that these are the shortest programs. None of these programs permit self-replication; rather, they merely perform a calculation.



ECHO
#Inst AX BX CX Stack Output
1IO ? X ? ? ?
2IO ? Y ? ? X
 
NOT
#Inst AX BX CX Stack Output
1IO ? X ? ? ?
2push ? X ? X, ?  
3pop ? X X ?  
4nop-C  
5nand ? ~X X ?  
6IO ? Y X ? ~X
 
NAND
#Inst AX BX CX Stack Output
1IO ? X ? ? ?
2IO ? X Y ? ?
3nop-C  
4nand ? X nand Y Y ?  
5IO ? Z Y ? X nand Y
 
OR_N
#Inst AX BX CX Stack Output
1IO ? X ? ? ?
2IO ? X Y ? ?
3nop-C  
4nand ? X nand Y Y ?  
5nand ? X or ~Y Y ?  
6IO ? Z Y ? X or ~Y
 
AND
#Inst AX BX CX Stack Output
1IO ? X ? ? ?
2IO ? X Y ? ?
3nop-C  
4nand ? X nand Y Y ?  
5push ? X nand Y Y X nand Y, ?  
6pop ? X nand Y X nand Y ?  
7nop-C  
8nand ? X and Y X nand Y ?  
9IO ? Z X nand Y ? X and Y
 
OR
#Inst AX BX CX Stack Output
1IO ? X ? ? ?
2push ? X ? X, ?  
3pop ? X X ?  
4nop-C  
5nand ~X X X ?  
6nop-A  
7IO ~X Y X ? X
8push ~X Y X Y, ?  
9pop ~X Y Y ?  
10nop-C  
11nand ~X ~Y Y ?  
12swap Y ~Y ~X ?  
13nop-C  
14nand Y X or Y ~X ?  
15IO Y Z ~X ? X or Y
 
AND_N
#Inst AX BX CX Stack Output
1IO ? X ? ? ?
2IO ? X Y ? ?
3nop-C  
4nand ? X nand Y Y ?  
5nand ? X or ~Y Y ?  
6push ~X X or ~Y Y ~X or Y, ?  
7pop ~X X or ~Y X or ~Y ?  
8nop-C  
9nand ? ~X and Y X or ~Y ?  
10IO ? Z X or ~Y ? ~X and Y
 
NOR
#Inst AX BX CX Stack Output
1IO ? X ? ? ?
2push ? X ? X, ?  
3pop ? X X ?  
4nop-C  
5nand ~X X X ?  
6nop-A  
7IO ~X Y X ? X
8push ~X Y X Y, ?  
9pop ~X Y Y ?  
10nop-C  
11nand ~X ~Y Y ?  
12swap Y ~Y ~X ?  
13nop-C  
14nand Y X or Y ~X ?  
15push Y X or Y X X or Y, ?  
16pop Y X or Y X or Y ?  
17nop-C  
18nand Y X nor Y X or Y ?  
19IO Y Z X or Y ? X nor Y
 
XOR
#Inst AX BX CX Stack Output
1IO ? X ? ? ?
2IO ? X Y ? ?
3nop-C 
4push ? X Y X, ?  
5nand ? X nand YY X, ?  
6swap ? Y X nand YX, ?  
7nand ? X or ~Y X nand YX, ?  
8swap X or ~Y ? X nand YX, ?  
9nop-A 
10pop X or ~Y X X nand Y?  
11nand X or ~Y Y or ~X X nand Y?  
12swap X nand YY or ~X X or ~Y ?  
13nop-C 
14nand X nand YX xor Y X or ~Y ?  
15IO X nand YZ X or ~Y ? X xor Y
 
EQU
#Inst AX BX CX Stack Output
1IO ? X ? ? ?
2IO ? X Y ? ?
3nop-C 
4push ? X Y X, ?  
5nand ? X nand YY X, ?  
6swap ? Y X nand YX, ?  
7nand ? X or ~Y X nand YX, ?  
8swap X or ~Y ? X nand YX, ?  
9nop-A 
10pop X or ~Y X X nand Y?  
11nand X or ~Y Y or ~X X nand Y?  
12swap X nand YY or ~X X or ~Y ?  
13nop-C 
14nand X nand YX xor Y X or ~Y ?  
15push X nand YX xor Y X or ~Y X xor Y, ? 
16pop X nand YX xor Y X xor Y ?  
17nop-C 
18nand X nand YX equ Y X xor Y ?  
19IO X nand YZ X xor Y ? X equ Y
</html>