wrote the main loops for bottom-up search
added generic generation of backwards rewrite rules