diff --git a/scribblings/tbn.scrbl b/scribblings/tbn.scrbl index a2be9d7..539579f 100644 --- a/scribblings/tbn.scrbl +++ b/scribblings/tbn.scrbl @@ -45,3 +45,28 @@ inputs of the TBF must match the number of variables in the state. (require "functions.rkt") (apply-tbf-to-state (tbf #(1 1) 1) (hash 'x1 0 'x2 1)) ]} + +@defstruct*[tbf/state ([weights (VariableMapping Real)] + [threshold Real])]{ + +A state TBF is a @racket[TBF] with named inputs. A state TBF can be +applied to states in an unambiguous ways. + +} + +@deftype[TBF/State]{ + +The type of the instances of @racket[tbf/state]. + +} + +@deftogether[(@defproc[(tbf/state-w [tbfs TBF/State]) (VariableMapping Real)] + @defproc[(tbf/state-θ [tbfs TBF/State]) Real])]{ + +Shorter synonyms for field accessors of @racket[tbf/state]. + +@ex[ +(let ([tbfs (tbf/state (hash 'a 1 'b 1) 1)]) + (values (tbf/state-w tbfs) + (tbf/state-θ tbfs))) +]} diff --git a/tbn.rkt b/tbn.rkt index 2927eb0..34f9625 100644 --- a/tbn.rkt +++ b/tbn.rkt @@ -14,6 +14,8 @@ (provide apply-tbf-to-state + + (struct-out tbf/state) TBF/State tbf/state-w tbf/state-θ ) (: apply-tbf-to-state (-> TBF (State (U Zero One)) (U Zero One))) @@ -26,6 +28,14 @@ (define st (hash 'x1 0 'x2 1)) (define f (tbf #(1 1) 1)) (check-equal? (apply-tbf-to-state f st) 0))) + + (struct tbf/state ([weights : (VariableMapping Real)] + [threshold : Real]) + #:transparent + #:type-name TBF/State) + (define tbf/state-w tbf/state-weights) + (define tbf/state-θ tbf/state-threshold) + ) (module+ test