Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap1_198111 - decus/20-0020/ntruth.log
There are 2 other files named ntruth.log in the archive. Click here to see a list.
100'  NAME--NTRUTH
110'
120'  DESCRIPTION--COMPUTES THE N-VALUED TRUTH TABLES FOR 
130'  FORMULAS OF THE PROPOSITIONAL CALCULUS ACCORDING TO THE
140'  TRUTH TABLES SUPPLIED BY THE USER FOR THE PROPOSITIONAL
150'  CONNECTIVES - (NOT), & (AND), V (OR), => (IF...THEN), <=> (IF
160'  AND ONLY IF), AND / (NOT BOTH). USING THE N TRUTH VALUES 
170'  0,1,...N-1. ABBREVIATIONS OF THE FORMULAS ARE ALLOWED, WITH
180'  BINARY CONNECTIVES BEING ASSOCIATED TO THE RIGHT OBSERVING THE
190'  PRIORITIES ESTABLISHED BY THE ORDER OF THE CONNECTIVES IN THE
200'  ABOVE LIST. FORMULAS MAY EMPLOY THE PROPOSITIONAL VALUES A,B,...T.
210'
220'  SOURCE--UNKNOWN
230'
240'  INSTRUCTIONS--IN ADDITION TO BEING ABLE TO SPECIFY THE NUMBER
250'  N OF TRUTH VALUES AND THE TRUTH TABLES FOR THE PROPOSITIONAL
260'  CONNECTIVES, THE USER ALSO HAS TWO OPTIONS WITH REGARD TO
270'  OUTPUT: UNDER OPTION (1) NTRUTH PRINTS OUT THE ENTIRE
280'  TRUTH TABLE FOR A GIVEN FORMULA, WHILE UNDER OPTION (0) NTRUTH
290'  MERELY DETERMINES IF THE GIVEN FORMULA IS A TAUTOLOGY (I.E.,
300'  IF ITS TRUTH TABLE CONTAINS ALL 0'S) AND PRINTS OUT AN
310'  INVALIDATING ASSIGNMENT TO THE VARIABLES OCCURRING IN THE
320'  FORMULA IF IT IS NOT A TAUTOLOGY.
330'  THE FOLLOWING INFORMATION IS TYPED IN AS DATA:
340'      510  DATA    (THE OPTION 0 OR 1 FOR OUTPUT)
350'     520  DATA    (THE NUMBER OF N TRUTH VALUES)
360'     530  DATA    (TRUTH TABLE FOR  -    N ENTRIES)
370'     540  DATA    (TRUTH TABLE FOR  &  N*N ENTRIES)
380'     550  DATA    (TRUTH TABLE FOR  V  N*N ENTRIES)
390'     560  DATA    (TRUTH TABLE FOR  => N*N ENTRIES)
400'     570  DATA    (TRUTH TABLE FOR <=> N*N ENTRIES)
410'     580  DATA    (TRUTH TABLE FOR  /  N*N ENTRIES)
420'       THEN TYPE "RUN", WHEN NTRUTH TYPES "FORMULA?" TYPE
430'    IN THE FORMULA WHOSE TRUTH TABLE YOU WISH TO COMPUTE.
440'    TO EXIT NTRUTH, TYPE "STOP" WHEN NTRUTH TYPES "FORMULA?".
450'
460'
470'  *  *  *  *  *  *  MAIN PROGRAM  *  *  *  *  *  *  *  *  *  *
480'
490 REM  ********** DATA FOR TRUTH TABLES  **********
500 REM
510 DATA 1
520 DATA 3
530 DATA 2,1,0
540 DATA 0,1,2,1,2,2,2,2,2
550 DATA 0,0,0,0,0,1,0,1,2
560 DATA 0,1,2,0,0,1,0,0,0
570 DATA 0,2,2,2,0,2,2,2,0
580 DATA 2,1,0,1,0,0,0,0,0
590 DATA 123456
600 READ T
610 READ N1
620 IF N1 <= 10 THEN 650
630 PRINT "A MAXIMUM OF 10 TRUTH VALUES IS ALLOWED."
640 STOP
650 DIM L(51,10)
660 MAT READ L(5*N1+1,N1)
670 READ X
680 IF X = 123456 THEN 710
690 PRINT "INCORRECT AMOUNT OF DATA IN TRUTH TABLES FOR CONNECTIVES."
700 STOP
710 REM
720 REM  **********  INITIALIZATION  **********
730 REM
740 DIM A(100), B(100), C(100), F(100), G(127)
750 DIM N(100), S(120), V(20), V$(21)
760 MAT READ G
770 LET G(0) = 9
780 DATA 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9
790 DATA 9,11,9,9,9,9,9,3,9,1,8,9,9,9,2,9,7,9,9,9,9,9,9,9,9,9,9,9,9,6
800 DATA 5,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
810 DATA 10,10,10,10,9,4,9,9,9,9,9,9,9,9,9,9,9,9,9,9
820 DATA 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9
830 MAT READ V$
840 DATA A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,F
850 LET P = S = N = F1 = 0
860 PRINT "FORMULA";
870 INPUT F$
880 IF F$ <> "STOP" THEN 900
890 STOP
900 PRINT
910 CHANGE F$ TO F
920 LET L = F(0)
930 REM
940 REM  **********  COMPILATION  **********
950 REM
960 FOR I = 1 TO L
970 LET C = G(F(I))
980 IF C > 11 THEN 1250
990 ON C GOTO 1000,1000,1130,1130,1090,1050,1130,1170,1310,1230,1530
1000 REM    PUT  (  OR  -  INTO SYMBOL CELLAR
1010 IF F1 = 1 THEN 1500
1020 LET S = S+1
1030 LET S(S) = C
1040 GOTO 1530
1050 REM    CHECK FOR REST OF  =>  AND  <=>
1060 IF I = L THEN 1310
1070 LET I = I+1
1080 IF F(I) <> 61 THEN 1310
1090 IF I = L THEN 1310
1100 LET I = I+1
1110 IF F(I) <> 62 THEN 1310
1120 REM    HANDLE BINARY CONNECTIVES
1130 IF F1 = 0 THEN 1500
1140 LET F1 = 0
1150 GOSUB 1330
1160 GOTO 1010
1170 REM    HANDLE  )
1180 IF F1 = 0 THEN 1500
1190 GOSUB 1330
1200 IF S = 0 THEN 1500
1210 LET S = S-1
1220 GOTO 1530
1230 REM    HANDLE NEW VARIABLES
1240 LET C = G(F(I)) = F(I)
1250 REM    HANDLE OLD VARIABLES
1260 IF F1 = 1 THEN 1500
1270 LET N = N+1
1280 LET N(N) = C+36
1290 LET F1 = 1
1300 GOTO 1530
1310 PRINT "CONTAINS AN ILLEGAL CHARACTER"
1320 GOTO 2330
1330 REM     SUBROUTINE TO COMPILE INSTRUCTIONS
1340 IF S = 0 THEN 1480
1350 LET D = S(S)
1360 IF D = 1 THEN 1480
1370 IF D >= C THEN 1480
1380 LET P = P+1
1390 LET C(P) = D
1400 IF D = 2 THEN 1490
1410 IF N < 2 THEN 1500
1420 LET N = N-1
1430 LET B(P) = N(N+1)
1440 LET A(P) = N(N)
1450 LET N(N) = P
1460 LET S = S-1
1470 GOTO 1330
1480 RETURN
1490 IF N > 0 THEN 1440
1500 PRINT "IS NOT WELL-FORMED."
1510 GOTO 2330
1520 REM    END OF COMPILATION LOOP
1530 NEXT I
1540 REM
1550 REM    CLEAN OUT SYMBOL CELLAR AND CHECK FOR ERRORS
1560 IF F1 = 0 THEN 1500
1570 IF S = 0 THEN 1610
1580 LET C = 8
1590 GOSUB 1330
1600 IF S > 0 THEN 1500
1610 IF N <> 1 THEN 1500
1620 LET R = N(1)
1630 REM
1640 REM
1650 REM  ********** SET UP FOR PRINTING  **********
1660 REM
1670 REM     FIND VARIABLES OCCURRING IN FORMULA
1680 LET V = 0
1690 FOR I = 65 TO 84
1700 IF G(I) = 10 THEN 1730
1710 LET V = V+1
1720 LET V(V) = I+36
1730 NEXT I
1740 REM    SET TABS
1750 LET T9 = 6
1760 IF V < 11 THEN 1780
1770 LET T9 = INT(60/V)
1780 IF T = 0 THEN 2040
1790 IF N1^V > 500 THEN 1830
1800 PRINT "HAS THE TRUTH TABLE"
1810 GOSUB 1880
1820 GOTO 2040
1830 PRINT "WOULD GENERATE A TRUTH TABLE OF OVER 500 LINES.  HOWEVER";
1840 PRINT " THIS FORMULA"
1850 LET T = 0
1860 GOTO 2040
1870 REM
1880 REM    SUBROUTINE TO PRINT VARIABLES
1890 PRINT
1900 FOR J = 1 TO V
1910 PRINT " "; V$(V(J)-100); TAB(T9*J);
1920 NEXT J
1930 PRINT "FORMULA"
1940 RETURN
1950 REM
1960 REM     SUBROUTINE TO PRINT TRUTH VALUES
1970 FOR J = 1 TO V
1980 PRINT S(V(J)); TAB(T9*J);
1990 NEXT J
2000 PRINT "  "; S(R)
2010 RETURN
2020 REM
2030 REM
2040 REM  **********  CALCULATION OF TRUTH TABLE  **********
2050 REM
2060 FOR Q = 0 TO N1^V-1
2070 LET X = Q
2080 FOR I = V TO 1 STEP -1
2090 LET Y = INT(X/N1)
2100 LET S(V(I)) = X - Y*N1
2110 LET X = Y
2120 NEXT I
2130 FOR I = 1 TO P
2140 LET X = C(I) - 3
2150 IF X < 0 THEN 2180
2160 LET  S(I)  = L( X*N1 + S(A(I)) + 2, S(B(I))+1 )
2170 GOTO 2190
2180 LET S(I) = L(1,S(A(I))+1)
2190 NEXT I
2200 IF T = 1 THEN 2310
2210 IF S(R) = 1 THEN 2260
2220 NEXT Q
2230 IF T = 1 THEN 2250
2240 PRINT "IS A TAUTOLOGY."
2250 GOTO 2330
2260 PRINT "IS NOT A TAUTOLOGY.  AN INVALIDATING ASSIGNMENT TO THE";
2270 PRINT " VARIABLES IS:"
2280 GOSUB 1880
2290 GOSUB 1960
2300 GOTO 2330
2310 GOSUB 1960
2320 GOTO 2220
2330 REM   RESET FOR NEXT FORMULA
2340 FOR I = 65 TO 84
2350 LET G(I) = 10
2360 NEXT I
2370 PRINT
2380 PRINT
2390 PRINT
2400 GOTO 850
2410 END