A differentiable neural computer for logic reasoning with scalable near-memory computing and sparsity based enhancement