Chemical Visualization of Boolean Functions: A Simple Chemical Computer R. Blittersdorf, J. Muller, and F. W. Schneider Institute of Physical Chemistry, University of Wijrzburg, Marcusstrasse 9 - 11, 97070 Wurzburg, Germany Basic processes in computation are carried out by the Boolean functions AND, OR, NAND, and NOR, which allow the reduction of complex events to simple binary problems. Such computations may he done i n principle by artificial neural nets ( l , 2 ) .The structure of a feed-forward net consists of a t least two layers: an input and a n output layer. The input layer feeds some activation into the net. This activation is processed forward to the output layer by links, which represent the axons, dendrites, and synapses of biological systems. The calculated result of the neural net i s given by the activation of the neurons i n the output layer. Two layered neural nets can solve only simple prohlems. For more complex problems one or more hidden layers a r e necessary between t h e i n p u t a n d o u t p u t layer. Recently we trained such a feed-forward net containing 40 neurons including two hidden layers (3) to predict deterministic chaos i n t h e Belousov-Zhahotinskii reaction ( 4 ) .We also calculated the four logical functions AND, OR, NAND, and NOR using the histahle region in the NFT model of the minimal hromate reaction
(5). Reactions That Calculate H e r e we present experiments t h a t "calculate" t h e above logical functions (AND, OR, NAND, and NOR) using the neutralization reaction. A s e t u p of three flow reactors can he considered a s a chemical neural net, which consists of a n input layer (input reactors 1and 2) and a n output layer (output reactor 3) without any hidden layers (Fig. 1). The links between the input and output layers a r e realized experimentally by flow-rate coupling of the reactors, t h a t is, adjustment of t h e NaOH flow into the output reactor according to the chosen Boolean function and depending on the pH values of the two input reactors. I n previous calculations ( 6 ) a histahle, n o n l i n e a r chemical reaction was used to implement a parallel chemical computer in the form of a Hopfield net (7).I n the present experiments we use a fast reaction particularly suitable for demonstration purposes: the neutralization of hydrochloric acid with sodium hydroxide in the presence of phenolphthalein a s a n indicator. The states of the indicator (red or colorless) represent the binary states observed. We have also carried out chemical computer experiments (8)with three reactors containing the nonlinear BelousovZhahotinskii reaction (41, which shows histability ( 9 ) a s well as other complex phenomena (10).In complex cases the reaction acts a s a chemical switch; the chemical reaction shows relatively sharp kinetic transitions lasting less than one residence time from one steady state to the other. In the present system, the indicator equilibrium obeys the law of mass action; the pH change is gradual rather than sharp. This disadvantage is outweighed by the overall simplicity of the system. 760
Journal of Chemical Education
Figure 1. All three reactors (1-3) are stirred with magnetic stirrers at 600 rpm, and they are fed with a constant flow of the HCI solutions (A, Ph) containino the indicator 11.0 M HCI + 1.0 x 10" M ohenolohthalei; and a vaiable flow of sd~utionB 11.0 M NaOHI. , ~svrinoe ~, ~ ourno , ,~~ ( ~ J ' d vers e 6 a1 a cenam low 'ale kt3 ~(eq1 ) "to reactor 3 Olner arrons nacale !he o~llfowTne aka ne low rate lor me two np-1 reaclors s aa,.s!eo so !hat 1ne.r onan/ slates are elner 1 or 0 Tne connectivities between 1-3 and 2-3 are denoted by wn (s-') and ma (5').
Experimental Setup The experimental setup (Fig. 1) consists of three continuous-flow stirred-tank reactors (CSTR's) (reactors 1 and 2 for input; reactor 3 for output) and four syringe pumps, which are electronically controlled to deliver the inflow solutions a t a defined flow rate into the reactors. The rectangular CSTR's a r e homemade from Plexiglas with a volume of 22 mL (width: 27 mm, depth: 27 mm, height: 30 mm). At the bottom of a reactor there are two inlet tubes (1mm $1 for the reaction solutions and a n overflow a t the top ensuring a constant reactor volume. The solutions are stirred by magnetic stirrers a t 600 rpm driven by a motor beneath the reactor. The syringe pumps are regulated with a step motor. Typical stepping frequencies in these experiments are between 20 and 100 Hz using normal 50-mL syringes. For the present neutralization experiment i t is possible to use less precise pumps, such a s the peristaltic pumps available in many labs. Solutions Three pumps each contain a syringe with solution B (1.0 M NaOH). In our present setup the fourth pump simulta-
,
~
~
Table 1. Boolean Functions
Input 1
Input2
AND
OR
NAND
NOR
1
1
1
1
0
0
me four Boolean functions AND. OR. NAND, and NOR. The 1 denotes a '11118"
value, whereas 0 indicates 'Yalse".
Table 2. Connectivities (eq 1)
OR
AND
Figure 2. (a) An electrical circuit with two serial switches represents the AND connection: If both switches are pressed (1 for the input), then the lamp (output)is lit (I).(b)An electrical circuit with two parallel switches represents an OR connection. If either one or both switches are pressed, the lamp is lit. neously drives three syringes with solution A (1.0 M HC1, 1.0 x lo4 M phenolphthalein (Ph)). The HCI solutions are delivered a t a constant flow rate corresponding to a residence time T,,, of 183 min, where r,.,is the reactor volume per flow rate (mWmin). For the two input reactors the flow rate of solution B i s adjusted according to the chosen input pattern. The colorless, acidic state is defined a s the binary state 0; and the red, alkaline state is defined as 1. The pH of the reactors i s monitored by pH electrodes (Ingold). The switching process from 0 to 1 (i.e., from red to colorless) is represented by the color change of the indicator a t pH 8.4 (pK, of phenolphthalein) where the concentration of the red chinoidal dianion R2- is equal to the colorless monoanion HR-. The flow rate kn of the NaOH solution into the output reactor 3 is calculated on-line according to kn = w , , (output 1) + wz3 (output 2) + b3
(1)
where w13 and wz3 denote the coupling strengths in K' hetween reactors 1-3 and 2-3; ba (s-') acts as a simple bias; output 1 and output 2 represent the actual pH values i n input reactors 1 and 2; and output reactor 3 displays the result: red or colorless.
Logical Functions and Boolean Variables The four logical functions AND, OR, NAND, and NOR require only the simple answers "true" and "false". The answers to logical questions are represented by the Boolean variables a and b, with values of either "true" or "false". The Boolean functions fb describe the connections of the variables a and b. The identity (eq 2) has a value equal to its argument, whereas the negation (eq 3) leads to a result opposite to its argument.
Functions of two arguments are the AND connection (eq 4) leading to "true" only if all arguments are true and the OR connection (eq 51, which yields 'true" if a t least one argument a o r b has the value "true".
fb(a,b)= avb
(5)
NAND
NOR
W13
4.3 lo4
4.3 lo4
4.3
4 . 3x
~ 2 3
4.3 x lo4
4.3 x lo4
4 . 3 x lo4
-4.3 x 104
12.1 XIO" 1.0x10-~ 6.1 X I O - ~ 18.1 XIO-' The coupling strengths w,)'I( and bias values b , ( s ' ) for all four rypes of connections obtained using eq 1. bj
The NAND and NOR connections are obtained by application of the negation to the results of the AND and OR connections. For a physical understanding, the functions AND and OR can be illustrated i n terms of electrical circuits (Figs. 2a, b). Results
Input Patterns and Output Values A n overview of the four Boolean functions AND, OR, NAND, and NOR is given i n Table 1showing the values for all four possible input patterns. The coupling strengths w, and the bias values b, for the four connections used in the experiments are shown in Table 2. The four possible input patterns and their corresponding output values for the AND connection are shown in Figures 3 a-d: The red reactors mark the binary state 1("true"), whereas the colorless reactors indicate the 0 ("false") state. Areversal of the assignment from 0 (1)to 1(0) changes AND to OR and vice versa. This is a n expression of De Morgans theorem (11). Figures 4a-d show the OR connection for the four possible input patterns. Figures 3 and 4 can be easily correlated with Table 1verifying . that the chemical c o m ~ u t e rworks correctly. In a typical experiment the pH of the three reactors is plotted versus time (Figs. 5a-d) for all four types of logical connections. For each connection all four input patterns and their corresponding output values are shown. For examnle. O d = 0 (for AND) means that reactor 1is in the 0 state (colorless); reactor 2 is in the 1state (red); and output reactor 3 is i n the 0 state (colorless). I t i s also possible to do the whole experiment without automated equipment. Register the pH of reactor 1(output 1)and reactor 2 (output 2). Then calculate k n according to eq 1)on a PC with the given values of w13 and w23 (adjust b3 accordingly) to obtain the value for the flow rate of solution B into reactor 3. (Solution A flows into all three reactors a t a constant flow rate.) If a peristaltic pump is used, its potentiometer may be calibrated and quickly adjusted by hand according to the calculated value of kn.
-
L~
~.
Discussion Using the easy-to-handle neutralization reaction, one may realize the four logical functions AND, OR, NAND, and NOR. The values of w13 and WZQwere calculated using eq 1and inserting the pH.values of output 1and output 2 Volume 72 Number 8 August 1995
761
r 10.1-~-13..1 pilllwrs 01 !he ogca f.riaon Ah9 s 0.0 = 0, o ' ' = 11. c 1 ? = :a i f l n 1 . 1 = F ~ . T 3 Pioiograpisol l i e l o ~ pcs53c 1 T.le P e x a as rsaclors w In e8eclroaeSanc SI rr i g n m r s DP our are aop ec 1-3 Trw, are fen oy i u o sn a !.ocs from l i e oac. -ne arge 1,oes are .st0 lor 1r1r;rrnoslattnga i i o q terTpera'.'e collro i no1cr Ica n In s nn.tra za'oi exper rneil. T w ac a c co or ess sla'e s cenoted as 0; the alkaline red state is denoted as 1. The pumps, PC, and the electronics for calcuiating kt3 o d i n e are not shown.
Figure 4. Photographs of the four possible input-output patterns of OR: (a) OvO = 0,(b) Ovl
762
Journal of Chemical Education
=
1, (c) 1vO
-
1, and (d) l v l = 1