Sunteți pe pagina 1din 30

Threshold and Majority Logic

Function

F ( x0 , x1,...., xn 1 ) is called threshold function,


if it can be represented as :

F ( x0 , x1 ,...., xn 1 ) = Sign( 0 x0 + 1 x1 + .... + n 1 xn 1 ) = =Sign( j x j ),


j=0 n-1

where 1 if A 0 SignA= 0 if A<0


x0

x1

- weight of input (variable) x j ; - threshold.

n 1

f
1

x n 1

Implementation of threshold elements

By definition threshold element has the following structure: Example:


U U0 U1 Uk Un-1

X0 X1 Xk Xn-1

F(X)

Adding Amplifier.

r r0 r1 rk rn-1
2

k
U in U ou t

Let

n = 3,0 = 2,1 = 1, 2 = 1, and = 1.5


X1:1 x2x1 00 x0 0 X0:2 1 0 2 1 3 2 4 1 3 01 11 X2:1 10

Example:

1, when 2x0 + x1 + x2 1.5, f = 0, otherwise.

The logic function satisfying this condition is represented by f = x0 x1 x2 . Let n = 2. In this case, when 0 = 1 = 1 and = 0.5 When 0 = 1 = 1, When

the function is:

f = x0 x1 ;

When 0 = 1 = 1 and = 1.5, then f = x0 x1 . and

= 0.5, then f = x0 x1 .
3

0 = 1 = 1,

and = 1.5, then f = x0 x1 .

Example: There are 16 functions of two variables, Among them, only two functions are not threshold functions: x1 x 2 and x1 x2 All other functions are threshold functions. Example: All the monotone increasing function with up to three variables are threshold functions. However, the four-variable function x 1 x 2 x 3 x 4 is not a threshold function.
Set of all functions Monotonic Isotonic Threshold Self-dual Majority

f7 f6

f1

f2
f3 f8 f9

f4

f5

Example of three-inputs majority (voting) function


X0 0 1 0 1 0 1 0 1 X1 0 0 1 1 0 0 1 1 X2 0 0 0 0 1 1 1 1 X0+X1+X2-2 -2 -1 -1 0 -1 0 0 1 Sign(X0+X1+X2-2) 0 0 0 1 0 1 1 1

Properties of threshold functions


Theorem: let f ( x0 , x1 ,...., xn 1 ) a threshold function with weights = ( 0 , 1 ,... n 1 ) and threshold . If i 0 then the function is isotonic in then the function is antitonic in xi .

xi

, and if i 0

Proof (isotonic) : Assume that i 0 and the function is not isotonic in xi . Then there is at least one combination of x0 ,...xi 1 , xi +1 ,...xn 1 where 1 = f ( x0 ,...0, xn 1 ) > f ( x0 ,...1, xn 1 ) = 0 Therefore 0 x0 + ... + 0 + ... + n 1 xn 1 and 0 x0 + ... + i + ... + n 1 xn 1 < since i 0 we get a contradiction.
6

Properties of threshold functions (cont) Theorem: A threshold function is monotonic in respect of all its variables.

All threshold functions are monotonic, but opposite is not true - not any monotonic function is a threshold function.
Example: function

x0 x1 + x2 x3 is a monotonous but not threshold.

Properties of threshold functions (cont)


Theorem: let F ( x0 , x1 ,...., xn 1 ) a threshold function with weights = ( 0 , 1 ,... n 1 ) and threshold . If a function G is of the same NN class as F, then G is a threshold function with weights = ( 0 , 1 ,... n 1 ) and threshold , where

| i |=| i | and = f ( , ) .

F(x1,x2 ,...,xk ,...,xn1 ) = Sign(0 x0 + 1 x1 + ... + k xk + ... + n 1 xn1 )


then,

Lemma: Negation of a variable , if

F(x1 ,x 2 ,..., x k ,...,x n 1 ) = =Sign( 0 x0 + 1 x1 + ... + k ( 1 x k ) + ... + n 1 x n 1 ) = = Sign( 0 x0 + 1 x1 + ... k x k + ... + n 1 x n 1 + k );


8

Synthesis of threshold functions


For Boolean function defined by two sets of vertices T and F. (XT)=1; (X F)=0. The input weights and threshold of the corresponding threshold function are found by solving the task:

min( j + );
j =0

n 1

j =0

n 1

x j 0 x j < 0

X T ; X F ;

j =0

n 1

This task is called the standard task of linear programming. If a solution of this task exists, then for xj ={0,1} it exists in integer numbers. If a solution doesnt exist, this Boolean function is not a threshold function.
9

Synthesis of threshold functions (cont)


When synthesizing a threshold element, it is sufficient to solve the linear programming task only for the basic sets because, if the inequalities are true for the supporting sets, they are certainly true for all the remaining vertexes.

10

Synthesis of isotonic threshold functions


Define Mi the number of minterms for which Theorem:

f ( x) = 1. and
if Mi = M j

xi = 1

if

Mi > M j

then i > j , and

then i = j .
Mi B A

Proof: Assume that i j and M i > M j Let A = ( x1 , x2 ,..xi 1 , 0, xi +1.., x j 1 ,1, x j +1 ,...xn 1 ) and B= ( x1 , x2 ,..xi 1 ,1, xi +1.., x j 1 , 0, x j +1 ,...xn 1 )

if f ( A) = 1 then f ( B ) 1 Mj and if f ( A) = 0 then f ( B ) = 0 . Therefore M i M j which leads to a contradiction.

11

Synthesis of isotonic threshold functions-cont Example: M0=7 M1=8 M2=6 M3=6 M1>M0>M2=M3
x3x2 x1x0 00 01 11 10 1 1 1 1 1 1 1 1 1 1 1 00 01 11 10 x3x2 x1x0 00 00

1
01

2
11

1
10

0 2 5 3

1 3 6 4

2 4 7 5

1 3 6 4

2 5 3

01 11 10

base point

max( 0 , 2 + 3 ) < min(1 , 0 + 3 , 0 + 2 ) 0 < 1 and 2 , 3 < 0

f ( x0 , x1 , x2 , x3 ) = 2 x0 + 3 x1 + 1x2 + 1x3 3

12

Synthesis of threshold functions - example


Synthesis steps: a) Is the function monotonic ? b) Classify the variables (isotonic, antitonic) c) Negate the variables for which the function is antitonic d) Calculate and order the Mi e) Assign weights and find a threshold or prove that you get a contradiction x1
000 00 01 11 10 1 1 001 1 1 1 011 1 1 1 010 1 1 1 1 1 110 111 1 1 1 101 1 1 1 1 1 100

x2

x3

x x5 4

The function is isotonic in x1 , x2 and x4 The function is antitonic in x5 and x3

13

Synthesis of threshold functions-example cont 3


011

2
000 00 001

1
010

2
110

4
111 4

3
101

1
100

x1

x x2 3

4 7 3

01 11 10

x x5 4

M 1 = 12, M 2 = 11, M 3 = 11, M 4 = 16, M 5 = 13 4 > 5 > 1 > 2 = 3 4 > 3 > 2 >1 =1 5 > 3 > 2 >1 =1 = 5 4 = 5, 5 = 3, 1 = 2, 2 = 1, 3 = 1 = 5 (3 + 1)

x = 1 x

14

Hyper-geometrical representation of threshold function


Equation j x j = 0 is the equation of a hyper-plane in the nj= 0 dimensional space. For 2-dimentions: 0 x0 + 1 x1 = 0 - equation of a line.
X1 y1
D (Y ,L )
n 1

x1 + x2 1 = 0; D (Y , L) =

0 y0 + 1 y1 02 + 12
=

y0 + y1 1 ; 2

D (0, L) =

02 + 12

1 ; 2
15

y0

X0

For 3-dimentions:

X2 1

0 x0 + 1 x1 + 2 x2 = 0
- equation of a plane.

Y D(Y,P)

1 X0 X1 1

x0 + x1 + x2 1 = 0; D (Y , P ) =

0 y0 + 1 y1 + 2 y2
2 02 + 12 + 2

y0 + y1 + y2 1 ; 3
16

For n-dimensions: j x j = 0 j= 0 plane in the n-dimensional space.


n 1

n 1

- equation of a hyper-

D(Y , P n ) =

j =0

j y j
n 1

;
2

j =0

n 1

As

2 j j =0

> 0, then

Sign{D(Y, P )} = Sign( j y j )
n j =0

n 1

and the value of the threshold function in the point Y (cube vertex) is determined by the sign of the distance from this point to the hyper-plane determined by the weights of the variables and by the threshold.
17

At all the cube vertices located above or within the hyper-plane, the value of threshold function is equal to 1. At all the cube vertices located below the hyper-plane, the value of threshold function is equal to 0.

F(x0 ,x1,x2 ) = x0 x1 x2 = = Sign(x0 + x1 + x2 3 );


18

F(x0 ,x1,x2 ) = x0 x2 + x1 x2 = = Sign(x0 + x1 + 2 x2 3 )

F(x0 ,x1,x2 ) = = x0 x1 + x0 x2 + x1 x2 = = Sign(x0 + x1 + x2 2 );


19

F(x0 ,x1,x2 ) = x0 x1 + x2 = = Sign(x0 + x1 + 2 x2 2 );

F(x0 ,x1,x2 ) = x0 + x1 + x2 = = Sign(x0 + x1 + x2 1 );

20

Negation of a variable and hyper-plane rotation


Let Boolean function F(x1,x2 ,...,xk ,...,xn 1 ) be a threshold function, that is

F(x1,x2 ,...,xk ,...,xn1 ) = Sign(0 x0 + 1 x1 + ... + k xk + ... + n 1 xn1 )


then

F(x1 ,x 2 ,..., x k ,...,x n 1 ) = =Sign( 0 x0 + 1 x1 + ... + k ( 1 x k ) + ... + n 1 x n 1 ) = = Sign( 0 x0 + 1 x1 + ... k x k + ... + n 1 x n 1 + k );

21

F(x0 ,x1,x2 ) = x0 x2 + x1 x2 = = Sign(x0 + x1 + 2 x2 3);

F(x0 ,x1,x2 ) = x0 x2 + x1 x2 = = Sign(x0 x1 + 2 x2 2 );

22

Since a threshold function is monotonous, it is represented by a star of basic elements. Basic sets T0 and F0 of threshold function are the sets of vertexes, which are maximal diagonal vertices in the basic elements that form stars for the function itself and for its negation. 6 4 Example: 5 7 Star top is 15 vertex. 12 0 2 T = {3,6,7,10,11,13,14,15} T0={3,6,10,13} Star top of negation function is 0 1 15 13 3 vertex. 8 F = {0,1,4,2,5,8,9,12} F0={2,5,9,12} 9 11

14

10

( x0 , x1, x2 , x3 ) = x0 x1 + x1 x2 + x1 x3 + x0 x2 x3 = = Sign ( x0 + 2 x1 + x2 + x3 3)

When synthesizing a threshold element, it is sufficient to solve the linear programming task only for the basic sets because, if the inequalities are true for the supporting sets, they are certainly true for all the remaining vertexes.
23

Implement the following function

f ( x1,, x5 ) = x1 x3 + x1 x5 + x1 x2 x4 + x2 x3 x5
by a single threshold element
1. Define weight relations between variables x1 and x2:

f ( x1 = 1, x2 = 0, x3, x4 , x5 ) = x3 + x5 f ( x1 = 0, x2 = 1, x3, x4 , x5 ) = x3 x5
Since x3+ x5 x3x5, than x1>x2 2. Define weight relations between variables x2 and x3:

f ( x1, x2 = 1, x3 = 0, x4 , x5 ) = x1x5 + x1 x4 f ( x1, x2 = 0, x3 = 1, x4 , x5 ) = x1


Since x1 x1x5+ x1x4 than x3>x2
24

3. Define weight relations between variables x3 and x4:

f ( x1, x2 , x3 = 1, x4 = 0, x5 ) = x1 + x2 x5
Since x1+x2x5 x1x5+x2x5 than x3>x4

f ( x1, x2 , x3 = 0, x4 = 1, x5 ) = x1x5 + x2 x5

4. Define weight relations between variables x4 and x5:

f ( x1, x2 , x3, x4 = 1, x5 = 0 ) = x1 x3 + x1 x2 f ( x1, x2 , x3, x4 = 0, x5 = 1) = x1 + x2 x3


Since x1+x2x3 x1x3+x2x4 than x4<x5

25

5. Define weight relations between variables x1 and x3:

f ( x1 = 0, x2 , x3 = 1, x4 , x5 ) = x2 x5
Since x5+x2x4 x2x5 than x1>x3

f ( x1 = 1, x2 , x3 = 0, x4 , x5 ) = x5 + x2 x4

6. Define weight relations between variables x3 and x5:

f ( x1, x2 , x3 = 1, x4 , x5 = 0 ) = x1

f ( x1, x2 , x3 = 0, x4 , x5 = 1) = x1
Consequently: x3 ~ x5

26

7. Define weight relations between variables x2 and x4:

f ( x1, x2 = 0, x3, x4 = 1, x5 ) = x1 x3 + x1 x5
Consequently: x2>x4 And: x1 > x3 ~ x5 > x2 > x4

f ( x1, x2 = 1, x3, x4 = 0, x5 ) = x1 x3 + x1 x5 + x3 x5

Consequently: 1 > 3 5 > 2 > 4

Let us also compare functions:

f ( x1 = 1, x2 , x3, x4 = 0, x5 = 0 ) = x3

f ( x1 = 0, x2 , x3, x4 = 1, x5 = 1) = x2 x3
Threshold is equal to 8

Since: x3 x2x3 than 1 > 4 + 5 Minimal possible weights:

1 =5, 2 =2, 3 = 3, 4 = 1, 5 =3.

f ( x1,...., x5 ) = Sign(5 x1 + 2 x2 + 3 x3 + x4 + 4 x5 8)
27

Implementation of threshold elements

By definition threshold element has the following structure: Example:


U U0 U1 Uk Un-1

X0 X1 Xk Xn-1

F(X)

Adding Amplifier.

r r0 r1 rk rn-1
28

k
U in U ou t

The main fields of threshold and majority functions application


A threshold function is called a majority function (voting function) if its value coincides with n more than a half of the input signals ( i = 1, =] [+1).

1. Logical synthesis of discrete devices (hardware) 2. Pattern recognition. Diagnostics (hardware and software). Example: Relying on a set of symptoms (results of analyses, temperature, cardiogram, etc. etc.) for each of the possible diseases a weighted sum is calculated and compared with threshold. 3. Neural networks. (hardware and software). Input weights and threshold are formed during learning. 4. Coding (hardware and software)

29

Example 1: Optimal Balance Code (OBC) Working combination of n-OBC contain


n + 1 2

ones.

n=4 {1100, 1010, 1001, 0110, 0101, 0011} Hence, whether a combination belongs to the working set is determined by the n 1 n 1 condition:

n + 1 Sign( xj )(1 Sign( 2 j =0

n + 1 xj 1)) 2 j =0

Example 2: Bergers code (Code with code indicator): Bergers code consist of two parts which are the n-bits information part and (1+]log2n[)-bits code indicator, the value of which is equal of the number of zeros in the information part. n=3, k=2 {000.11, 100.01, 110.10, 111.00, ....} Whether a combination belongs to the working set is determined by the condition:

Sign(

x j + 2i yi n)(1 Sign( x j + 2i yi n 1)) i =0 i =0 j =0 j =0


30

n 1

k 1

n 1

k 1

S-ar putea să vă placă și