## Harvard Basic v11.1

The following program written in Microsoft Visual Basic v6 will reduce multiple state logical equations to minimum form and may be used to simulate logical human thought.[1]

```00010 SUB MAIN()
00020 Copyright 1968-2010 Patrick C Eberhart
00030 --------- dimension array to hold raw terms --------------
00040 'Dim ai\$(2000)
00050 --------- skip symbolic processing ----------------------
00060 'k = 0
00070 'v = 0
00080 'i = 0
00090 --------- open truth table file ----------------------
00100 'Open "C:\multiplestates.txt" For Input As #1
00110 'Do While Not EOF(1)
00120 'Line Input #1, micky\$
00130 'betsy = Split(micky\$, Chr\$(9), , vbTextCompare): ai\$(i) = Join(betsy, "")
00140 'If ai\$(i) = "" Then Exit Do
00150 'Debug.Print i, ai\$(i); Len(ai\$(i))
00160 'i = i + 1
00170 'Loop
00180 'Close #1
00190 ------- convert string input to numeric ---
00200 'b = i
00210 'g = b - 1
00220 'i = 0
00230 'Do Until ai\$(i) = ""
00240 'If i > 0 And Len(ai\$(i)) <> k Then End
00250 'k = Len(ai\$(i))
00260 'For j = 1 To k
00270 'o\$ = Mid\$(ai\$(i), j, 1): r = Val(o\$)
00280 'If r > v Then v = r
00290 'Next
00300 Debug.Print i; "==>"; ai\$(i); b; k; v
00310 'i = i + 1
00320 'Loop
00330 'b = i
00340 'v = v + 1
00350 ----- GENerate chart ------------------------
00360 'Dim xi\$(100)
00370 'Dim ah(100), bi\$(1000, 1000), Q(11111)
00380 'For i = 0 To v - 1
00390 'xi\$(i) = Right\$(Str\$(i), Len(Str\$(i)) - 1)
00400 'Next i
00410 'For i = 1 To v ^ k: Q(i) = 0: For j = 1 To v ^ k: bi\$(i, j) = String\$(k, 32): Next j, i
00420 'For i = 1 To v ^ k: T = i - 1
00430 'For j = k To 1 Step -1
00440 'D = Int(T / v): ah(j) = T - D * v: T = D: Next j
00450 'For l = 1 To v ^ k: F = l - 1
00460 'For j = 1 To k
00470 'D = Int(F / v): E = F - D * v: F = D
00480 'If E = 0 Then GoTo 00520
00490 'Mid\$(bi\$(i, l), j, 1) = xi\$(ah(j))
00500 'For M = 0 To g: If ai\$(M) = bi\$(i, l) Then Q(i) = 1
00510 'Next M
00520 'Next j
00530 'Next l
00540 'Next i
00550 'S\$ = String\$(k, 88)
00560 ---------reduce----------------------------------------------------
00570 'For j = 1 To v ^ k
00580 'For i = 1 To v ^ k
00590 'If Q(i) = 1 Then GoTo 00640
00600 'For N = 1 To v ^ k
00610 'If bi\$(i, j) = bi\$(N, j) And Q(N) = 1 Then bi\$(N, j) = S\$
00620 'Next N
00630 'If Q(i) = 0 Then bi\$(i, j) = S\$
00640 'Next i
00650 'For i = 1 To v ^ k
00660 'For l = j + 1 To v ^ k
00670 'For M = 1 To k
00680 'WERT\$ = Mid\$(bi\$(i, l), M, 1)
00690 'WART\$ = Mid\$(bi\$(i, j), M, 1)
00700 'If WERT\$ = WART\$ Then bi\$(i, l) = S\$
00710 'Next M
00720 'Next l
00730 'DoEvents
00740 'Next i
00750 'Next j
00760 -------CONVERT------------------------------------------------------
00770 'For j = 1 To v ^ k: For i = 1 To v ^ k
00780 'tandor = False
00790 'For l = 1 To Len(bi\$(i, j))
00800 'sag\$ = Mid\$(bi\$(i, j), l, 1)
00810 'If sag\$ <> "X" And sag\$ <> " " Then
00820 'If tandor = False And p\$ <> "" Then p\$ = p\$ + "+"
00830 'p\$ = p\$ + sag\$ + Chr\$(64 + l)
00840 'tandor = True
00850 'End If
00860 'Next l
00870 'If tandor = True Then Exit For
00880 'Next i,j
00890 'Print Chr\$(65 + k); "="; p\$
00900 'Stop
00910 Copyright 1968-2008 Patrick C Eberhart
00920 'End
00930 END SUB
```

### User definition of happiness

Happiness is lots of love and no money or lots of love and lots of money or lots of love and some money or some love and no money or some love and lots of money or some love and some money.

Happiness is:
y/n Love Money
n no no
n no lots
n no some
y lots no
y lots lots
y lots some
y some no
y some lots
y some some

### multiplestates.txt - file contents format

Text file format of logic terms is shown below for upload to reduction program here.

```10
11
12
20
21
22
```

### Program Results

```C = 1A + 2A
```

### Results Interpretation

```Happiness is lots of love or some love.
```

## Online Version

The distributed version is not yet up and running but you can submit your own multiple state equation file with a limited number of variables and states to obtain a reduction. Just use the file format shown above, and upload from your browser to get the results online.

## notes

1. Logical human thought is defined in this case as the process of reducing multi-valued logical equations to minimum form. Note: the body of the listing has been commented out to allow line renumbering