A Legal Framework for Artificially Intelligent Robots