hi
i need code for brute force Boolean satisfyability program.
plz help me i need it asap
thank u

Aia commented: (Waving hand) What you need is to turn your computer off and re-think your life! -2

Recommended Answers

All 2 Replies

hi
i need code for brute force Boolean satisfyability program.
plz help me i need it asap
thank u

hahahahahahahah


lol


thanks, man.


i needed that.

Hey man, you need to do homeworks yourself. But given that your mentioned problem is interesting NP problem,- i'll give you small pseudocode snippet:

#define OP_NOT 1
#define OP_AND 2
#define OP_OR 3
int bool_formula[6] = {OP_NOT,0,OP_AND,0,OP_OR,0};
int bit_pattern = -1;
char x1,x2,x3;
int is_formula_satisfiable = 0;
WHILE (bit_pattern <= 7 /*111 in binary*/) {
   ++bit_pattern;
   x1 = extract_first_bit(bit_pattern);
   x2 = extract_second_bit(bit_pattern);
   x3 = extract_third_bit(bit_pattern);
   substitute_x_variables_to(bool_formula);
   // such as bool formula will become =>
   // {OP_NOT,x1,OP_AND,x2,OP_OR,x3};
   is_formula_satisfiable = Evaluate_bool_formula(bool_formula);
   if (is_formula_satisfiable) {
      // this bool formula is satisfiable and there is no need to
      // analyze other combinations of x1,x2,x3
      break;
   }
}
// if after while loop variable is_formula_satisfiable == 0, then
// this bool formula is un-satisfiable or in other words -> is in-distinguishable
// from FALSE constant

Generalize this example to include support for parenthesis in bool formula and other details which you need.
Also read here-
http://en.wikipedia.org/wiki/Boolean_satisfiability_problem

Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.