Scientists have discovered a connection between disrupted sleep during middle age and cognitive decline in the future.