machine_programmer.tex 6.15 KB
Newer Older
LiberIT's avatar
LiberIT committed
1 2
\chapter{Machine Programmer}

3
\begin{description}
LiberIT's avatar
LiberIT committed
4 5
  \item[recipe] is a function in computer programming jargon. 
  \item[holy recipe] is a pure functionin computer programming jargon.
6 7
\end{description}

8 9 10 11 12 13 14 15 16 17 18
\section{Oracle Based, or Active Synthesis}

The interactive version of evolutionary programming is where a user starts a
conversaion with the machine programmer.

First you would give a brief description about the purpose of this function, for
documentation, and helping yourself narrow it down a little.
Then you would make the function declaration with the input and output types,
perhaps with some contractual constraints on the range of valid inputs and
outputs. 

19 20 21 22 23 24
At this point the machine programmer can check it's inventory of known programs
to see if there are any matching programs, that have the same input/outputs, and
similar names and-or description. If it finds a small amount of them, can ask 
if you'd like to use one of them as a basis. 

After that user can give one or more input and output example and-or a logical 
25 26
description of what the output should be relative to the input. Can also offer
some suggestions for which functions may be helpful in accomplishing the task.
27 28

At which point the machine programmer will start evolving functions that meet
29 30 31 32 33 34 35 36 37 38 39
the specification and examples.  
If it is taking more than a few seconds user can start writing the program as
they think it should be. the functions they thought would be necessary would be
in comments, they can remove or add to them as necessary or uncomment them to
include them in the code.

If the user decides that will need to make a new support function in order to
achieve this task, then can save state of this development. and switch over to
developing the supporting function. 

If it evolves multiple programs that meet the
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
full specification, but deviate from each other within the valid range of
inputs.  
Then the machine programmer will ask which of them is prefered, or if neither
then by giving the appropriate output for that particular input. 

This process of refinement would occur until either the user is satisfied with
the program or all the evolved programs having matching input and output pairs. 

The machine programmer will then select one or more of the evolved programs to
the library, based on what optimization have been set.  For example, if
size-optimization is enabled, then the smallest would be added, if
speed-optimization is enabled then the fastest would be added,  if
fault-tolerance is enabled then two which call a maximally different set of
functions would be added. 

Got the idea from a book called "Program Synthesis" (2017), about a 4 hour read:
https://www.nowpublishers.com/article/Details/PGL-010

LiberIT's avatar
LiberIT committed
58
\section{Overview}
LiberIT's avatar
LiberIT committed
59 60
A human programmer writes a recipe template, recipe suggestions and 
either provides a working recipe or sample input and output data. 
LiberIT's avatar
LiberIT committed
61

LiberIT's avatar
LiberIT committed
62
An encoder encodes the recipe template and recipe suggestions into the
LiberIT's avatar
LiberIT committed
63 64
intermediate representation (IR).  

LiberIT's avatar
LiberIT committed
65 66
If the human programmer provides a working recipe, then the recipe profiler
takes the recipe template IR and working recipe and generates the sample 
LiberIT's avatar
LiberIT committed
67 68
input and output data. 

LiberIT's avatar
LiberIT committed
69
A population generator takes the recipe suggestions IR and input from
LiberIT's avatar
LiberIT committed
70 71 72 73 74 75 76 77 78 79 80 81
/dev/random to create the population IR.\@

The population compiler converts the population IR into kernel or ``.cl'' files,
one for each.

The population tester loads each population kernel, and streams the sample
inputs through them, checking outputs for correctness, and produces the
population fitness which includes fitness of all individuals. 

The champion selector takes the fitness ratings, and the population IR,
and outputs the champions.

LiberIT's avatar
LiberIT committed
82
The population mutator and recombiner takes the champions and recipe
LiberIT's avatar
LiberIT committed
83 84 85 86
suggestions, then generates a new population IR.\@

An output generator takes the champions and outputs the best ones to a file. 

87 88
\section{input specification}
The input specification consists of:
LiberIT's avatar
LiberIT committed
89

90
\begin{itemize}
LiberIT's avatar
LiberIT committed
91 92 93
  \item the slogan of the recipe, 
  \item description of the recipe,
  \item specification of the recipe,
94
\end{itemize}
LiberIT's avatar
LiberIT committed
95

96
\subsection{Constraint Specification}
LiberIT's avatar
LiberIT committed
97

98 99 100 101
The one implemented so far is one of the simplest, 
A form of constraint programing, commonly used in training contemporary AI\@.

\begin{itemize}
102
  \item the training sequence
LiberIT's avatar
LiberIT committed
103
  \item a list of recipes to work with.
104 105 106
\end{itemize}


LiberIT's avatar
LiberIT committed
107
\subsection{Specification example}
LiberIT's avatar
LiberIT committed
108
\begin{verbatim}
LiberIT's avatar
LiberIT committed
109
specification -top recipe slogan -acc begin -rea
110
training sequence -top begin -rea
LiberIT's avatar
LiberIT committed
111 112 113 114 115
-quoted letter.A.letter -quoted -acc input -con
-quoted letter.a.letter -quoted -acc produce -rea
zero -num -acc input -con
zero -num -acc produce -rea
-fin
LiberIT's avatar
LiberIT committed
116
recipe sequence -top begin -rea
LiberIT's avatar
LiberIT committed
117 118 119
plus -rea
subtract -rea
-fin
120
regulation sequence -top begin -rea
LiberIT's avatar
LiberIT committed
121
-quoted letter.A.letter -quoted -abl down -con
LiberIT's avatar
LiberIT committed
122
input -nom produce -acc copula -rea
LiberIT's avatar
LiberIT committed
123
-fin
LiberIT's avatar
LiberIT committed
124
\end{verbatim}
125 126 127

\section{Evolutionary programming}

LiberIT's avatar
LiberIT committed
128
multiple forms of evolution and optmial recipe discovery are used:
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146

\begin{itemize}
  \item random mutation (asexual reproduction)
  \item program inversion with backpropogation
  \item crossover (sexual reproduction)
  \item speciation
  \item neuro evolution
  \item specification generated tests
  \item adverserial coevolution
  \item neural networks 
\end{itemize}

A computer program is similar to a recurrent neural net. 

\section{Ceremony produce}

The produce of the evolutionary process contains the following items:
\begin{itemize}
LiberIT's avatar
LiberIT committed
147
  \item recipe slogan
148
  \item best tests generated if any
LiberIT's avatar
LiberIT committed
149 150
  \item health achieved and recipe metrics
  \item unique identifier based on universal hash of recipe definition.
151
  \item required imports
LiberIT's avatar
LiberIT committed
152
  \item recipe definition including declared internal variables.
153 154 155
\end{itemize}


LiberIT's avatar
LiberIT committed
156
The recipe produce is a named recipe, appended to the file that has the same
157 158
verb. If no such file exists then it is created. 

LiberIT's avatar
LiberIT committed
159
This way various over-ride recipes will all be in the same file. 
160 161 162

Automatic importing can happen by getting a list of all the verbs in the file
and importing them.  Though that could have a lot of problems, if there are name
LiberIT's avatar
LiberIT committed
163
collisions or there are different providers of recipes.
LiberIT's avatar
LiberIT committed
164 165 166 167 168 169

\subsection{produce example}

holy -top letter tiny -nom tiny letter -num -dat letter -num -acc begin -dec

metadata -top begin -rea
170

LiberIT's avatar
LiberIT committed
171 172
-fin

LiberIT's avatar
LiberIT committed
173
program recipe -deo
174

LiberIT's avatar
LiberIT committed
175
-fin