(module inference-environments mzscheme
(provide (all-defined))
(define-values (struct:inference-environment
inference-environment-constructor
inference-environment?
inference-environment-field-ref
set-inference-environment-field!)
(make-struct-type 'inference-environment #f 12 0))
(define inference-environment-data-index
(make-struct-field-accessor
inference-environment-field-ref 0 'data-index))
(define set-inference-environment-data-index!
(make-struct-field-mutator
set-inference-environment-field! 0 'data-index))
(define inference-environment-goal-index
(make-struct-field-accessor
inference-environment-field-ref 1 'goal-index))
(define set-inference-environment-goal-index!
(make-struct-field-mutator
set-inference-environment-field! 1 'goal-index))
(define inference-environment-rule-nodes
(make-struct-field-accessor
inference-environment-field-ref 2 'rule-nodes))
(define set-inference-environment-rule-nodes!
(make-struct-field-mutator
set-inference-environment-field! 2 'rule-nodes))
(define inference-environment-exit
(make-struct-field-accessor
inference-environment-field-ref 3 'exit))
(define set-inference-environment-exit!
(make-struct-field-mutator
set-inference-environment-field! 3 'exit))
(define inference-environment-next-assertion-id
(make-struct-field-accessor
inference-environment-field-ref 4 'next-assertion-id))
(define set-inference-environment-next-assertion-id!
(make-struct-field-mutator
set-inference-environment-field! 4 'next-assertion-id))
(define inference-environment-assertion-index
(make-struct-field-accessor
inference-environment-field-ref 5 'assertion-index))
(define set-inference-environment-assertion-index!
(make-struct-field-mutator
set-inference-environment-field! 5 'assertion-index))
(define inference-environment-trace
(make-struct-field-accessor
inference-environment-field-ref 6 'trace))
(define set-inference-environment-trace!
(make-struct-field-mutator
set-inference-environment-field! 6 'trace))
(define inference-environment-agenda
(make-struct-field-accessor
inference-environment-field-ref 7 'agenda))
(define set-inference-environment-agenda!
(make-struct-field-mutator
set-inference-environment-field! 7 'agenda))
(define inference-environment-rule
(make-struct-field-accessor
inference-environment-field-ref 8 'rule))
(define set-inference-environment-rule!
(make-struct-field-mutator
set-inference-environment-field! 8 'rule))
(define inference-environment-strategy
(make-struct-field-accessor
inference-environment-field-ref 9 'strategy))
(define set-inference-environment-strategy!
(make-struct-field-mutator
set-inference-environment-field! 9 'strategy))
(define inference-environment-parent
(make-struct-field-accessor
inference-environment-field-ref 10 'parent))
(define set-inference-environment-parent!
(make-struct-field-mutator
set-inference-environment-field! 10 'parent))
(define inference-environment-rules-fired
(make-struct-field-accessor
inference-environment-field-ref 11 'rules-fired))
(define set-inference-environment-rules-fired!
(make-struct-field-mutator
set-inference-environment-field! 11 'rules-fired))
(define make-inference-environment
(case-lambda
((parent)
(inference-environment-constructor
(make-hash-table) (make-hash-table) '() #f 1 (make-hash-table) #f '() #f 'depth parent 0 ))
(()
(make-inference-environment #f))))
(define default-inference-environment
(make-inference-environment))
(define current-inference-environment
(make-parameter
default-inference-environment
(lambda (x)
(when (not (inference-environment? x))
(raise-type-error 'current-inference-environment
"inference-environment" x))
x)))
(define current-inference-data-index
(case-lambda
(()
(inference-environment-data-index
(current-inference-environment)))
((data-index)
(set-inference-environment-data-index!
(current-inference-environment) data-index))))
(define current-inference-goal-index
(case-lambda
(()
(inference-environment-goal-index
(current-inference-environment)))
((goal-index)
(set-inference-environment-goal-index!
(current-inference-environment) goal-index))))
(define current-inference-rule-nodes
(case-lambda
(()
(inference-environment-rule-nodes
(current-inference-environment)))
((rule-nodes)
(set-inference-environment-rule-nodes!
(current-inference-environment) rule-nodes))))
(define current-inference-exit
(case-lambda
(()
(inference-environment-exit
(current-inference-environment)))
((exit)
(set-inference-environment-exit!
(current-inference-environment) exit))))
(define current-inference-next-assertion-id
(case-lambda
(()
(inference-environment-next-assertion-id
(current-inference-environment)))
((next-assertion-id)
(set-inference-environment-next-assertion-id!
(current-inference-environment) next-assertion-id))))
(define current-inference-assertion-index
(case-lambda
(()
(inference-environment-assertion-index
(current-inference-environment)))
((assertion-index)
(set-inference-environment-assertion-index!
(current-inference-environment) assertion-index))))
(define current-inference-trace
(case-lambda
(()
(inference-environment-trace
(current-inference-environment)))
((trace)
(set-inference-environment-trace!
(current-inference-environment) trace))))
(define current-inference-agenda
(case-lambda
(()
(inference-environment-agenda
(current-inference-environment)))
((agenda)
(set-inference-environment-agenda!
(current-inference-environment) agenda))))
(define current-inference-rule
(case-lambda
(()
(inference-environment-rule
(current-inference-environment)))
((rule)
(set-inference-environment-rule!
(current-inference-environment) rule))))
(define current-inference-strategy
(case-lambda
(()
(inference-environment-strategy
(current-inference-environment)))
((strategy)
(set-inference-environment-strategy!
(current-inference-environment) strategy))))
(define current-inference-parent
(case-lambda
(()
(inference-environment-parent
(current-inference-environment)))
((parent)
(set-inference-environment-parent!
(current-inference-environment) parent))))
(define current-inference-rules-fired
(case-lambda
(()
(inference-environment-rules-fired
(current-inference-environment)))
((rules-fired)
(set-inference-environment-rules-fired!
(current-inference-environment) rules-fired))))
(define-syntax with-inference-environment
(syntax-rules ()
((with-inference-environment inference-environment
body ...)
(parameterize ((current-inference-environment
inference-environment))
body ...))))
(define-syntax with-new-inference-environment
(syntax-rules ()
((with-new-inference-environment
body ...)
(parameterize ((current-inference-environment
(make-inference-environment)))
body ...))))
(define-syntax with-new-child-inference-environment
(syntax-rules ()
((with-new-child-inference-environment
body ...)
(parameterize ((current-inference-environment
(make-inference-environment
(current-inference-environment))))
body ...))))
)