What program will derive the underlying algorithm in these question-answer pairs (updated)? - Computer Science Stack Exchange most recent 30 from cs.stackexchange.com 2019-09-18T14:43:26Z https://cs.stackexchange.com/feeds/question/19663 https://creativecommons.org/licenses/by-sa/4.0/rdf https://cs.stackexchange.com/q/19663 -1 What program will derive the underlying algorithm in these question-answer pairs (updated)? Calvin https://cs.stackexchange.com/users/12742 2014-01-12T04:09:23Z 2014-01-14T22:27:00Z <p>Given this set of question-answer pairs, what program will derive the underlying algorithm and provide the correct answer for any question of the same format.</p> <p><strong>Question-Answer Pairs (training set):</strong></p> <pre><code>B:BA BA:BB BB:BAA BAA:BAB BAB:BBA BBA:BBB BBB:BAAA BAAA:BAAB BAAB:BABA </code></pre> <p>Those familiar with binary may notice that the training set is binary numbers with A and B substituted for 0 and 1. The answer to each question is the next binary number (using A and B). </p> <p>After processing the training set, the program should be able to answer questions such as the following using the algorithm it derived:</p> <pre><code>BABA:? BABB:? BBBBAAA:? BAABBAAABBABA:? </code></pre> <p><strong>Constraints:</strong></p> <ul> <li>The program must derive the counting algorithm <strong>only by manipulating the data given</strong> in the training set. It must not use hard coded knowledge of binary counting.</li> <li>Many algorithms may produce the correct answers. Therefore, <strong>the simplest algorithm is preferred</strong>. </li> <li>The program should assume that <strong>each answer is a transformation of the question</strong>.</li> <li>All questions will be in the binary format seen above, but they may be of arbitrary size.</li> </ul> <p>Can any existing machine learning programs/algorithms solve this? If so, how? If you believe this is unsolvable, please explain why.</p> <hr> <p><em>This update contains background to the question, explanation of the problem space, a new constraint, a proposed solution, and further questions.</em></p> <p>This problem is relevant to general machine learning where the machine must learn by observation and feedback the algorithms that govern the world around it.</p> <p>Based on <a href="https://en.wikipedia.org/wiki/Kolmogorov_complexity" rel="nofollow">Kolmogorov complexity</a>, there is at least one program that can produce the correct mappings:</p> <pre><code>if B, then BA if BA, then BB (etc. for all pairs in training set) </code></pre> <p>This will work for every pair in the training set and nothing else. This will be the shortest program if the training set is completely random. The good news is that this is an upper bound. For any training set that is not random, there will be a smaller program that will work. Also, the number of programs smaller than upper bound is finite. </p> <p>A unfortunate result of Kolmogorov complexity is that it cannot be calculated. This is due to the <a href="http://en.wikipedia.org/wiki/Halting_problem" rel="nofollow">halting problem</a>. We can't know if any program will stop until it does.</p> <p>If the question is "Write pi," then the program that produces the correct answer would never halt because pi has infinite digits. An answer infinitely long is never desirable so I think the best way to deal with this is to put an <strong>arbitrary limit on the length of the answer</strong>.</p> <p>With that additional constraint, here is an (inefficient) program that will generate a correct solution program shorter than the upper bound if one exists. (sorry of this is confusing, but these steps outline a program that generates programs that implement an algorithm to map questions to answers in a training set):</p> <ol> <li>Create the "upper bound" program. One that maps each input in the training set directly to its output.</li> <li>Generate every possible program that is shorter than the upper bound and list them from shortest to longest.</li> <li>Starting with the shortest program, run the first step of every program. </li> <li>Stop when a correct program is found.</li> <li>Eliminate programs that stop without a correct answer or produce an answer longer than the arbitrary limit.</li> <li>Repeat steps 3-5 running the second step, third step, etc. of the programs.</li> </ol> <p>This program has the following benefits:</p> <ul> <li>It limits the number of programs to those smaller than the "upper bound" program.</li> <li>It avoids the halting problem by <ul> <li>incorporating an arbitrary limit to the length of the answer and </li> <li>executing step x in all programs before moving on to step x+1 so that the solution will be found before looping infinity.</li> </ul></li> </ul> <p>The main disadvantage is that it is terribly slow. It takes millions of years to crack a 128 bit password and I think this program could have comparable performance.</p> <p><strong>Now, the questions:</strong></p> <ul> <li><p>Do you see any significant flaws in this solution?</p></li> <li><p>Can this program's performance be improved in any significant way without introducing onerous constraints?</p></li> </ul> https://cs.stackexchange.com/questions/19663/-/19682#19682 1 Answer by D.W. for What program will derive the underlying algorithm in these question-answer pairs (updated)? D.W. https://cs.stackexchange.com/users/755 2014-01-13T07:34:24Z 2014-01-13T09:19:12Z <p>The same answers you got <a href="https://cs.stackexchange.com/a/19640/755">the last time you asked this question</a> apply. There are infinitely many possible mappings $\{A,B\}^* \to \{A,B\}^*$ and none is preferable to any other.</p> <p>Let's try to formalize your problem more clearly. I suspect you want an algorithm to solve the following problem:</p> <blockquote> <p>Given a training set as input (i.e., a set of mappings $x \mapsto y$, where $x,y$ are strings), output the shortest algorithm $A$ with the property that $A(x)=y$ for every $x,y$ in the training set.</p> </blockquote> <p>The bad news is that this problem is not solvable. In particular, the problem is undecidable, so you should not expect any general algorithm to solve this problem. To do better, you will need some structure on the set of hypotheses (e.g., a distribution on possible mappings or something like that).</p> <p>Why is this undecidable? Because it is basically the problem of computing the <a href="https://en.wikipedia.org/wiki/Kolmogorov_complexity" rel="nofollow noreferrer">Kolmogorov complexity</a> of the training set, and computing the Kolmogorov complexity is known to be undecidable.</p> <p>You might be wondering how standard methods for machine learning get around this barrier. The answer is that they avoid this barrier by changing the problem statement. Machine learning methods generally involve a more restricted space of hypotheses (instead of allowing all possible algorithms, we only consider a restricted subset, such as those that are linear or that have some other nice properties) or else involve specifying a probability distribution on the set of possible mappings. I recommend you spend some time studying machine learning.</p> <hr> <p>What is the context and motivation for your question? What's the <em>specific</em> real-world situation where you encountered this? To make progress I suspect you'll need to step back and look at the real requirements from your application, and be open to other ways to meet your needs.</p>