User:Thepigdog/Play3

Pizza, beer, whiskey
After a hard days work, attempting to meet some crazy deadline, with the project from hell, there comes that desperate time at 10 PM when we all need pizza, beer, whiskey. Pizza shops are open at,
 * $$\text{PizzaShop}(V(\{\text{Carlton}::p_1, \text{Richmond}::p_2, \text{South Melbourne}::p_3, \text{Footscray}::p_4, \text{St Kilda}::p_5, \text{Toorak}::p_6\}))$$

Beer you can get at,
 * $$\text{BottleshopWithBeer}(V(\{\text{South Melbourne}::b_1, \text{St Kilda}::b_2, \text{Carlton}::b_3, \text{Docklands}::b_4\}))$$

Whiskey,
 * $$\text{BottleshopWithWhiskey}(V(\{\text{Essendon}::w_1, \text{South Melbourne}::w_2\}))$$

The cops are about and we are not getting any younger. Where to go?
 * $$\text{WhereToGo}(x) = \text{PizzaShop}(x) \land \text{BottleshopWithBeer}(x) \land \text{BottleshopWithWhiskey}(x) $$

If the constraints are applied in the order left to right,
 * $$x = V(\{\text{Carlton}::p_1, \text{Richmond}::p_2, \text{South Melbourne}::p_3, \text{Footscray}::p_4, \text{St Kilda}::p_5, \text{Toorak}::p_6\})$$

Then we need to unify this with,
 * $$x = V(\{\text{South Melbourne}::b_1, \text{St Kilda}::b_2, \text{Carlton}::b_3, \text{Docklands}::b_4\})$$

This will create 24 combinations from which the matching ones are,
 * $$x = V(\{\text{South Melbourne}::b_1 \cap p_3, \text{St Kilda}::b_2 \cap p_5, \text{Carlton}::b_3 \cap p_1\})$$

Finally we need to unify with whiskey.
 * $$x = V(\{\text{Essendon}::w_1, \text{South Melbourne}::w_2\})$$

Which gives 6 combinations. The matching one is,
 * $$x = V(\{\text{South Melbourne}::b_1 \cap p_3 \cap w_2\})$$

A total of 30 combinations were generated.

If the constraints are applied in the order right to left,
 * $$x = V(\{\text{Essendon}::w_1, \text{South Melbourne}::w_2\})$$

Then we need to unify this with,
 * $$x = V(\{\text{South Melbourne}::b_1, \text{St Kilda}::b_2, \text{Carlton}::b_3, \text{Docklands}::b_4\})$$

This will create 8 combinations from which the matching one is,
 * $$x = V(\{\text{South Melbourne}::b_1 \cap w_2\})$$

Finally we need to unify with pizza.
 * $$x = \{\text{Carlton}::p_1, \text{Richmond}::p_2, \text{South Melbourne}::p_3, \text{Footscray}::p_4, \text{St Kilda}::p_5, \text{Toorak}::p_6\}$$

Which gives 6 combinations. The matching one is,
 * $$x = V(\{\text{South Melbourne}::b_1 \cap w_2\ \cap p_3 \})$$

The result is the same but only 14 combinations were generated to arrive at the conclusion.

Every calculation combines value sets to create a value set which is the product of the sizes of the input value sets. The value set will then be trimmed down. And every calculation has an equal chance of narrowing the calculation. So by controlling the order and proceeding with calculations with the smallest product of sizes, there will be less calculation and less combinatorial explosion.