{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# _automaton_.complement\n",
"\n",
"Produce an automaton that accepts the complement of the language of the input automaton.\n",
"\n",
"Precondition:\n",
"- the labelset is free\n",
"- the weightset is $\\mathbb{B}$\n",
"- the automaton is complete\n",
"- the automaton is deterministic\n",
"\n",
"Postcondition:\n",
"- Result.is_complete()\n",
"- Result.is_deterministic()\n",
"\n",
"See also:\n",
"- [_expression_.complement](expression.complement.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Examples"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import vcsn\n",
"b = vcsn.context('lal_char(abc), b')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
"mutable_automaton, b>>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = b.expression('a+b').standard().determinize().complete()\n",
"a"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The prefix operator `~` invokes `complement()`."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
"mutable_automaton, b>>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"~a"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
"mutable_automaton, b>>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c = a.complement()\n",
"c"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$\\mathit{a} \\oplus \\mathit{b}$"
],
"text/plain": [
"a + b"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a.shortest(2)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$\\varepsilon \\oplus \\mathit{c} \\oplus \\mathit{aa} \\oplus \\mathit{ab} \\oplus \\mathit{ac} \\oplus \\mathit{ba} \\oplus \\mathit{bb} \\oplus \\mathit{bc} \\oplus \\mathit{ca} \\oplus \\mathit{cb}$"
],
"text/plain": [
"\\e + c + aa + ab + ac + ba + bb + bc + ca + cb"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c.shortest(10)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}