Logical operator "IMP"

What is the preferred source code implementation of the logical operator IMP that should be included in HexLib.TRU?

For starters, Imp (or any of the logical operators) can be defined in terms of Not( Or), that is Nor, as first done by the famous logician C.S. Peirce (1839-1914):

Using DEF NOR (that is DEF And, and then "Not( Or( a, b))"):

p IMP q == ( ( ( p NOR p) NOR q) NOR ( ( p NOR p) NOR q))

However, is there a way to include source code directly in HexLib.TRU, then recompile as an object file, to produce faster running code, and simply to invoke it as:

LIBRARY "HexLib.TRU"
DECLARE Or, Imp

where the function invocation is "Imp( a, b)".

Thank you!

Comments

HEXLIB

Hi,

You need the source code file for HEXLIB.TRU

Read through the code and make sure you understand how this EXTERNAL file is constructed and how it uses DEF Convert$(number,base). Include your own code for IMP, NOT and NOR, then compile in the normal way to produce a TRC file. AND, OR and XOR are already included in HEXLIB and should be a good guide as to how to construct the code for NOT, NOR and IMP.

Big John

HEXLIB

I already own the source code for HEXLIB and know how external functions and modules work, but the reply does not answer the question.

What is needed is the actual source code for IMP, that is, what is the line of code below for

LET Imp = ????????????????

in the block of code below:

DEF And( a, b)
LET m = 1
LET b = Int( b)
DO
CALL Divide( a, 2, a, aa)
CALL Divide( b, 2, b, bb)
LET r = r + m * aa * bb
LET m = 2 * m
IF b = -1 then
LET r = r + m * a
EXIT DO
END IF
LOOP while b <> 0
LET And = r
END DEF

DEF Or( a, b)
DECLARE DEF And
LET Or = a + b - And( a, b)
END DEF

DEF Xor( a, b)
DECLARE DEF And
LET Xor = a + b - 2 * And( a, b)
END DEF

DEF Imp( a, b)
DECLARE DEF And ! , Or, Xor
LET Imp = ??????????????
END DEF

I already programmed NOR, and hence IMP, as an internal function, but I want the above line of code which should run faster from the compiled external library.