我正在尝试在 ACL2 中以一元符号 ( O
, (S O)
, (S (S O))
, ...) 对自然数进行建模,并证明加法的交换性。这是我的尝试:
; a NATURAL is 'O or a list ('S n') where n' is a NATURAL
(defun naturalp (n)
(cond ((equal n 'O) t)
(t (and (true-listp n)
(equal (length n) 2)
(equal (first n) 'S)
(naturalp (second n))))))
(defun pred (n)
(cond ((equal n 'O) 'O)
((naturalp n) (second n))))
(defun succ (n)
(list 'S n))
(defun plus (n m)
(cond ((equal n 'O) m)
((naturalp n) (succ (plus (pred n) m)))))
; FIXME: cannot prove this because rewriting loops...
(defthm plus_comm
(implies (and (naturalp n) (naturalp m))
(iff (equal (plus n m) (plus m n)) t)))
这可能不是最 LISPy 的方式,我习惯于使用模式匹配的语言。
我的问题正如评论所建议的那样:证明者循环,试图证明同一事物的越来越深的嵌套版本。我该如何阻止这个?该手册确实简要提到了循环重写规则,但没有说明如何处理它们。
我的期望是这个证明会失败,给我提示需要哪些辅助引理来完成它。我可以使用循环证明的输出来找出可能停止循环的引理吗?