### Problem 1: light switches

Suppose you have $n$ light bulbs, where each light bulb $i = 1, \dots, n$ is initially off. You also have $m$ buttons which control the lights. For each button $j = 1, \dots, m$, we know the subset $T_j \subset \{ 1, \dots, n \}$ of light bulbs that it controls. When button $j$ is pressed, toggles the state of each light bulb in $T_j$ (if $3 \in T_j$ and light bulb 3 is off, then after the button is pressed, light bulb 3 will be on, and vice versa). Your goal is to turn on all the light bulbs by pressing a sequence of buttons.

1. [1 point] Show that it suffices to consider pressing each button zero or one time. that is, there exists a sequence of button presses that achieves the goal if and only if there exists a sequence of button presses in which each button is pressed at most once that achieves the goal.
2. [1 point] Show that the order in which the buttons are pressed doesn't affect the final setting of the light bulbs.
3. [3 points] Cast this problem as a CSP (explicitly state the variables, domains of each variable, and constraint functions on each variable).
4. [2 points] Suppose that if there are ever three consecutive buttons which are all pressed, then all the lights burn out. For example, you can press buttons {1, 3, 4, 6} but not {1, 3, 4, 5} because {3,4,5} are consecutive. Add the smallest number of constraints to your CSP from above to make sure that you don't burn out all the lights.

### Problem 2: transforming CSPs

[2 points] Suppose we have a general CSP with variables $X = (X_1, \dots, X_n)$ and constraints $f_1, \dots, f_m$. Assume that each variable $X_i$ can only take on only integer values $1, \dots, M$ (that is, $\text{Domain}_i = \{1, \dots, M\}$). Assume that the first constraint function is $f_1(x) = [\sum_{i=1}^n x_i = T]$, which says that the sum of the integer values must equal some known target integer value $T$. Recall that it's generally good to have constraint functions that depend on few variables. Since $f_1$ depends on all the variables, this is not desirable.

Your job is to define a new CSP with $O(n)$ additional integer-valued auxiliary variables, where the original constraint $f_1$ is represented by $O(n)$ ternary constraints (those that depend on three variables).

### Problem 3: conditioning and elimination

Suppose we have a general CSP with variables $X = (X_1, \dots, X_n)$ and constraints $f_1, \dots, f_m$.
1. [2 points] Suppose we condition on one variable $X_i = x$ for some value $x$. Define a new CSP over $n-1$ variables such that for each satisfying assignment $(x_1, \dots, x_{i-1}, x_{i+1}, \dots, x_n)$ in the new CSP, we have that $(x_1, \dots, x_{i-1}, x, x_{i+1}, \dots, x_n)$ is a satisfying assignment in the old CSP and vice-versa.
2. [2 points] Supose we eliminate $X_i$. Define a new CSP over $n-1$ variables such that for each satisfying assignment $(x_1, \dots, x_{i-1}, x_{i+1}, \dots, x_n)$ in the new CSP, there exists an $x$ such that $(x_1, \dots, x_{i-1}, x, x_{i+1}, \dots, x_n)$ is a satisfying assignment in the old CSP and vice-versa.
3. [2 points] Compare the difference in the number of the constraints in the new CSP derived from conditioning and the new CSP derived from eliminating. Also compare the arity of the constraints between the two new CSPs.