DeclareInvariant

DeclareInvariant[class,f]
declares the invariant for the symbol class to be the pure function f.

DeclareInvariant[class,{f1,f2,}]
declares the invariant for the symbol class based on the pure functions fi.

DetailsDetails

  • ValidQ[instance] returns True if instance satisfies the class invariants specified through DeclareInvariant.
  • The symbol class in DeclareInvariant[class,instance] has to have been declared a class using DeclareClass.
  • DeclareInvariant can be used to specify additional requirements for a child class, which are otherwise inherited from the child class' parents.
  • DeclareInvariant never overwrites existing invariants, it only specifies additional invariants.