From c8e7d3733c3d5a6fa4e54da2c9f8ac95afce8160 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Mon, 12 Oct 2020 22:40:03 +0200 Subject: [PATCH] networks: Add sbf/state?. --- networks.rkt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/networks.rkt b/networks.rkt index fde16b8..0fc6f5a 100644 --- a/networks.rkt +++ b/networks.rkt @@ -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)