/// <summary>
 /// Check argument and throw instantiation exception if necessary.
 /// </summary>
 public static void Check(object task, object arg, bool shouldBeInstantiated, BindingEnvironment e,
                          object[] args)
 {
     if (!(e.Resolve(arg) is LogicVariable) != shouldBeInstantiated)
     {
         throw new ArgumentInstantiationException(task, e, args);
     }
 }