This directory contains the source code for the decision procedure described in Using Compassion and Respect to Motivate an Artificial Intelligence. Since this is just a decision procedure, even on toy problems it will not terminate in the forseeable future if run on physically realizable computers. However, parts of the code can be separately tested, and in aggregate all of the unit tests listed below touch all lines of the code.
This file describes how to run the regression tests, and it provides an overview that makes it easy to browse individual source files either from the web or after downloading the sources.
The code was tested on a 600 MhZ Pentium system running GNU/Linux. It is written in Python, and tested against Python 2.3.5. Using GNU/Linux for testing ought to be inessential, but you will need Python, which can be downloaded from http://www.python.org. To run the tests, do the following:
import mpmath mpmath.__version__
python regress.py -nocover to run the
regression tests without doing coverage analysis. This takes 23
seconds on a 600 MhZ Pentium system.
python regress.py to run the regression tests
and print the results from coverage analysis. This will take about 10
times as long as running without coverage analysis.
If you have problems with this, or you have observed it to work with a different version of Python or a different operating system, send me email at tim@fungible.com.
We have three categories of Python source here:
| Name | Bytes | Lines | Description |
|---|---|---|---|
| animate.py | 3236 | 79 | Draw the state of a Turing machine as it executes, so they can be debugged. |
| answerer.py | 28279 | 652 | A simple decision procedure that uses inductive inference to answer questions. |
| bits.py | 6754 | 189 | Low-level data manipulation. Mostly bit-picking for Turing machines. |
| compile.py | 6805 | 155 | Rudimentary assembler for Turing machines. |
| compile_and_run.py | 2439 | 54 | Convenience functions to compile and run a Turing machine. |
| constants.py | 1350 | 29 | Constants used in Turing machine assembler syntax. |
| infer_utility.py | 14102 | 267 | Code for inferring an agent's utility function from his voluntary behavior and perceptions. Uses mind_body to first infer the voluntary behavior. |
| interleave.py | 5511 | 117 | Turing machine writing exercise. Given an input tape with bits abcd, return a tape three times as long with bits 00a00b00c00d. |
| machine.py | 5705 | 131 | Turing machine interpreter. |
| mind_body.py | 12973 | 265 | Infer an agent's voluntary actions and perceptions. The inputs are training data to extrapolate from and observations of the world (including the agent). Uses physics.py. |
| physics.py | 5739 | 128 | General decision procedure for inferring laws of physics given observations of the world. |
| plan_generators.py | 6763 | 160 | Utilities to generate plans. |
| planner.py | 13357 | 263 | Given the ability to infer utility functions for the known agents in the world (typically from infer_utility.py) and a plan for combining the utilities of the individual agents into a grand total (from utility_combiners.py), figure out what to do next. |
| speed_prior.py | 6044 | 137 | Speed prior explanations. These incorporate a Turing machine and a runtime limit, and they present methods for running subject to the time limit and for computing the complexity. |
| turing_tape.py | 4781 | 124 | The input or output tape of a Turing machine, made into an object for code readability and so we get errors sooner if we're passing the wrong data around. |
| utility_combiners.py | 3581 | 73 | Various ways to combine together the utilities of all of the agents other than the AI to get the AI's utility. |
| video_prediction.py | 4529 | 99 | A warm-up exercise in writing a decision procedure that could in principle extrapolate future frames of video based on past frames. |
| video_prediction_act.py | 4783 | 102 | Like video_prediction, except the AI's past actions are given as input and therefore do not need to be explained. |
| total | 136731 | 3024 |
A file with a name like foo_test.py is almost always
a test for foo.py.
| Name | Bytes | Lines | Description |
|---|---|---|---|
| animate_test.py | 2344 | 52 | |
| answerer_test.py | 27485 | 589 | |
| baby_catch_test.py | 31639 | 719 | Test cases for the reasoning about uncertainty. |
| bits_test.py | 3581 | 93 | |
| compile_and_run_test.py | 5652 | 128 | |
| compile_test.py | 2626 | 55 | |
| grocery_test.py | 17492 | 463 | Test cases for respect (planner.py and utility_combiners.py) involving grocery shopping. Explanations and the world-model are represented as Python code instead of Turing machines. |
| infer_utility_test.py | 39925 | 974 | |
| interleave_test.py | 2372 | 46 | |
| machine_test.py | 2742 | 58 | |
| mind_body_test.py | 1403 | 26 | |
| physics_test.py | 1802 | 37 | An incomplete test for physics.py. For the most part, physics.py is tested as a consequence of being used by other classes. The code here just tests a few things that were missed elsewhere. |
| plan_generators_test.py | 3685 | 95 | |
| planner_test.py | 1424 | 26 | |
| speed_prior_test.py | 2800 | 66 | |
| test_util_test.py | 1398 | 28 | |
| turing_tape_test.py | 3498 | 92 | |
| utility_combiners_test.py | 1989 | 52 | |
| video_prediction_act_test.py | 4542 | 110 | |
| video_prediction_test.py | 9846 | 221 | |
| total | 168245 | 3930 |
| Name | Bytes | Lines | Description |
|---|---|---|---|
| free_html.py | 9947 | 219 | Script for generating the free use cases. |
| htmlgen.py | 9668 | 245 | Shared code between the various HTML files. |
| index_html.py | 6767 | 175 | Script for generating index.html. |
| license_check.py | 5068 | 122 | Check that the given files incorporate copies of the LICENSE file. If -fix is passed, modify files to make them have a license. |
| license_text.py | 1896 | 50 | Code for formatting the license. |
| paper_html.py | 91472 | 1993 | Script for generating the main paper. |
| redundant_html.py | 5125 | 107 | Script for generating the redundant use cases. |
| regress.py | 3949 | 110 | The top level of the test harness. Useful if you want to run many tests or run with coverage analysis. |
| test_util.py | 2892 | 74 | Utilities for unit tests to call. |
| util.py | 1392 | 32 | Utility functions for document generation. |
| total | 138176 | 3127 |
If you want to regenerate this document from source, or you want to
repackage a variation on the source code, read the
Makefile.
coverage.py.patch includes some workarounds for Python
variable naming bugs that the coverage analyzer aggravates. These
bugs exist in Python 2.3.5 and may not exist in newer versions.
Copyright (c) 2009 Tim Freeman
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(This is the standard MIT License, copied from http://www.opensource.org/licenses/mit-license.php on 24 Apr 2007.)