Can the shunting-yard algorithm handle logic processing?

AI Thread Summary
Logic processing can utilize binary values, where 1 represents true and 0 represents false, allowing for arithmetic operations to be applied to logical operations. For instance, an "OR" operation can be executed using addition, while an "AND" operation can be performed through multiplication. The shunting yard algorithm is questioned for its ability to manage sequences of logical operations, with an emphasis on the necessity of setting operator precedence correctly. The discussion highlights that boolean and arithmetic operators can be treated similarly, as both can be processed in stack-based systems, a practice established for decades. In programming languages like C and C++, binary operators encompass arithmetic, relational, logical, and bitwise operations, all of which return results based on two input values. Additionally, C++ allows for the creation of custom operand types, enabling the redefinition of operator functions. However, the implementation of infix code in C++ is determined by the compiler, which may prioritize optimization over the use of the shunting yard algorithm.
synch
Messages
84
Reaction score
11
Looking at logic processing with 1 meaning true and 0 meaning false..an "OR" could be implemented using an addition operation , an "AND" using multiplication, and so on. I am wondering if the shunting yard algorithm would handle the sequences of logic based operations ? The precedence of the operators would have to be set appropriately of course..
 
Technology news on Phys.org
The boolean operators are just like the arithmetic operators.
No distinction need be made between boolean or arithmetic operators.
They can all be processed in a stack based processor, and have been for the last 70 years.
 
  • Like
Likes QuarkyMeson
synch said:
Looking at logic processing with 1 meaning true and 0 meaning false..an "OR" could be implemented using an addition operation , an "AND" using multiplication, and so on. I am wondering if the shunting yard algorithm would handle the sequences of logic based operations ? The precedence of the operators would have to be set appropriately of course..
In the computer languages C and C++, "binary operators" take two values and return a result. So, they are the kind of operators you are asking about. The binary operators supported by C and C++ include:
Arithmetic operators:
addition(+), subtraction(-), multiplication(*), division(/), modulos(%)
Relational operators (return true of false): <, >, <=, >=, ==, !=
Logical operators: and(&&), or(||)
Bitwise operators: and(&), or(|), exclusive or(^), left shift(<<) and right shift(>>)

Not only that, but in C++ you can create your own operand types and redefine what all of those operators do.

As for the "shunting yard" algorithm, the C++ compiler gets to decide how your infix code is implemented. Since the compiler will be looking for optimization opportunities and to make best use of the computers registers, it may not use "shunting yard".
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top