https://github.com/tani/ob-acl2
https://github.com/tani/ob-acl2
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tani/ob-acl2
- Owner: tani
- License: gpl-3.0
- Created: 2024-05-01T12:16:18.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-05T18:44:41.000Z (about 1 year ago)
- Last Synced: 2025-02-02T00:46:31.033Z (4 months ago)
- Language: Emacs Lisp
- Size: 36.1 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE.md
Awesome Lists containing this project
README
#+TITLE: ob-acl2
#+AUTHOR: TANIGUCHI MasayaThis is a library for org-babel to execute ACL2 code.
* Installation
This package is not yet available on MELPA.
But you can install it from GitHub as follows:#+BEGIN_SRC emacs-lisp
(leaf ob-acl2
:vc (:url "https://github.com/tani/ob-acl2")
:config
(defun ob-acl2-setup ()
(add-to-list 'org-babel-load-languages '(acl2 . t))
(add-to-list 'org-src-lang-modes '("acl2" . lisp)))
(add-hook 'org-mode-hook 'ob-acl2-setup))
#+END_SRC#+RESULTS:
: ob-acl2* Usage
You can execute ACL2 code in org-mode as follows:
First, write lisp function in org-mode and evaluate it (=C-c C-c=).
#+BEGIN_SRC acl2 :results output
(defun factorial (n)
(if (zp n)
1
(* n (factorial (1- n)))))
#+END_SRC#+RESULTS:
#+begin_exampleThe admission of FACTORIAL is trivial, using the relation O< (which
is known to be well-founded on the domain recognized by O-P) and the
measure (ACL2-COUNT N). We observe that the type of FACTORIAL is described
by the theorem (AND (INTEGERP (FACTORIAL N)) (< 0 (FACTORIAL N))).
We used the :compound-recognizer rule ZP-COMPOUND-RECOGNIZER and primitive
type reasoning.Summary
Form: ( DEFUN FACTORIAL ...)
Rules: ((:COMPOUND-RECOGNIZER ZP-COMPOUND-RECOGNIZER)
(:FAKE-RUNE-FOR-TYPE-SET NIL))
Time: 0.00 seconds (prove: 0.00, print: 0.00, other: 0.00)
FACTORIAL
#+end_exampleYaay! The function FACTORIAL is defined.
Let's prove that the factorial of a positive integer is positive.
Write a theorem and evaluate it.#+BEGIN_SRC acl2 :results output
(defthm factorial-positive
(implies (and (integerp n) (<= 0 n))
(and (integerp (factorial n))
(< 0 (factorial n)))))
#+END_SRC#+RESULTS:
#+begin_exampleQ.E.D.
The storage of FACTORIAL-POSITIVE depends upon primitive type reasoning
and the :type-prescription rule FACTORIAL.Summary
Form: ( DEFTHM FACTORIAL-POSITIVE ...)
Rules: ((:FAKE-RUNE-FOR-TYPE-SET NIL)
(:TYPE-PRESCRIPTION FACTORIAL))
Time: 0.00 seconds (prove: 0.00, print: 0.00, other: 0.00)
FACTORIAL-POSITIVE
#+end_exampleThe theorem FACTORIAL-POSITIVE is proved.
Now, you have a safe and sound factorial function in ACL2.* License
Copyright (C) 2024 TANIGUCHI Masaya
This program is licensed under the GNU General Public License version 3.
* Related works
- [[https://github.com/tani/acl2-kernel]] - A jupyter kernel for ACL2