1
; Copyright (C) 2000 Panagiotis Manolios
3
; This program is free software; you can redistribute it and/or modify
4
; it under the terms of the GNU General Public License as published by
5
; the Free Software Foundation; either version 2 of the License, or
6
; (at your option) any later version.
8
; This program is distributed in the hope that it will be useful,
9
; but WITHOUT ANY WARRANTY; without even the implied warranty of
10
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
; GNU General Public License for more details.
13
; You should have received a copy of the GNU General Public License
14
; along with this program; if not, write to the Free Software
15
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
; Written by Panagiotis Manolios who can be reached as follows.
19
; Email: pete@cs.utexas.edu
22
; Department of Computer Science
23
; The University of Texas at Austin
24
; Austin, TX 78701 USA
28
(defun make-sym (s suf)
29
; Returns the symbol s-suf.
30
(declare (xargs :guard (and (symbolp s) (symbolp suf))))
31
(intern-in-package-of-symbol
38
(defmacro defung (&rest def)
39
; A function definition that has a declare followed by a list of the
40
; form ((thm) commands), where commands can be anything that you would
41
; give to a defthm (look at defthm documentation), specifically it is:
42
; :rule-classes rule-classes
43
; :instructions instructions
48
; The if test checks for documentation strings.
50
(cons 'defun (append (list (first def)
53
(if (stringp (third def))
57
(append (list 'defthm (make-sym (car def) 'return-type))
58
(if (stringp (third def))
62
(defung update-valuation (v s val)
63
"gives val[v <- s] if v is in val, otherwise gives val U [v <- s]"
64
(declare (xargs :guard (alistp val)))
65
((implies (alistp val) (alistp (update-valuation v s val))))
68
(if (equal v (caar val))
70
(cons (car val) (update-valuation v s (cdr val))))))
72
(defun value-of (x alist)
73
(declare (xargs :guard (alistp alist)))
74
(cdr (assoc-equal x alist)))
77
(equal (value-of n (update-valuation m z x))
82
(defthm update-valuation-update-valuation-same
83
(equal (update-valuation i v1 (update-valuation i v2 l))
84
(update-valuation i v1 l)))