Preserving the Structure of Definitions After Simplification Matt - - PowerPoint PPT Presentation

preserving the structure of definitions after
SMART_READER_LITE
LIVE PREVIEW

Preserving the Structure of Definitions After Simplification Matt - - PowerPoint PPT Presentation

Preserving the Structure of Definitions After Simplification Matt Kaufmann UT Austin November 6, 2018 1/9 THE PROBLEM 2/9 THE PROBLEM Task : Simplify definitions (largest single task during my three-year collaboration with Kestrel; part of


slide-1
SLIDE 1

Preserving the Structure

  • f Definitions

After Simplification

Matt Kaufmann

UT Austin

November 6, 2018

1/9

slide-2
SLIDE 2

THE PROBLEM

2/9

slide-3
SLIDE 3

THE PROBLEM

Task: Simplify definitions (largest single task during my three-year collaboration with Kestrel; part of their APT tool suite)

2/9

slide-4
SLIDE 4

THE PROBLEM

Task: Simplify definitions (largest single task during my three-year collaboration with Kestrel; part of their APT tool suite) Goal: Preserve structure when simplifying definitions

2/9

slide-5
SLIDE 5

THE PROBLEM

Task: Simplify definitions (largest single task during my three-year collaboration with Kestrel; part of their APT tool suite) Goal: Preserve structure when simplifying definitions Approach: Directed-untranslate

2/9

slide-6
SLIDE 6

THE PROBLEM

Task: Simplify definitions (largest single task during my three-year collaboration with Kestrel; part of their APT tool suite) Goal: Preserve structure when simplifying definitions Approach: Directed-untranslate Problem: Reconstruct LET, LET*, and MV-LET (and B*) after they are expanded away by simplification.

2/9

slide-7
SLIDE 7

THE PROBLEM

Task: Simplify definitions (largest single task during my three-year collaboration with Kestrel; part of their APT tool suite) Goal: Preserve structure when simplifying definitions Approach: Directed-untranslate Problem: Reconstruct LET, LET*, and MV-LET (and B*) after they are expanded away by simplification. Solution: Make separate calls to the ACL2 rewriter while descending through the top-level IF and LAMBDA calls of the definition’s body.

2/9

slide-8
SLIDE 8

EXAMPLE

(include-book "simplify") (defun app3 (x y ign) (declare (ignore ign)) (append x y)) (defstub f1 (x) t) (defun f2 (x) (f1 x)) (defun g (u) (let* ((temp (f2 u)) (v temp)) (app3 u v 17)))

3/9

slide-9
SLIDE 9

EXAMPLE

(include-book "simplify") (defun app3 (x y ign) (declare (ignore ign)) (append x y)) (defstub f1 (x) t) (defun f2 (x) (f1 x)) (defun g (u) (let* ((temp (f2 u)) (v temp)) (app3 u v 17))) ACL2 !>(simplify g) (DEFUN G$1 (U) (DECLARE (XARGS :GUARD T :VERIFY-GUARDS NIL)) (LET* ((TEMP (F1 U)) (V TEMP)) (APPEND U V))) (DEFTHM G-BECOMES-G$1 (EQUAL (G U) (G$1 U))) ACL2 !>

3/9

slide-10
SLIDE 10

(rewrite-augmented-term-rec aterm ; augmented term alist hyps geneqv thints runes ctx state) (generalize-to-lambda formals rewritten-actuals rewritten-body)

4/9

slide-11
SLIDE 11

(rewrite-augmented-term-rec aterm ; augmented term alist hyps geneqv thints runes ctx state) (generalize-to-lambda formals rewritten-actuals rewritten-body) (trace$ (apt::rewrite-augmented-term-rec :entry (cons traced-fn (take 2 arglist)) :exit (car (cadr values))) (apt::generalize-to-lambda :entry (cons ’generalize-to-lambda arglist) :exit (cons ’generalize-to-lambda values)))

4/9

slide-12
SLIDE 12

Recall: (defun g (u) (let* ((temp (f2 u)) (v temp)) (app3 u v 17)))

5/9

slide-13
SLIDE 13

Recall: (defun g (u) (let* ((temp (f2 u)) (v temp)) (app3 u v 17))) 1> (APT::REWRITE-AUGMENTED-TERM-REC ((LAMBDA (TEMP U) ((LAMBDA (V U) (APP3 U V ’17)) TEMP U)) (F2 U) U) NIL) .... <1 ((LAMBDA (TEMP U) ((LAMBDA (V U) (BINARY-APPEND U V)) TEMP U)) (F1 U) U)

5/9

slide-14
SLIDE 14

ACL2 !>(untranslate ’((LAMBDA (TEMP U) ((LAMBDA (V U) (BINARY-APPEND U V)) TEMP U)) (F1 U) U) nil (w state)) (LET* ((TEMP (F1 U)) (V TEMP)) (APPEND U V)) ACL2 !>

6/9

slide-15
SLIDE 15

1> (APT::REWRITE-AUGMENTED-TERM-REC ((LAMBDA (TEMP U) ((LAMBDA (V U) (APP3 U V ’17)) (F2 U) U) NIL) 2> (APT::REWRITE-AUGMENTED-TERM-REC ((LAMBDA (V U) (APP3 U V ’17)) TEMP U) ((TEMP F1 U) (U . U))) 3> (APT::REWRITE-AUGMENTED-TERM-REC (APP3 U V ’17) ((V F1 U) (U . U))) ... <3 (BINARY-APPEND U (F1 U)) <2 ((LAMBDA (V U) (BINARY-APPEND U V)) (F1 U) U)

7/9

slide-16
SLIDE 16

2> (APT::REWRITE-AUGMENTED-TERM-REC ((LAMBDA (V U) (APP3 U V ’17)) TEMP U) ((TEMP . (F1 U)) (U . U))) 3> (APT::REWRITE-AUGMENTED-TERM-REC (APP3 U V ’17) ((V F1 U) (U . U))) <3 (BINARY-APPEND U (F1 U)) 3> (GENERALIZE-TO-LAMBDA (V U) ((F1 U) U) (BINARY-APPEND U (F1 U))) <3 (GENERALIZE-TO-LAMBDA ((LAMBDA (V U) (BINARY-APPEND U V)) (F1 U) U)) ; (let ((v (f1 u))) (append u v)) <2 ((LAMBDA (V U) (BINARY-APPEND U V)) (F1 U) U)

8/9

slide-17
SLIDE 17

CONCLUSION

An old lesson but a good one....

9/9

slide-18
SLIDE 18

CONCLUSION

An old lesson but a good one.... If an approach is problematic, try another approach!

9/9

slide-19
SLIDE 19

CONCLUSION

An old lesson but a good one.... If an approach is problematic, try another approach! DUH?

9/9

slide-20
SLIDE 20

CONCLUSION

An old lesson but a good one.... If an approach is problematic, try another approach! DUH? If an approach (like trying to use directed-untranslate to reconstruct LET forms) is problematic, try another approach (like orchestrating calls to the rewriter that support such reconstruction)!

9/9