Introduce a
defsubtype introduces fixtypes for an arbitrary subtype.
A subtype
(iff (sub-p x) (and (super-p x) (sub-restriction-p x)))
The restriction predicate should be a total function of one argument.
It can be a symbol or a lambda expression.
The required
(defsubtype positive-even :supertype pos :restriction (lambda (x) (and (integerp x) (evenp x))) :fix-value 2)
This example would produce:
The reason the restriction predicate is not just
(defsubtype subtype :supertype ... ;; required; must be defined using fty :restriction ... ;; required; can be named or a lambda expression :fix-value ... ;; required :pred ... ;; optional name of new predicate; default: subtype-p :fix ... ;; optional; default: subtype-fix :equiv ... ;; optional; default: subtype-equiv :parents ... ;; optional; XDOC parents :short ... ;; optional; XDOC short description. :long ... ;; optional; XDOC long description. )
A symbol that specifies the name of the new fixtype.
A symbol that names a fixtype that is a supertype of the type being defined.
The recognizer, fixer, and equivalence function of the supertype must all be guard-verified.
A predicate that is used, in conjunction with the supertype's predicate, to define
pred , which recognizes values of the subtype.
The value returned by the fixing function when passed a value for which
pred is false. Also establishes that the subtype has at least one value.
A symbol that specifies the name of the generated recognizer for
subtype . If this isnil (the default), the name of the recognizer issubtype followed by-p .
A symbol that specifies the name of the generated fixer for
subtype . If this isnil (the default), the name of the fixer issubtype followed by-fix .
A symbol that specifies the name of the generated equivalence checker for
subtype . If this isnil (the default), the name of the equivalence checker issubtype followed by-equiv .
These, if present, are added to the XDOC topic generated for the new fixtype.
The recognizer for the fixtype, guard-verified.
A rewrite rule saying that
pred is boolean-valued.
A rewrite rule and a forward chaining rule saying that a value satisfies
supertype-pred when it satisfiespred .
The fixer for the fixtype, guard-verified.
It fixes values outside of
pred by returningfix-value .
pred-of-fix A rewrite rule saying that
fix always returns a value that satisfiespred .
fix-when-pred A rewrite rule saying that
fix disappears when its argument satisfiespred .
type equiv The fixtype, via a call of deffixtype that also introduces the equivalence checker
equiv .The above items are generated with XDOC documentation.