acl2等式推理,证明平等

时间:2014-03-15 19:54:11

标签: acl2 equational-reasoning

我正在尝试证明以下函数是真的,并且我很难搞清楚它,即使它看起来很明显!

(implies (and (listp x)
              (listp y))
         (equal (app (rev x) (rev y))
                (rev (app x y))))

通过这样做我只需要使用函数显示(app(rev x)(rev y))等同于(rev(app x y)))):

(defunc len (x)
  :input-contract t
  :output-contract (natp (len x))
  (if (atom x)
    0
    (+ 1 (len (rest x)))))

(defunc atom (x)
  :input-contract t
  :output-contract (booleanp (atom x))
  (not (consp a)))

(defunc not (a)
  :input-contract (booleanp a)
  :output-contract (booleanp (not a))
  (if a nil t))

(defunc listp (l)
  :input-contract t
  :output-contract (booleanp (listp l))
  (or (equal l ())
      (consp l)))

(defunc endp (a)
  :input-contract (listp a)
  :output-contract (booleanp (endp a))
  (not (consp a)))

(defunc twice (l)
  :input-contract (listp l)
  :output-contract (listp (twice l))
  (if (endp l)
    nil
    (cons (first l) (cons (first l) (twice (rest l))))))

(defunc app (a b)
  :input-contract (and (listp a) (listp b))
  :output-contract (listp (app a b))
  (if (endp a)
    b
    (cons (first a) (app (rest a) b))))

(defunc rev (x)
  :input-contract (listp x)
  :output-contract (and (listp (rev x)) (equal (len x) (len (rev x))))
  (if (endp x)
    nil
    (app (rev (rest x)) (list (first x)))))

这是我如何做另一个(希望正确)

(implies (listp y)
         (equal (len (rev (cons x y)))
                (+ 1 (len (rev y)))))

“反向追加事物”

(rev (app (rev y) (rex x))) = (app x y)

(len (rev (cons x y))

= def of rev

len (app (rev y) (list x))

= rev的输出合约

(len (rev (app (rev y) (list x))))

=“反向追加事物”

(len (rev (cons x y))

= rev的输出合约

(len (cons x y))

= def of len

(+ 1 (len y))

= rev的输出合约

(+ 1 (len (rev y)))

0 个答案:

没有答案