reasoning with constraints ""self title title self variables variables self constraints constraints self var_to_const {var:set(for var in self variablesfor con in constraintsfor var in con scopeself var_to_const[varadd(con def __str__(self)"""string representation of csp""return str(self title def __repr__(self)"""more detailed string representation of csp""return "csp({self title}{self variables}{([str(cfor in self constraints])})csp consistent(assignmentreturns true if the assignment is consistent with each of the constraints in csp ( all of the constraints that can be evaluated evaluate to truenote that this is local consistency with each constraintit does not imply the csp is consistent or has solution cspproblem py -(continued def consistent(self,assignment)"""assignment is variable:value dictionary returns true if all of the constraints that can be evaluated evaluate to true given assignment ""return all(con holds(assignmentfor con in self constraints if con can_evaluate(assignment)the show method uses matplotlib to show the graphical structure of constraint network cspproblem py -(continued def show(self)plt ion(interactive ax plt figure(gca(ax set_axis_off(plt title(self titlevar_bbox dict(boxstyle="round ,pad= ,rounding_size= "con_bbox dict(boxstyle="square,pad= ",color="green"for var in self variablesif var position is nonevar position (random random()random random()for con in self constraintsif con position is nonecon position tuple(sum(var position[ifor var in con scope)/len(con scopeversion june