Module: Codes (codes)

Code theory module

New in version 1.0.

Classes

CodeProperty

class CodeProperty(name, alph)[source]
See: K. Dudzinski and s. Konstantinidis: Formal descriptions of code properties: decidability, complexity,

implementation. International Journal of Foundations of Computer Science 23:1 (2012), 67–85.

Variables

sigma – the alphabet

abstract maximalP(aut, U=None)[source]

Tests if the language is maximal w.r.t. the property

Parameters
  • U (DFA|NFA) – Universe of permitted words (sigma^* as default)

  • aut (DFA|NFA) – the automaton

Return type

bool

abstract notMaximalW(aut, U=None)[source]

Witness of non maximality

Parameters
  • aut (DFA|NFA) – the automaton

  • U (DFA|NFA) – Universe of permitted words (sigma^* as default)

Returns

a witness

Return type

str

abstract notSatisfiesW(aut)[source]

Return a witness of non-satisfaction of the property by the automaton language

Parameters

aut (DFA|NFA) – the automaton

Returns

word witness tuple

Return type

tuple

abstract satisfiesP(aut)[source]

Satisfaction of the property by the automaton language

Parameters

aut (NFA|DFA) – the automaton

Return type

bool

TrajProp

class TrajProp(aut, Sigma)[source]

Class of trajectoty properties

Inheritance diagram of TrajProp

Constructor

Parameters
  • aut (DFA|NFA) – regular expression over {0,1}

  • Sigma (set) – the alphabet

static trajToTransducer(traj, Sigma)[source]

Input Altering Tranducer corresponding to a Trajectory

Parameters
  • traj (NFA) – trajectory language

  • Sigma (set) – alphabet

Return type

SFT

IPTProp

class IPTProp(aut, name=None)[source]

Input Preserving Transducer Property

Inheritance diagram of IPTProp
Variables
  • Aut (SFT) – the transducer defining the property

  • sigma (set) – alphabet

Constructor :param SFT aut: Input preserving transducer

addToCode(aut, N, n=2000)[source]

Returns an NFA and a list W of up to N words of length ell, such that the NFA accepts L(aut) union W, which is an error-detecting language. ell is computed from aut

Parameters
  • aut (NFA) – the automaton

  • N (int) – the number of words to construct

  • n (int) – number of tries when needing a new word

Returns

an automaton and a list of strings

Return type

tuple

makeCode(N, ell, s, n=2000, ov_free=False)[source]

Returns an NFA and a list W of up to N words of length ell, such that the NFA accepts W, which is an error-detecting language. The alphabet to use is {0,1,…,s-1}. where s <= 10.

Parameters
  • N (int) – the number of words to construct

  • ell (int) – the codeword length

  • s (int) – the alphabet size (must be <= 10)

  • n (int) – number of tries when needing a new word

Returns

an automaton and a list of strings

Return type

tuple

makeCodeO(N, ell, s, n=2000, end=None, ov_free=False)[source]

Returns an NFA and a list W of up to N words of length ell, such that the NFA accepts W, which is an error-detecting language. The alphabet to use is {0,1,…,s-1}. where s <= 10.

Parameters
  • N (int) – the number of words to construct

  • ell (int) – the codeword length

  • s (int) – the alphabet size (must be <= 10)

  • n (int) – number of tries when needing a new word

  • end (Word) – a Word or None that should much the end of code words

  • ov_free (Boolean) – if True code words much be overlap free

Returns

an automaton and a list of strings

Return type

tuple

Note: not ov_free and end defined simultaneously Note: end should be a Word

maximalP(aut, U=None)[source]

Tests if the language is maximal w.r.t. the property

Parameters
  • aut (NFA) – the automaton

  • U (NFA) – Universe of permitted words (sigma^* as default)

Return type

bool

notMaxStatW(aut, ell, n=2000, ov_free=False)[source]

Returns a word of length ell to add into aut or None; simpler version of function nonMaxStatFEpsW

Parameters
  • aut (NFA) – the automaton

  • ell (int) – the length of the words in aut

  • n (int) – number of words to try

Returns

a string or None

Return type

str

notMaximalW(aut, U=None)[source]

Tests if the language is maximal w.r.t. the property

Parameters
  • aut (DFA|NFA) – the automaton

  • U (DFA|NFA) – Universe of permitted words (sigma^* as default)

Return type

bool

Raises

PropertyNotSatisfied – if not satisfied

notSatisfiesW(aut)[source]

Return a witness of non-satisfaction of the property by the automaton language

Parameters

aut (DFA|NFA) – the automaton

Returns

word witness pair

Return type

tuple

satisfiesP(aut)[source]

Satisfaction of the property by the automaton language

Parameters

aut (DFA|NFA) – the automaton

Return type

bool

IATProp

class IATProp(aut, name=None)[source]

Input Altering Transducer Property

Inheritance diagram of IATProp

Constructor :param SFT aut: Input preserving transducer

notSatisfiesW(aut)[source]

Return a witness of non-satisfaction of the property by the automaton language

Parameters

aut (DFA|NFA) – the automaton

Returns

word witness pair

Return type

tuple

PrefixProp

class PrefixProp(t)[source]

Prefix Property

Inheritance diagram of PrefixProp

Constructor

Parameters
  • aut (DFA|NFA) – regular expression over {0,1}

  • Sigma (set) – the alphabet

satisfiesPrefixP(aut)[source]

Satisfaction of property by the automaton language: faster than satisfiesP

Parameters

aut (DFA|NFA) – the automaton

Return type

bool

ErrDetectProp

ErrDetectProp

alias of FAdo.codes.IPTProp

ErrCorrectProp

class ErrCorrectProp(t)[source]

Error Correcting Property

Inheritance diagram of ErrCorrectProp

Constructor :param SFT aut: Input preserving transducer

notMaximalW(aut, U=None)[source]

Tests if the language is maximal w.r.t. the property

Parameters
  • aut (DFA|NFA) – the automaton

  • U (DFA|NFA) – Universe of permitted words (sigma^* as default)

Return type

bool

notSatisfiesW(aut)[source]

Satisfaction of the code property by the automaton language

Parameters

aut (DFA|NFA) – the automaton

Return type

tuple

satisfiesP(aut)[source]

Satisfaction of the property by the automaton language

See also

s. Konstantinidis: Transducers and the Properties of Error-Detection, Error-Correction and Finite-Delay Decodability. Journal Of Universal Computer Science 8 (2002), 278-291.

Parameters

aut (DFA|NFA) – the automaton

Return type

bool

Functions

buildTrajPropS

buildTrajPropS(regex, sigma)[source]

Builds a TrajProp from a string RegExp

Parameters
  • regex (str) – the regular expression

  • sigma (set) – alphabet

Return type

TrajProp

buildIATPropF

buildIATPropF(fname)[source]

Builds a IATProp from a FAdo SFT file

Parameters

fname (str) – file name

Return type

IATProp

buildIPTPropF

buildIPTPropF(fname)[source]

Builds a IPTProp from a FAdo SFT file

Parameters

fname (str) – file name

Return type

IPTProp

buildIATPropS

buildIATPropS(s)[source]

Builds a IATProp from a FAdo SFT string

Parameters

s (str) – string containing SFT

Return type

IATProp

buildIPTPropS

buildIPTPropS(s)[source]

Builds a IPTProp from a FAdo SFT string

Parameters

s (str) – file name

Return type

IPTProp

buildErrorDetectPropF

buildErrorCorrectPropF

buildErrorDetectPropF(fname)[source]

Builds an Error Detecting Property

Parameters

fname (str) – file name

Return type

ErrDetectProp

buildErrorCorrectPropF

buildErrorCorrectPropF(fname)[source]

Builds an Error Correcting Property

Parameters

fname (str) – file name

Return type

ErrCorrectProp

buildErrorDetectPropS

buildErrorDetectPropS(s)[source]

Builds an Error Detecting Property from string

Parameters

s (str) – transducer string

Return type

ErrDetectProp

buildErrorCorrectPropS

buildErrorCorrectPropS(s)[source]

Builds an Error Correcting Property from string

Parameters

s (str) – transducer string

Return type

ErrCorrectProp

buildPrefixProperty

buildPrefixProperty(alphabet)[source]

Builds a Prefix Code Property

Parameters

alphabet (set) – alphabet

Return type

PrefixProp

editDistanceW

editDistanceW(auto)[source]

Compute the edit distance of a given regular language accepted by the NFA via Input-altering transducer.

Parameters

auto (NFA) – language recogniser

Returns

The edit distance of the given regular language plus a witness pair

Return type

tuple

Attention

language should have at least two words

See also

Lila Kari, Stavros Konstantinidis, Steffen Kopecki, Meng Yang. An efficient algorithm for computing the edit distance of a regular language via input-altering transducers. arXiv:1406.1041 [cs.FL]

exponentialDensityP

exponentialDensityP(aut)[source]
Checks if language density is exponential

Using breadth first search (BFS)

Parameters

aut (NFA) – the representation of the language

Return type

bool

Attention

aut should not have Epsilon transitions

createInputAlteringSIDTrans

createInputAlteringSIDTrans(n, sigmaSet)[source]

Create an input-altering SID transducer based

Parameters
  • n (int) – max number of errors

  • sigmaSet (set) – alphabet

Returns

a transducer representing the SID channel

Return type

SFT