Working on interactive tactic
Currently, due to multiple uses of eval, can't get this to work. Need to redesign/reorganize tactics
This commit is contained in:
parent
2609cf0b08
commit
678607afa0
|
@ -949,6 +949,7 @@
|
||||||
only-in
|
only-in
|
||||||
all-defined-out
|
all-defined-out
|
||||||
rename-in
|
rename-in
|
||||||
|
submod
|
||||||
#%module-begin
|
#%module-begin
|
||||||
begin
|
begin
|
||||||
(rename-out
|
(rename-out
|
||||||
|
@ -975,6 +976,7 @@
|
||||||
;; DYI syntax extension
|
;; DYI syntax extension
|
||||||
define-syntax
|
define-syntax
|
||||||
begin-for-syntax
|
begin-for-syntax
|
||||||
|
define-for-syntax
|
||||||
(for-syntax (all-from-out syntax/parse))
|
(for-syntax (all-from-out syntax/parse))
|
||||||
syntax-case
|
syntax-case
|
||||||
syntax-rules
|
syntax-rules
|
||||||
|
|
|
@ -118,7 +118,6 @@
|
||||||
(syntax-local-eval
|
(syntax-local-eval
|
||||||
;; Thread proof state through tactic calls, and eval
|
;; Thread proof state through tactic calls, and eval
|
||||||
;; at compile-time.
|
;; at compile-time.
|
||||||
|
|
||||||
#`(let* ([ps (new-proof-state #'#,t)]
|
#`(let* ([ps (new-proof-state #'#,t)]
|
||||||
[ps (f #'args* ... ps)]
|
[ps (f #'args* ... ps)]
|
||||||
...)
|
...)
|
||||||
|
@ -143,9 +142,8 @@
|
||||||
(syntax-case syn ()
|
(syntax-case syn ()
|
||||||
[(_ (name args ... ps) body ...)
|
[(_ (name args ... ps) body ...)
|
||||||
(quasisyntax/loc syn
|
(quasisyntax/loc syn
|
||||||
(begin-for-syntax
|
(define-for-syntax (name args ... ps)
|
||||||
(define (name args ... ps)
|
body ...))]
|
||||||
body ...)))]
|
|
||||||
[(_ name function)
|
[(_ name function)
|
||||||
(raise-syntax-error "Syntax not yet defined")]))
|
(raise-syntax-error "Syntax not yet defined")]))
|
||||||
|
|
||||||
|
@ -202,7 +200,37 @@
|
||||||
[current-goal (proof-state-original-goal ps)]
|
[current-goal (proof-state-original-goal ps)]
|
||||||
[current-proof empty-proof]))
|
[current-proof empty-proof]))
|
||||||
|
|
||||||
(define-tactic (print ps) (print-proof-state ps) ps)
|
(define-tactic (show ps) (print-proof-state ps) ps)
|
||||||
|
|
||||||
|
(begin-for-syntax
|
||||||
|
(define-namespace-anchor a))
|
||||||
|
|
||||||
|
;; Interactive you say? Sure whatevs, DIY
|
||||||
|
(define-tactic (interactive ps)
|
||||||
|
(printf "Starting interactive tactic session:~n")
|
||||||
|
(let loop ([ps ps] [cmds '()])
|
||||||
|
(show ps)
|
||||||
|
(let ([cmd (read-syntax)])
|
||||||
|
(syntax-case cmd (quit)
|
||||||
|
[(quit)
|
||||||
|
(begin
|
||||||
|
(printf "Your tactic script:~n")
|
||||||
|
(pretty-print cmds)
|
||||||
|
(newline)
|
||||||
|
ps)]
|
||||||
|
;; TODO: eval is bad. Maybe use (read-eval-print-loop) and its
|
||||||
|
;; TODO: config parameters.
|
||||||
|
[(tactic arg ...)
|
||||||
|
(with-handlers (#;[exn:fail:syntax?
|
||||||
|
(lambda (e)
|
||||||
|
(printf "~a is not a tactic.~n"
|
||||||
|
(syntax->datum #'tactic))
|
||||||
|
(loop ps cmds))])
|
||||||
|
(displayln (syntax-local-eval #'(begin tactic)))
|
||||||
|
(loop (apply (eval-syntax #'tactic
|
||||||
|
(namespace-anchor->namespace a))
|
||||||
|
(append (syntax->list #'(arg ...)) (list ps)))
|
||||||
|
(cons cmd cmds)))]))))
|
||||||
|
|
||||||
;; TODO:
|
;; TODO:
|
||||||
;; Open interactive REPL for tactic DSL; exit with QED command, which
|
;; Open interactive REPL for tactic DSL; exit with QED command, which
|
||||||
|
@ -218,13 +246,16 @@
|
||||||
(define-theorem meow1 (forall (x : bool) bool))
|
(define-theorem meow1 (forall (x : bool) bool))
|
||||||
(proof
|
(proof
|
||||||
(obvious)
|
(obvious)
|
||||||
(print))
|
(show))
|
||||||
(define-theorem meow2 (forall (x : bool) bool))
|
(define-theorem meow2 (forall (x : bool) bool))
|
||||||
(proof
|
(proof
|
||||||
(intro x)
|
(intro x)
|
||||||
(restart)
|
(restart)
|
||||||
(intro x)
|
(intro x)
|
||||||
(by-assumption))
|
(by-assumption))
|
||||||
|
;(define-theorem meow3 (forall (x : bool) bool))
|
||||||
|
;(proof
|
||||||
|
; (interactive))
|
||||||
;; TODO: Add check-cur-equal? for unit testing?
|
;; TODO: Add check-cur-equal? for unit testing?
|
||||||
#;(check-pred (curry cur-equal? '(lambda (x : bool) x)))
|
#;(check-pred (curry cur-equal? '(lambda (x : bool) x)))
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user