(exload "mpc/nat0.scm")

(add-program-constant
 "natPlus" (py "nat=>nat=>nat") 1 'const 2)

(add-token
 "+"
 'add-op
 (lambda (x y)
   (mk-term-in-app-form
    (make-term-in-const-form (pconst-name-to-pconst "natPlus")) x y)))

(add-display
 (py "nat")
 (lambda (x)
   (let* ((op (term-in-app-form-to-final-op x))
	  (args (term-in-app-form-to-args x)))
     (if (and (term-in-const-form? op)
	      (string=? "natPlus"
			(const-to-name (term-in-const-form-to-const op)))
	      (= 2 (length args)))
	 (list 'add-op "+"
	       (term-to-token-tree (car args))
	       (term-to-token-tree (cadr args)))
	 #f))))

(add-computation-rule (pt "n+0") (pt "n"))
(add-computation-rule (pt "n+Succ m") (pt "Succ(n+m)"))
(add-rewrite-rule (pt "0+n") (pt "n"))
(add-rewrite-rule (pt "Succ n+m") (pt "Succ(n+m)"))

(set-goal (pf "all n,m.n+m=m+n"))
(assume "n")
(ind)
(normalize-goal)
(use "Truth-Axiom")
(assume "m" "IH")
(normalize-goal)
(use "IH")

(cdp)
