The UK has joined the EU and the United States in signing the first international treaty on artificial intelligence, which commits nations to protecting the public from potential dangers linked to the technology.