(pat->al pat data al) extends the alist
The cars of the new pairs are precisely all the non-NIL atoms of
the pattern
(pat->al '(a (b) (c d)) '(1 (2) (3 4)) nil) --> ((a . 1) (b . 2) (c . 3) (d . 4))
The alist is extended with ordinary
Function:
(defun pat->al (pat data al) (declare (xargs :guard (data-for-patternp pat data))) (if pat (if (atom pat) (cons (cons pat data) al) (pat->al (car pat) (car data) (pat->al (cdr pat) (cdr data) al))) al))
Theorem:
(defthm pat->al-to-append (implies (syntaxp (not (equal acc ''nil))) (equal (pat->al a b acc) (append (pat->al a b nil) acc))))
Theorem:
(defthm alist-keys-pat->al (equal (alist-keys (pat->al p1 p2 nil)) (pat-flatten1 p1)))