Skip to content

Instantly share code, notes, and snippets.

@cartazio
Created November 19, 2010 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cartazio/706216 to your computer and use it in GitHub Desktop.
Save cartazio/706216 to your computer and use it in GitHub Desktop.
how to encode circuits in 0 1 integer programs, a sketch
how to use integer programming to encode circuits:
Given a circuit C with n boolean inputs, and assume without loss of
generality that every logic operation is unary or binary. Label each
binary or unary expression c_1 .... c_m. Let r_0 be the distinguished
clause that is the result of this boolean circuit (because an n bit
output is just a product of circuits that have 1 bit outputs.).
For a given c_i, it is of the form c_i = one of
1) = not a, which we can define via the constraint c_i - a= 0
2) = a xor b, define via not a -b + not b - a+ c_i = 1 because
not a -b + not b - a = 0 always
and so this one needs to generate new clause variables for the nots.
*and* & *or* can then be encoded in a straightforward fashion with these.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment