Type update-function-form->update-function.

This commit is contained in:
Sergiu Ivanov 2022-05-03 00:37:13 +02:00
parent b97bbfd972
commit 320ae55456
2 changed files with 26 additions and 12 deletions

View file

@ -16,6 +16,7 @@
make-01-domains make-01-network update
UpdateFunctionForm (struct-out network-form) NetworkForm
update-function-form->update-function
)
(define-type (State a) (VariableMapping a))
@ -123,6 +124,16 @@
[domains : (DomainMapping a)])
#:transparent
#:type-name NetworkForm)
(: update-function-form->update-function (-> UpdateFunctionForm (UpdateFunction Any)))
(define (update-function-form->update-function form)
(λ (s) (eval1-with s form)))
(module+ test
(test-case "update-function-form->update-function"
(define s (hash 'x #t 'y #f))
(define f (update-function-form->update-function '(and x y)))
(check-equal? (f s) #f)))
)
(require 'typed)
@ -139,8 +150,7 @@
[struct dynamics ([network network?]
[mode mode?])])
;; Functions
(contract-out [update-function-form->update-function (-> update-function-form? update-function/c)]
[network-form->network (-> network-form? network?)]
(contract-out [network-form->network (-> network-form? network?)]
[make-boolean-network-form (-> variable-mapping? network-form?)]
[forms->boolean-network (-> variable-mapping? network?)]
[list-syntactic-interactions (-> network-form? variable? (listof variable?))]
@ -289,16 +299,6 @@
(define update-function-form? any/c)
;;; Build an update function from an update function form.
(define (update-function-form->update-function form)
(λ (s) (eval1-with s form)))
(module+ test
(test-case "update-function-form->update-function"
(define s (hash 'x #t 'y #f))
(define f (update-function-form->update-function '(and x y)))
(check-equal? (f s) #f)))
;;; Build a network from a network form.
(define (network-form->network nf)
(network

View file

@ -232,6 +232,20 @@ The type of instances of @racket[network-form].
(hash 'a '(#f #t) 'b '(#f #t)))
]}
@defproc[(update-function-form->update-function [func UpdateFunctionForm])
(UpdateFunction Any)]{
Builds an update function from an update function form.
@ex[
(define and-from-form (update-function-form->update-function '(and x y)))
(and-from-form (hash 'x #f 'y #f))
(and-from-form (hash 'x #f 'y #t))
(and-from-form (hash 'x #t 'y #f))
(and-from-form (hash 'x #t 'y #t))
]}
@section{Inferring interaction graphs}
This section provides inference of both unsigned and signed interaction graphs.