cnfgen.transformations.shuffle module

Shuffle(F, polarity_flips='shuffle', variables_permutation='shuffle', clauses_permutation='shuffle')

Reshuffle the given formula F

Returns a formula logically equivalent to F with the following transformations applied the following order:

  1. Polarity flips, specified as one of the following - string ‘fixed’: no flips is applied - string ‘shuffle’: each variable is subjected

    to a random flip of polarity

    • a list of -1 and +1 of length equal to the number of the variables in the formula F.
  2. Variable shuffling, specified as one of the following - string ‘fixed’: no shuffling - string ‘shuffle’: the variable order is randomly permuted - an sequence of integer which represents a permutation of [1,…,N],

    where N is the number of the variable in the formula. The i-th variable is mapped to the i-th index in the sequence.

  3. Clauses shuffling, specified as one of the following - string ‘fixed’: no shuffling - string ‘shuffle’: the clauses are randomly permuted - an sequence S of integer which represents a permutation of [0,…,M-1],

    where M is the number of the variable in the formula. The i-th clause in F is going to be at position S[i] in the new formula.

Parameters:
F : cnfgen.formula.cnf.CNF

formula to be shuffled

polarity_flips: string or iterable(int)

Specifies the flips of polarity

variables_permutation: string or iterable(int)

Specifies the permutation of the variables.

clauses_permutation: string or iterable(int)

Specifies the permutation of the clauses.