1
; Introduction of an arbitrary primitive-recursive function.
2
; Construction based on flat domains in ACL2.
3
; Copyright (C) 2001 John R. Cowles, University of Wyoming
5
; This book is free software; you can redistribute it and/or modify
6
; it under the terms of the GNU General Public License as published by
7
; the Free Software Foundation; either version 2 of the License, or
8
; (at your option) any later version.
10
; This book is distributed in the hope that it will be useful,
11
; but WITHOUT ANY WARRANTY; without even the implied warranty of
12
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
; GNU General Public License for more details.
15
; You should have received a copy of the GNU General Public License
16
; along with this book; if not, write to the Free Software
17
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
; Department of Computer Science
22
; University of Wyoming
23
; Laramie, WY 82071-3682 U.S.A.
26
; Last modified 20 December 2001.
28
To certify (originally in ACL2 Version 2.6):
32
*common-lisp-symbols-from-main-lisp-package*))
34
(certify-book "flat-primitive" 1 nil ; compile-flg
41
A construction based on flat domains in ACL2, as introduced in
42
flat.lisp, of a function f that satisfies the equation, for
43
functions h that are monotonic in their second argument, in the
46
(defthm generic-primitive-recursive-f
48
(if (test x) (base x) (h x (f (st x)))))).
50
The book primitive.lisp gives an alternative (and simpler)
51
construction of such a primitive-recursive f.
53
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
54
;; Add some basic arithmetic facts:
64
associate-constants-left-+
65
(implies (and (syntaxp (quotep x))
73
(implies (acl2-numberp y)
80
(implies (acl2-numberp y)
84
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
85
;; Proceed with the construction:
102
(declare (ignore x y))
107
(implies ($<=$ y1 y2)
108
($<=$ (h x y1)(h x y2))))
113
(implies (and (syntaxp (not (equal y '($bottom$))))
114
(not (equal (h x ($bottom$)) ($bottom$))))
115
(equal (h x y)(h x ($bottom$))))
117
:in-theory (disable h-is-monotonic-2)
129
(h x (f-chain (- i 1)(st x))))))
132
base-of-f-chain=$bottom$
138
f-chain-is-$<=$-chain
139
(implies (and (integerp i)
142
(f-chain (+ 1 i) x))))
144
;; Choose an ``index'' for definition of lub of f-chain:
148
(not (equal (f-chain i x)
152
lub-f-chain-i-rewrite
153
(implies (equal (f-chain (lub-f-chain-i x) x)
155
(equal (f-chain i x) ($bottom$)))
157
:use lub-f-chain-i)))
159
;; Make sure the chosen index is a nonneg. integer:
162
lub-f-chain-nat-i (x)
163
(nfix (lub-f-chain-i x)))
165
;; Define the least upper bound of f-chain:
169
(f-chain (lub-f-chain-nat-i x) x))
171
(in-theory (disable (:executable-counterpart
175
lub-f-chain-is-upper-bound
180
(:functional-instance
181
lub-$bottom$-based-chain-is-upper-bound
182
($bottom$-based-chain f-chain)
183
(lub-$bottom$-based-chain lub-f-chain)
184
(lub-$bottom$-based-chain-nat-i lub-f-chain-nat-i)
185
(lub-$bottom$-based-chain-i lub-f-chain-i)))
187
:use f-chain-is-$<=$-chain)))
204
g-chain-$<=$-ub-g-chain
205
(implies (and (integerp i)
210
:in-theory (disable lub-f-chain-is-upper-bound)
212
lub-f-chain-is-upper-bound
217
(lub-f-chain-nat-i (st x)))
220
ub-g-chain-=-g-chain-Skolem-f
221
(equal (ub-g-chain x)
222
(g-chain (Skolem-f x) x)))
225
lub-f-chain=ub-g-chain
226
(equal (lub-f-chain x)(ub-g-chain x))
230
(:functional-instance
231
lub-$chain$=ub-shifted-$chain$
233
(lub-$chain$ lub-f-chain)
234
(lub-$chain$-i lub-f-chain-i)
235
(lub-$chain$-nat-i lub-f-chain-nat-i)
237
(shifted-$chain$ g-chain)
238
(ub-shifted-$chain$ ub-g-chain)))
240
:use g-chain-$<=$-ub-g-chain)
242
:use f-chain-is-$<=$-chain)
246
generic-primitive-recursive-f
252
:use lub-f-chain=ub-g-chain)))