Liking cljdoc? Tell your friends :D

loco.automata


catclj

(cat A1 A2)

Takes two automata A1 and A2, and returns a new automaton that accepts an input S iff there exists two strings S1 and S2, such that a1 accepts S1, a2 accepts S2, and S1 + S2 = S.

Takes two automata A1 and A2, and returns a new automaton that
accepts an input S iff there exists two strings S1 and S2, such that
a1 accepts S1, a2 accepts S2, and S1 + S2 = S.
raw docstring

check-stateclj

(check-state all-states state)

intersectionclj

(intersection A1 A2)

Takes two automata A1 and A2, and returns a new automaton that accepts an input iff both A1 and A2 would accept it.

Takes two automata A1 and A2, and returns a new automaton that
accepts an input iff both A1 and A2 would accept it.
raw docstring

make-automatonclj

(make-automaton all-states transitions initial-state final-states)

Creates a Choco FiniteAutomaton object to be used in loco constraints. Takes as arguments:

  • A list of all the states
  • A list of all the transitions, in the form of vectors of [src dest input]
  • The initial state
  • A list of the final / accepting states Note that in Loco, all inputs to the state machine must be integers.
Creates a Choco FiniteAutomaton object to be used in loco constraints.
Takes as arguments:
- A list of all the states
- A list of all the transitions, in the form of vectors of [src dest input]
- The initial state
- A list of the final / accepting states
Note that in Loco, all inputs to the state machine must be integers.
raw docstring

map->automatonclj

(map->automaton m initial-state final-states)

A more idiomatic way to create automaton objects. Takes a map of {:state {<input> :new-state ...} ...}, as well as the initial state and final states.

A more idiomatic way to create automaton objects.
Takes a map of
{:state {<input> :new-state
         ...}
 ...},
as well as the initial state and final states.
raw docstring

minimize!clj

(minimize! a)
(minimize! a algorithm)

Mutates an automaton to have the minimal number of states necessary. Optionally specify what algorithm to use:

  • :hopcroft (O(n log n) algorithm) (default)
  • :huffman (O(n^2) algorithm)
  • :brzozowski (O(2^n) algorithm) If the input automaton is non-deterministic, minimize! will first have to "determinize" it (i.e. ensure only one transition per input character per state) which is an exponential-complexity operation.
Mutates an automaton to have the minimal number of states necessary.
Optionally specify what algorithm to use:
- :hopcroft (O(n log n) algorithm) (default)
- :huffman (O(n^2) algorithm)
- :brzozowski (O(2^n) algorithm)
If the input automaton is non-deterministic, minimize! will first
have to "determinize" it (i.e. ensure only one transition per input
character per state) which is an exponential-complexity operation.
raw docstring

runclj

(run a input)

Good for testing state machines you've built before passing them to the constraint solver. Runs the automaton on an "input" of a collection of integers, and returns a boolean (true if the state machine parses the input and ends at a final state).

Good for testing state machines you've built before passing them to
the constraint solver. Runs the automaton on an "input" of a
collection of integers, and returns a boolean (true if the state
machine parses the input and ends at a final state).
raw docstring

string->automatonclj

(string->automaton s)

Takes a regular expression that parses a sequence of integers instead of characters. It has the following syntax:

  • Any digit (0-9) parses that number.
  • An integer within angle-brackets (<12>) parses that integer. (careful, "12" without angle brackets parses 1, then 2.)
  • Special characters like ()[]|+*? work as expected.
  • Using letters, whitespace, or other non-digit non-special characters has unsupported, unintuitive behavior, and it is recommended that you avoid them.
Takes a regular expression that parses a sequence of integers instead of characters.
It has the following syntax:
- Any digit (0-9) parses that number.
- An integer within angle-brackets (<12>) parses that integer.
(careful, "12" without angle brackets parses 1, then 2.)
- Special characters like ()[]|+*? work as expected.
- Using letters, whitespace, or other non-digit non-special characters has unsupported,
unintuitive behavior, and it is recommended that you avoid them.
raw docstring

unionclj

(union A1 A2)

Takes two automata A1 and A2, and returns a new automaton that accepts an input iff A1 or A2 would accept it.

Takes two automata A1 and A2, and returns a new automaton that
accepts an input iff A1 or A2 would accept it.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close