diff --git a/networks.rkt b/networks.rkt index 42c0d70..9cbd464 100644 --- a/networks.rkt +++ b/networks.rkt @@ -49,6 +49,8 @@ tabulate-network tabulate-network+headers table+vars->network table->network table+headers->network + + random-function/state random-boolean-function/state ) (define-type (State a) (VariableMapping a)) @@ -1064,6 +1066,17 @@ (define f (random-function/state doms '(e f))) (check-equal? (tabulate-state+headers f doms) '((a b f1) (1 3 e) (1 4 e) (2 3 f) (2 4 e))))) + + (: random-boolean-function/state (-> (Listof Variable) (-> (State Boolean) Boolean))) + (define (random-boolean-function/state args) + (random-function/state (make-boolean-domains args) '(#f #t))) + + (module+ test + (test-case "random-boolean-function/state" + (random-seed 1) + (define f (random-boolean-function/state '(x1 x2))) + (check-equal? (tabulate-state+headers/boolean f '(x1 x2)) + '((x1 x2 f1) (#f #f #f) (#f #t #f) (#t #f #t) (#t #t #f))))) ) (require 'typed) diff --git a/scribblings/networks.scrbl b/scribblings/networks.scrbl index 158001b..a4019ac 100644 --- a/scribblings/networks.scrbl +++ b/scribblings/networks.scrbl @@ -906,6 +906,16 @@ by @racket[arg-domains] and producing values in @racket[func-domain]. (tabulate-state+headers f doms)) ]} +@defproc[(random-boolean-function/state [args (Listof Variable)]) + (-> (State a) a)]{ + +Generates a random Boolean function accepting states over the +variables in @racket[args]. + +@ex[ +(tabulate-state+headers/boolean (random-boolean-function/state '(a b)) '(a b)) +]} + @section{TBF/TBN and SBF/SBN} This section defines threshold Boolean functions (TBF) and networks (TBN), as