Executables

Vcsn comes with a set of programs that you use to manipulate automata, expressions, etc.

It is much less powerful than writing Python programs, however it comes handy occasionally to process a batch of files, or for a quick experiment.

Synopsis

vcsn COMMAND [OPTION...] ARG...

Run vcsn tafkit --help for details on the interface:

In [1]:
!vcsn tafkit --help
usage: /Users/akim/src/lrde/2/_build/36s/libexec/.libs/vcsn-tafkit COMMAND [OPTIONS...] [ARGS...]

General Options:
  -h, --help       display this help message and exit successfully
  -v, --version    display version information and exit successfully
  -c, --commands   display the supported commands and exit successfully

Available COMMANDs:
  accessible add are-equivalent are-isomorphic cat coaccessible
  complement complete compose constant-term conjunction derivation
  derived-term de-bruijn divkbaseb determinize difference divkbaseb
  double-ring eliminate-state enumerate evaluate expand inductive
  infiltrate is-ambiguous is-complete is-deterministic is-empty
  is-eps-acyclic is-normalized is-proper is-standard is-trim
  is-useless is-valid ladybird lweight lift minimize multiply proper
  quotkbaseb rweight shortest shuffle split standard star
  star-normal-form thompson to-expression transpose trim u union
  universal

Input/Output:
  -C CONTEXT    the context to use
                'lal, b', 'law, q', 'lan(abc), zmin', etc.
  -A            input is an automaton
  -E            input is a rational expression
  -P            input is a polynomial
  -W            input is a weight
  -e STRING     input is STRING
  -f FILE       input is FILE
  -I FORMAT     input format (dot, efsm, fado, text)
  -O FORMAT     output format
                (dot, efsm, grail, info, list, null, text, tikz, utf8)
  -o FILE       save output into FILE
  -q            discard any output

Input/Output Formats (for Automata, Expressions, Polynomials, Weights):
  dot    A     GraphViz's Dot language
  efsm   A     Extended FSM format for OpenFST: use efstcompile
  fado   A     FAdo's format
  grail  A     Grail's format
  info   AE    facts about the result (size, etc.)
  latex   E    display as a LaTeX formula
  list     P   display one monomial per line
  null   AEPW  no output at all (e.g., for benchmarks)
  text    EPW  usual concrete syntax in ASCII
  tikz   A     LaTeX source for TikZ
  utf8    EPW  usual concrete syntax in UTF-8

Examples:
  $ vcsn thompson -Ee '[ab]*a[ab]{3}' |
      vcsn proper |
      vcsn determinize |
      vcsn evaluate 'abba'

  $ vcsn thompson -Ee '[ab]*a[ab]{3}' |
      vcsn proper -f - |
      vcsn determinize -f - |
      vcsn evaluate -f - 'abba'

  $ vcsn derived-term -C 'lat<lan, lan>, q' -Ee 'a*|b*' |
      vcsn shortest 10

Examples

To generate the standard automaton of [ab]*c and save it in abc.gv:

In [2]:
!vcsn standard -Ee '[ab]*c' -o abc.gv
In [3]:
import vcsn
vcsn.automaton(filename='abc.gv')
Out[3]:
%3 I0 0 0 I0->0 F3 1 1 0->1 a 2 2 0->2 b 3 3 0->3 c 1->1 a 1->2 b 1->3 c 2->1 a 2->2 b 2->3 c 3->F3

To generate a Thompson automaton, make it proper, minimize it and extract a rational expression from it:

In [4]:
!vcsn thompson -Ee '[ab]*c' | vcsn proper | vcsn determinize | vcsn to-expression
c+aa*c+(b+aa*b)(b+aa*b)*(c+aa*c)

Likewise, but with an additional minimization step:

In [5]:
!vcsn thompson -Ee '[ab]*c' | vcsn proper | vcsn determinize | vcsn minimize | vcsn to-expression
(a+b)*c

The Python equivalent of these last runs are:

In [6]:
vcsn.B.expression('[ab]*c').thompson().proper().determinize().expression()
Out[6]:
$c + a \, {a}^{*} \, c + \left(b + a \, {a}^{*} \, b\right) \, \left(b + a \, {a}^{*} \, b\right)^{*} \, \left(c + a \, {a}^{*} \, c\right)$
In [7]:
vcsn.B.expression('[ab]*c').thompson().proper().determinize().minimize().expression()
Out[7]:
$\left(a + b\right)^{*} \, c$