constructor for terms and rules