Cosmic Logic