Add sbn?.
This commit is contained in:
parent
ab56b64d38
commit
738ad858ae
2 changed files with 27 additions and 1 deletions
|
@ -286,6 +286,21 @@ a @racket[TBF/State].
|
|||
|
||||
}
|
||||
|
||||
@defproc[(sbn? [tbn TBN]) Boolean]{
|
||||
|
||||
A SBN is a @racket[TBN] in which all @racket[TBF/State]s satisfy
|
||||
@racket[sbf/state?].
|
||||
|
||||
All functions in @racket[tbn] must only reference variables appearing
|
||||
in the network. This function does not check this condition.
|
||||
|
||||
@ex[
|
||||
(let ([f1 (tbf/state (hash 'a -1 'b 1) 0)]
|
||||
[f2 (tbf/state (hash 'a -1 'b 1) 1)])
|
||||
(values (sbn? (hash 'a f1 'b f1))
|
||||
(sbn? (hash 'a f1 'b f2))))
|
||||
]}
|
||||
|
||||
@section{Miscellaneous utilities}
|
||||
|
||||
@defproc[(group-truth-table-by-nai [tt (Listof (Listof Integer))])
|
||||
|
|
13
tbn.rkt
13
tbn.rkt
|
@ -35,7 +35,7 @@
|
|||
|
||||
group-truth-table-by-nai
|
||||
|
||||
TBN
|
||||
TBN sbn?
|
||||
)
|
||||
|
||||
(: apply-tbf-to-state (-> TBF (State (U Zero One)) (U Zero One)))
|
||||
|
@ -321,6 +321,17 @@
|
|||
((1 1 1 0))))))
|
||||
|
||||
(define-type TBN (HashTable Variable TBF/State))
|
||||
|
||||
(: sbn? (-> TBN Boolean))
|
||||
(define (sbn? tbn) (andmap sbf/state? (hash-values tbn)))
|
||||
|
||||
(module+ test
|
||||
(test-case "sbn?"
|
||||
(define f1 (tbf/state (hash 'a -1 'b 1) 0))
|
||||
(define f2 (tbf/state (hash 'a -1 'b 1) 1))
|
||||
(check-true (sbn? (hash 'a f1 'b f1)))
|
||||
(check-false (sbn? (hash 'a f1 'b f2))))
|
||||
)
|
||||
)
|
||||
|
||||
(module+ test
|
||||
|
|
Loading…
Reference in a new issue