# expression.info(key=None)¶

A dictionary of facts about an expression.

The keys of the dictionary are:

• length, size: the number of nodes in the syntax tree
• width, atom: the number of letter occurrences
• depth: the depth of the syntax tree (the depth of $a$ is 0, not 1)
• type: the implementation type
• add, complement, etc.: the number of occurrences of these operators (+, {c}, etc.) in the expression

Arguments:

• key: if specified, return just the corresponding result.

## Examples¶

In [1]:
import vcsn
e = vcsn.Q.expression('[ab]*a[ab]')
e

Out[1]:
$\left(a + b\right)^{*} \, a \, \left(a + b\right)$
In [2]:
e.SVG()

Out[2]:
In [3]:
e.info()

Out[3]:
{'add': 2,
'atom': 5,
'complement': 0,
'compose': 0,
'conjunction': 0,
'depth': 3,
'infiltrate': 0,
'ldivide': 0,
'length': 10,
'lweight': 0,
'mul': 1,
'one': 0,
'rweight': 0,
'shuffle': 0,
'size': 10,
'star': 1,
'transposition': 0,
'tuple': 0,
'type': 'expressionset<letterset<char_letters(ab)>, q>',
'width': 5,
'zero': 0}
In [4]:
e.info('type')

Out[4]:
'expressionset<letterset<char_letters(ab)>, q>'

Note that, although the expression uses a variadic product (the . node features three children), the length corresponds to the usual definition of expressions based on binary node. Hence the tree features 9 nodes, but the length of the expression is 10. This applies to all the variadic operators.

In [5]:
e.info('length')

Out[5]:
10
In [6]:
e.info('depth')

Out[6]:
3
In [7]:
e = vcsn.Q.expression('[ab]*a[ab]{2} & [ab]*a[ab]{4}')
e

Out[7]:
$\left(a + b\right)^{*} \, a \, \left(a + b\right)^{2} \& \left(a + b\right)^{*} \, a \, \left(a + b\right)^{4}$
In [8]:
e.SVG()

Out[8]:
In [9]:
e.info()

Out[9]:
{'add': 8,
'atom': 18,
'complement': 0,
'compose': 0,
'conjunction': 1,
'depth': 4,
'infiltrate': 0,
'ldivide': 0,
'length': 37,
'lweight': 0,
'mul': 2,
'one': 0,
'rweight': 0,
'shuffle': 0,
'size': 37,
'star': 2,
'transposition': 0,
'tuple': 0,
'type': 'expressionset<letterset<char_letters(ab)>, q>',
'width': 18,
'zero': 0}
In [10]:
vcsn.Q.expression('[ab]a[ab]').info()

Out[10]:
{'add': 2,
'atom': 5,
'complement': 0,
'compose': 0,
'conjunction': 0,
'depth': 2,
'infiltrate': 0,
'ldivide': 0,
'length': 9,
'lweight': 0,
'mul': 1,
'one': 0,
'rweight': 0,
'shuffle': 0,
'size': 9,
'star': 0,
'transposition': 0,
'tuple': 0,
'type': 'expressionset<letterset<char_letters(ab)>, q>',
'width': 5,
'zero': 0}