Learning Invariants through Soft Unification