diff --git a/table.lisp b/table.lisp index a6638e9..2dc9e90 100644 --- a/table.lisp +++ b/table.lisp @@ -38,6 +38,10 @@ collect (cons (cons var nil) entry)) finally (return (mapcar 'reverse perms)))) +(defconstant +maximum-variables+ 12 + "The maximum number of variables allowed when including variables in the table +output.") + (defun create-truth-table (prop &key (vars (discover-variables prop)) (include-intermediate t) (include-vars t)) "Evaluate PROP with all possible combinations of truth values for its @@ -49,6 +53,10 @@ if it is excluded, `discover-variables' will be used to generate it." ((null vars) (list (list (cons prop (eval-proposition prop '()))))) (t + (when (> (length vars) +maximum-variables+) + (error 'proposition-eval-error + :message (format nil "Got ~A variables when the max is ~A" + (length vars) +maximum-variables+))) (loop for perm in (permute-variables vars) for (value sub-map) = (multiple-value-list (eval-proposition prop perm))