 (anglican.infcomp.core/reset-infcomp-addressing-scheme!)
 ;; @@
 ;; =>
-;;; {"type":"html","content":"<span class='clj-unkown'>#function[anglican.infcomp.core/reset-infcomp-addressing-scheme!$fn--26348$fn--26349]</span>","value":"#function[anglican.infcomp.core/reset-infcomp-addressing-scheme!$fn--26348$fn--26349]"}
+;;; {"type":"html","content":"<span class='clj-unkown'>#function[anglican.infcomp.core/reset-infcomp-addressing-scheme!$fn--28032$fn--28033]</span>","value":"#function[anglican.infcomp.core/reset-infcomp-addressing-scheme!$fn--28032$fn--28033]"}
 ;; <=
 
 ;; **

;; **

;; @@
(defm new-pdfa [alphabet K transition emissiondist]
  (let [alphabet (map str (seq alphabet))

        states (range K)

        edges (into {} (map (fn [state]
                              [state (into {} (map #(vector % (transition state %))
                                                   alphabet))])
                            states))

        probs (into {} (map (fn [state]
                              [state (into {} (map (fn [[symbol prob]]
                                                     [(str symbol) prob])
                                                   (:categories (emissiondist state))))])
                            states))]
    {:edges edges
     :probs probs}))

(defn pdfa-states [pdfa]
  (keys (:edges pdfa)))


;; **

;; @@
(defm new-pdfa [alphabet K transition emissiondist]
  (let [alphabet (map str (seq alphabet))

        states (range K)

        edges (into {} (map (fn [state]
                              [state (into {} (map #(vector % (transition state %))
                                                   alphabet))])
                            states))

        probs (into {} (map (fn [state]
                              [state (into {} (map (fn [[symbol prob]]
                                                     [(str symbol) prob])
                                                   (:categories (emissiondist state))))])
                            states))]
    {:edges edges
     :probs probs}))

(with-primitive-procedures [normalize]
  (defquery pdfa [observedsequence alphabet]
    (let [num-states (sample (categorical [[2 10] [3 6] [4 3] [5 1]]))
          
          emissionprior (fn [] (normalize (repeatedly (count alphabet) (fn [] (sample (gamma 1 1))))))
          emissiondist (mem (fn [state] (categorical (zipmap alphabet (emissionprior))))) ; \pi

          transitiondist (uniform-discrete 0 num-states)
