원시데이터 수집 시스템
선정목록으로

Extended Abstract: Partial-encapsulate and Its Support for Floating-point Operations in ACL2

관련 화학·수지 · (21) 에폭시수지

기본 정보

저자
  1. Matt Kaufmann
  2. J Strother Moore
DOI
10.4204/eptcs.423.6
저널
Electronic Proceedings in Theoretical Computer Science
발행년도
2025
발행기관
Open Publishing Association
피인용수
0
라이선스
cc-by-nc-nd
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.4204/eptcs.423.6
토픽
High voltage insulation and dielectric phenomena
OpenAlex ID
W4412627213

평가 내용

관련도
관련
사업분야
화학·수지 · (21) 에폭시수지
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '화학·수지 > 에폭시수지' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

We illustrate the power of partial-encapsulate, showing how it is used in the implementation of floating-point operations in ACL2.

본문 12,761자

본문 펼치기
# Extended Abstract: Partial-encapsulate and Its Support for Floating-point Operations in ACL2 Matt Kaufmann and J Strother Moore Department of Computer Science, The University of Texas at Austin, Austin, TX, USA (retired) {kaufmann,moore}@cs.utexas.edu ## 1 Introduction [The partial-encapsulate](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____PARTIAL-ENCAPSULATE) <sup>1</sup> macro was introduced in ACL2 Version 8.2 (May, 2019), providing a general way to evaluate constrained functions, thus generalizing [trusted (unverified) clause-processors](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____DEFINE-TRUSTED-CLAUSE-PROCESSOR) [5]. However, the [ACL2 community books](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____COMMUNITY-BOOKS) [6] of ACL2 Version 8.6 contain only a few applications of this utility. One goal of this extended abstract is to publicize (finally) this powerful utility. We do so by describing how it supports floating-point (FP) computation in ACL2, which addresses our second goal: to augment the very brief discussion of that support in our published treatment of FP computation in ACL2 [4]. This extended abstract is intended to be reasonably self-contained, especially when combined with the supporting materials described below. For much more background on FP computation in ACL2, see [its documentation topic for user-level discussion; and for implementation-level comments, see the ACL2](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____DF) source code, especially file float-a.lisp and the comment therein, Essay on Support for Floatingpoint (double-float, df) Operations in ACL2. FP computations are widely used in the scientific community, and they are generally much faster than computations with rationals. ACL2 supports such computations using double-floats (FPs), which are a Lisp <sup>2</sup> datatype typically consisting of double-precision floating-point numbers. But FP operations are awkward to axiomatize. The following Lisp computations show that FP addition is not associative (which is awkward since ACL2 + is axiomatized to be associative) and in Lisp, the EQUAL function does not compute equality on numbers. ? (setq *read-default-float-format* ’double-float) ; read FPs as double-floats DOUBLE-FLOAT ? (+ 0.1 (+ 0.2 0.3)) 0.6 ? (+ (+ 0.1 0.2) 0.3) ; not the same result as above; associativity fails! 0.6000000000000001 ? (equal 1 1.0) ; two equal arithmetic values need not satisfy EQUAL NIL ? A solution might be to add a new FP datatype to the ACL2 logic, but we were loath to complicate ACL2 that way. In particular, although that could explain a result of nil for the evaluation of (equal 1 1Underlined links are to ACL2 documentation topics. 2In this paper, “Lisp” refers to Common Lisp [7]. Gamboa and Manolios (Eds): ACL2 Workshop 2025 [EPTCS 423, 2025, pp. 56–59, doi:10.4204/EPTCS.423.6](http://dx.doi.org/10.4204/EPTCS.423.6) © M. Kaufmann & J S. Moore This work is licensed under the [Creative Commons Attribution License.](https://creativecommons.org) M. Kaufmann & J S. Moore 57 1.0), it would be at odds with a result of t for the evaluation of (= 1 1.0), since = is defined logically [to be EQUAL. The new datatype would also probably complicate ACL2’s type reasoning.](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____TYPE-REASONING) Instead, ACL2 models FPs as the rational numbers they represent; a rational is representable if it is the numeric value of a double-float. [By tracking the use of FP expressions much as stobjs [1] are tracked,](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____STOBJ) ACL2 arranges for Lisp FP computations to be performed using Lisp double-floats, even though they are rational operations logically. Our goal is to illustrate how partial-encapsulate, when combined with redefinition in Lisp al[lowed by a trust tag [2], can extend the power of ACL2. We illustrate this idea by showing a toy example](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____DEFTTAG) that supports FP operations. For simplicity, this exposition ignores the stobj-like tracking mentioned above; as a result (and as noted at the end below), this toy implementation is actually unsound! That observation highlights the potential danger of using partial-encapsulate together with redefinition in Lisp. The actual ACL2 implementation of floating-point operations also uses partial-encapsulate but avoids unsoundness by taking great care, including the use of stobj-like tracking mentioned above. Although our toy example involves floating-point numbers, we expect most user applications would avoid data types not supported by the ACL2 logic (like floating-point). That should make it considerably less complicated to avoid unsoundness than was the case when adding support to ACL2 for FP operations. ## 2 A Toy Implementation Illustrating FP Support We describe the example worked out in the supporting materials for this paper, which can be found in the following files in community books directory books/demos/fp/. - fp.lisp — Certifiable book introducing some FP operations logically - fp-raw.lsp — Lisp redefinitions supporting FP computation - fp.acl2 — Certification support for trust tag and dependencies They define a few functions with “fp” in the name, which correspond to analogous ACL2 built-ins with “df” (for “double-float”) in the name instead of “fp”. [(There are many more df built-ins as well.)](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____DF) Square root and addition functions are introduced logically in fp.lisp using partial-encapsulate but are given executable Lisp definitions in file fp-raw.lsp. To support these, we also introduce a conversion function to-fp and a recognizer function fpp in fp.lisp, as follows. Think of (to-fp x) as choosing a representable rational near x; specifically, it chooses the rational returned by evaluating the expression (float x 0.0D0) in Common Lisp, as discussed further below. (partial-encapsulate ; introduce conversion to representable rationals (((constrained-to-fp *) => - :formals (x) :guard (rationalp x))) nil ; supporters; see documentation for partial-encapsulate (local (defun constrained-to-fp (x) (declare (ignore x)) 0)) (defthm rationalp-constrained-to-fp (rationalp (constrained-to-fp x)) :rule-classes :type-prescription) (defthm constrained-to-fp-idempotent (equal (constrained-to-fp (constrained-to-fp x)) (constrained-to-fp x))) ... ; other exported defthm events omitted here ) 58 FP in ACL2 (defun to-fp (x) ; convert to representable rationals (declare (xargs :guard (rationalp x))) (constrained-to-fp x)) (defun fpp (x) ; recognizer for representable rationals (declare (xargs :guard t)) (and (rationalp x) (= (to-fp x) x))) A partial-encapsulate event represents a corresponding, implicit encapsulate event that introduces additional exported theorems. The key requirement is that the axioms exported by that event, including the implicit additional ones, are all provable for some choice of local witnesses for the signature functions. See the documentation topic for [partial-encapsulate](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____PARTIAL-ENCAPSULATE) for more information about that [utility, in particular its lack of support for functional instantiation](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____FUNCTIONAL-INSTANTIATION) due to unknown constraints. In the case of constrained-to-fp, the implicit constraints (from additional, hidden defthm events) include a theorem for each computation result based on the following definition from fp-raw.lisp; for example, since (float 1/3 0.0D0) computes to an FP with value 6004799503160661/18014398509481984, an implicit axiom is (equal (to-fp 1/3) 6004799503160661/18014398509481984). (defun to-fp (x) (declare (type rational x)) (float x 0.0D0)) Of course, there are in principle infinitely many such implicit axioms. But the implicit encapsulate event is a finite object, so we consider only computation results that will be performed, somewhere by someone, using the current version of ACL2. For details, see comments in the partial-encapsulate that introduces function symbol constrained-to-df in ACL2 source file float-a.lisp. Why don’t we instead introduce to-fp with partial-encapsulate and eliminate the function constrained-to-fp? The reason is that the ACL2 rewriter refuses to execute calls of constrained functions (regardless of redefinition in Lisp). This way, ACL2 succeeds, for example, in the proof of (thm (equal (to-fp 1/4) 1/4)). The function fp-round is similar to to-fp, but these two functions serve different purposes. To-fp is intended to be executable. Fp-round, which is not executable, logically supports defining FP addition to be the rounded result of exact addition, as specified by IEEE Standard 754 [3]. FP addition is defined as follows in fp.lisp. (defun fp+ (x y) (declare (xargs :guard (and (fpp x) (fpp y)))) (fp-round (+ x y))) Fp+ is redefined in fp-raw.lsp as follows. Note that for FPs x and y, the Lisp + operation does the requisite rounding. (defun fp+ (x y) (declare (type double-float x y)) (+ x y)) For more details see the aforementioned supporting materials, which in particular contain: - redefinition in Lisp using a trust tag followed by the form [(include-raw](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____INCLUDE-RAW) "fp-raw.lsp") in fp.lisp, to load fp-raw.lsp into Lisp, which redefines functions already defined in ACL2; M. Kaufmann & J S. Moore 59 - introduction of the FP square root function, fp-sqrt, using partial-encapsulate for ACL2 and Lisp sqrt for execution; - [handling of executable-counterpart](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____EVALUATION) (so-called “*1*”) functions for redefined functions; - tests showing that evaluation works, even during proofs; and - examples demonstrating the need for care when using Lisp redefinition, by proving nil. The soundness issue just above is due to the attempt to traffic in a Lisp datatype (double-float) that is not supported in the ACL2 logic. Comments in fp.lisp outline how ACL2 avoids these problems for [its df implementation.](https://www.cs.utexas.edu/users/moore/acl2/manuals/latest/index.html?topic=ACL2____DF) We expect that most user applications of partial-encapsulate can avoid such soundness issues if appropriate care is taken. Acknowledgments. We thank Warren Hunt for encouraging the implementation of floating-point operations in ACL2 and ForrestHunt, Inc. for supporting that implementation. We also thank the reviewers for helpful comments. ## References [1] Robert S. Boyer & J Strother Moore (2002): Single-Threaded Objects in ACL2. In Shriram Krishnamurthi & C. R. Ramakrishnan, editors: Practical Aspects of Declarative Languages, 4th International Symposium, PADL 2002, Portland, OR, USA, January 19-20, 2002, Proceedings, Lecture Notes in Computer Science [2257, Springer, pp. 9–27, doi:10.1007/3-540-45587-6_3.](https://doi.org/10.1007/3-540-45587-6_3) [2] Peter C. Dillinger, Matt Kaufmann & Panagiotis Manolios (2007): Hacking and Extending ACL2. In Ruben Gamboa, Jun Sawada & John Cowles, editors: Proceedings Seventh International Workshop on the ACL2 Theorem Prover and its Applications. [3] IEEE (2019): IEEE Standard for Floating-Point Arithmetic. IEEE Std 754-2019 (Revision of IEEE 754-2008), [pp. 1–84, doi:10.1109/IEEESTD.2019.8766229.](https://doi.org/10.1109/IEEESTD.2019.8766229) [4] Matt Kaufmann & J Strother Moore (2024): ACL2 Support for Floating-Point Computations, p. 251–270. [Springer Nature Switzerland, doi:10.1007/978-3-031-66676-6_13.](https://doi.org/10.1007/978-3-031-66676-6_13) [5] Matt Kaufmann, J Strother Moore, Sandip Ray & Erik Reeber (2009): Integrating External Deduction Tools with ACL2. [Journal of Applied Logic 7(1), pp. 3–25, doi:10.1016/j.jal.2007.07.002.](https://doi.org/10.1016/j.jal.2007.07.002) [6] The ACL2 Community (2024): The ACL2 Community Books. [https://github.com/acl2/acl2/tree/](https://github.com/acl2/acl2/tree/master/books) [master/books.](https://github.com/acl2/acl2/tree/master/books) [7] Kent Pitman: The Common Lisp HyperSpec. See [https://www.lispworks.com/documentation/](https://www.lispworks.com/documentation/HyperSpec/Front/) [HyperSpec/Front/.](https://www.lispworks.com/documentation/HyperSpec/Front/)

섹션 본문

섹션 본문이 없습니다.

참고문헌 4건

  1. Single-Threaded Objects in ACL2 Lecture notes in computer science · Springer Science+Business Media · 2001 10.1007/3-540-45587-6_3
  2. IEEE Standard for Floating-Point Arithmetic 2019 10.1109/ieeestd.2019.8766229
  3. ACL2 Support for Floating-Point Computations Lecture notes in computer science · Springer Science+Business Media · 2024 10.1007/978-3-031-66676-6_13
  4. Integrating external deduction tools with ACL2 Journal of Applied Logic · Elsevier BV · 2007 10.1016/j.jal.2007.07.002