Please do not copy-paste an existing answer.
SOLUTION :-
Assume that G = (V, E) is a graph that has
following properties :
G is having a node corresponding to
each variable xi , and there is an edge (xi,
xj ) if xi = xj is an equality
constraint. Now perform Depth First Search of G in
order to find all its connected components. For
every node xi , if it is in the p-th connected
component of G, then allocate it a mark
p.
Now for every disequality constraint xi
≠ xj , Examine to view if xi and
xj occur in distinct connected components of G. If there
is few disequality constraint xi
≠ xj such that
xi and xj occur in the same connected
component of G, then It means that the constraints are
unsatisfiable. If there is no such constraint exists, then
it means that the constraints are
satisfiable.
Correctness of the above algorithm :-
In the above problem, the equality constraints formulates an equivalence class. If all the constraints are satisfiable, then, there can be no disequality constraint xi ≠ xj such that xi and xj are in the same equivalence class, it is because such a constraint is not satisfiable, which directs towards contradiction. Thus, if all the constraints are satisfiable, then the algorithm will perform in a correct manner.
Now assume that all the constraints are not satisfiable, we claim that it can only occur if there is an disequality constaint xi ≠ xj where xi and xj lie in the same equivalence class. Assume that it is not the scenario, and that for all disequality constraints xi ≠ xj , xi and xj lie in distinct connected components. Then, an assignment that allocates a value p to all the variables in connected component p satisfies all the constraints, therefore directing towards a contradiction. Thus, if all the constraints are not satisfiable, then, the algorithm performs in a correct manner.
=======================================================================
Please do not copy-paste an existing answer. Here's a problem that occurs in automatic program analysis....
Here's a problem that occurs in automatic program analysis. For a set of variables x1, x2, ..., In, you are given some equality constraints of the form "Xi = x;" and some disequality constraints of the form "r; # x;". Is it possible to satisfy all of them? For instance, the constraints Xi = x2, 22 = x3, x3 = 24, X1 + x4 cannot be satisfied. Give an efficient algorithm that takes as input m constraints over n variables...
Can I please get help with this question? Will upvote.
thanks.
Problem 4. Here's a problem that occurs in automatic program analysis. For a set of variables x1, ..., Xn, you are given some equality constraints, of the form "x, = x," and some disequality constraints, of the form “x, #x": Is it possible to satisfy all of them? For instance, the constraints x, = XX, = x3,x; = x, *, * x. cannot be satisfied. Give a polynomial time...
C++ For this assignment you will be building on the Original Fraction class you began last week. You'll be making four major changes to the class. [15 points] Delete your set() function. Add two constructors, a default constructor that assigns the value 0 to the Fraction, and a constructor that takes two parameters. The first parameter will represent the initial numerator of the Fraction, and the second parameter will represent the initial denominator of the Fraction. Since Fractions cannot have...