Nonperturbative Superpotentials and Compactification to Three Dimensions