Talk:Ternary logic

From Rosetta Code

test case

re: "Kudos (κῦδος) for actually thinking up a test case algorithm where ternary logic is intrinsically useful, optimises the test case algorithm and is preferable to binary logic".

I know that calculating Perfect numbers and Matrix-exponentiation_operator in binary has some algorithmic advantages. I imagine that there is some problem would benefit from Ternary logic. Any hints or suggestions?

NevilleDNZ 07:21, 26 August 2011 (UTC)

On first reading, it seems like you are implementing an analogue of the cmp function from C and C based languages. Or am I completely misunderstanding? --Thundergnat 11:03, 26 August 2011 (UTC)

Task structure

How about adding a truth table for implementation and cutting the history/leaving a link to the history?--Paddy3118 08:29, 26 August 2011 (UTC)

Just added the Logic Operators in Truth Tables. NevilleDNZ 11:33, 26 August 2011 (UTC)

C example

Could have been better (I could have bothered to do a table), but I hope the C example is sufficiently and approriately clear, fast and clever. Hopefully, I'll get around to implementing the C++ version using templates. --Michael Mol 17:23, 26 August 2011 (UTC)

if a then b

What is if a then b condition? It's not a straightforward conditional like if a then: b; else:a;. Looks more like if we define false < true, and "maybe" means "unknown state of either true or false", the "if a then b" condition is the same as a <= b. Some clarification? --Ledrug 01:07, 27 August 2011 (UTC)

if a then b is logically equivalent to (not a) or b. --Kernigh 01:27, 27 August 2011 (UTC)
That's equivelant to a <= b, I was more curious where the "if then" notation came from. --Ledrug 01:29, 27 August 2011 (UTC)
It started as plain old "implies" probably. Then something had to be used for "maybe". I'd say ask whoever came up with this. It certainly wasn't invented for this task. --Mwn3d 03:06, 27 August 2011 (UTC)

I included ⊃ and ≡ as (for some reason) they are part of the original ALGOL 60 specification. (Strange but true!) But in binary ⊃ does not seem to useful, AFAIK I have never used it. But in the case of Ternary logic ⊃ seems to be useful in tautologies so I included it. Indeed @Kernigh is correct to say it is logically equivalent to (not a) or b

Note: ⊃ is the same as → and ⇒ operations. c.f. List of logic symbols Also ⇔, ≡ and ↔ are equivalent.

BTW: the operators /\ and \/ were originally part of the C programming language, they appear to be borrowed from the ALGOL ∧ and ∨ operators. Indeed the character "\" was included in ASCII for this specific purpose.

NevilleDNZ 04:04, 27 August 2011 (UTC)