How to resolve the algorithm Ternary logic step by step in the J programming language

Published on 12 May 2024 09:40 PM
#J

How to resolve the algorithm Ternary logic step by step in the J programming language

Table of Contents

Problem Statement

In logic, a three-valued logic (also trivalent, ternary, or trinary logic, sometimes abbreviated 3VL) is any of several many-valued logic systems in which there are three truth values indicating true, false and some indeterminate third value.
This is contrasted with the more commonly known bivalent logics (such as classical sentential or boolean logic) which provide only for true and false. Conceptual form and basic ideas were initially created by Łukasiewicz, Lewis and Sulski. These were then re-formulated by Grigore Moisil in an axiomatic algebraic form, and also extended to n-valued logics in 1945.

Note:   Setun   (Сетунь) was a   balanced ternary   computer developed in 1958 at   Moscow State University.   The device was built under the lead of   Sergei Sobolev   and   Nikolay Brusentsov.   It was the only modern   ternary computer,   using three-valued ternary logic

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Ternary logic step by step in the J programming language

Source code in the j programming language

not=: -.
and=: <.
or =: >.
if =: (>. -.)"0~
eq =: (<.&-. >. <.)"0


   not 0 0.5 1
1 0.5 0

   0 0.5 1 and/ 0 0.5 1
0   0   0
0 0.5 0.5
0 0.5   1

   0 0.5 1 or/ 0 0.5 1
  0 0.5 1
0.5 0.5 1
  1   1 1

   0 0.5 1 if/ 0 0.5 1
  1   1 1
0.5 0.5 1
  0 0.5 1

   0 0.5 1 eq/ 0 0.5 1
  1 0.5   0
0.5 0.5 0.5
  0 0.5   1


not=: -.
and=: *
or=: *&.-.
if =: (or -.)"0~
eq =: (*&-. or *)"0


   not 0 0.5 1
1 0.5 0

   0 0.5 1 and/ 0 0.5 1
0    0   0
0 0.25 0.5
0  0.5   1

   0 0.5 1 or/ 0 0.5 1
  0  0.5 1
0.5 0.75 1
  1    1 1

   0 0.5 1 if/ 0 0.5 1
  1    1 1
0.5 0.75 1
  0  0.5 1

   0 0.5 1 eq/ 0 0.5 1
  1    0.5   0
0.5 0.4375 0.5
  0    0.5   1


and=: *.
or=: +.


   0 0.5 1 and/ 0 0.5 1
0   0 0
0 0.5 1
0   1 1

   0 0.5 1 or/ 0 0.5 1
  0 0.5   1
0.5 0.5 0.5
  1 0.5   1


  

You may also check:How to resolve the algorithm Golden ratio/Convergence step by step in the Hy programming language
You may also check:How to resolve the algorithm RPG attributes generator step by step in the MiniScript programming language
You may also check:How to resolve the algorithm Matrix transposition step by step in the Lambdatalk programming language
You may also check:How to resolve the algorithm Floyd-Warshall algorithm step by step in the Wren programming language
You may also check:How to resolve the algorithm Enumerations step by step in the PHP programming language