Check if a constraint is well-formed, with respect to a list of relation definitions.
(constraint-wfp constr defs) → yes/no
An equality is always well-formed. An application of a named relation to some expressions is well-formed iff the relation is defined in the list of defined relations and the number of argument expressions is the same as the number of formal parameters.
Function:
(defun constraint-wfp (constr defs) (declare (xargs :guard (and (constraintp constr) (definition-listp defs)))) (let ((__function__ 'constraint-wfp)) (declare (ignorable __function__)) (constraint-case constr :equal t :relation (b* ((def? (lookup-definition constr.name defs))) (and (definitionp def?) (= (len constr.args) (len (definition->para def?))))))))
Theorem:
(defthm booleanp-of-constraint-wfp (b* ((yes/no (constraint-wfp constr defs))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm constraint-wfp-of-constraint-fix-constr (equal (constraint-wfp (constraint-fix constr) defs) (constraint-wfp constr defs)))
Theorem:
(defthm constraint-wfp-constraint-equiv-congruence-on-constr (implies (constraint-equiv constr constr-equiv) (equal (constraint-wfp constr defs) (constraint-wfp constr-equiv defs))) :rule-classes :congruence)
Theorem:
(defthm constraint-wfp-of-definition-list-fix-defs (equal (constraint-wfp constr (definition-list-fix defs)) (constraint-wfp constr defs)))
Theorem:
(defthm constraint-wfp-definition-list-equiv-congruence-on-defs (implies (definition-list-equiv defs defs-equiv) (equal (constraint-wfp constr defs) (constraint-wfp constr defs-equiv))) :rule-classes :congruence)