#lang racket ;;; dds/generic ;;; Provides the definition of several generic interfaces for discrete ;;; dynamical systems. (require racket/generic) (provide ;; Generics gen:dds ;; Functions (contract-out [dds-step-one (-> dds? any/c (set/c any/c))] [dds-step (-> dds? (set/c any/c) (set/c any/c))]) ;; Predicates (contract-out [dds? (-> any/c boolean?)])) ;;; Given a dds and a set of starting states, produce the set of ;;; states reachable in one step. This is a fallback for dds-step. (define (fallback-dds-step dds ss) (apply set-union (for/list ([s ss]) (dds-step-one dds s)))) ;;; A discrete dynamical system. (define-generics dds ;; Given a dds and a state, produce the next states of the dds. (dds-step-one dds state) ;; Given a dds and a set of starting states, produce the set of ;; states reachable in one step. This method falls back to running ;; dds-step-one for all states. (dds-step dds states) #:defined-predicate dds-implements? #:fallbacks [(define dds-step fallback-dds-step)])