  We propose a formalism to derive the maximal bound of generalized Bell type
inequalities and shows that the formalism can be applied to various form of
Bell functions. The generic Bell function is defined to generate the
combinations of all the possible correlations whose local realistic bound can
be obtained from the series of the constraint equations. The application of the
constraints converts the optimization problem into the counting problems whose
complexity is dramatically reduced. It is also shown that generic Bell function
can be used to generate many other known Bell type functions such as Mermin,
Ardehali, Svetlichny functions for multipartite two-dimensional class.
