networks: Add sbf/state?.

This commit is contained in:
Sergiu Ivanov 2020-10-12 22:40:03 +02:00
parent 848d53f97a
commit c8e7d3733c

View File

@ -100,7 +100,8 @@
[update-function-form? (-> any/c boolean?)]
[network-form? (-> any/c boolean?)]
[modality? (-> any/c boolean?)]
[mode? (-> any/c boolean?)])
[mode? (-> any/c boolean?)]
[sbf/state? (-> any/c boolean?)])
;; Contracts
(contract-out [state/c contract?]
[update-function/c contract?]
@ -959,6 +960,13 @@
;;; applied to states in an unambiguous ways.
(struct tbf/state (weights threshold) #:transparent)
;;; A sign Boolean function (SBF) is a TBF whose threshold is 0.
(define sbf/state? (and/c tbf/state? (λ (tbf) (zero? (tbf/state-θ tbf)))))
(module+ test
(test-case "sbf/state?"
(check-true (sbf/state? (tbf/state #hash((a . -1) (b . 1)) 0)))))
;;; Shortcuts for acessing fields of a state/tbf.
(define tbf/state-w tbf/state-weights)
(define tbf/state-θ tbf/state-threshold)