0

I have just started reading into propositional calculus/logic, and have realised that a lot of the foundational concepts in this area are similar to those encountered in programming. That is, propositions/sentences in logic (due to the fact that they have truth-values), are similar to Booleans in programming. Furthermore, most of the sentential connectives are reflected in the logical operators adopted in programming. For instance, in C++, !, &&, and || behave in the same way that ¬, ∧, and ∨ behave, respectively, in logic.

My question is whether there are (say, C++) "equivalents" for the logical operators of implication (->) and equivalence (<->)? If so, what are they? If not, what is the reason they have they not been adopted? So, although I cannot think of any reason why they would be adopted, I would like to know if there is a specific reason that they are omitted.

1 Answers1

0

Implication can be replaced with <=, and equivalence is ==.

However, unlike && and ||, those don't convert their arguments to bool (since they're not inherently boolean operators).

HolyBlackCat
  • 78,603
  • 9
  • 131
  • 207
  • == is the equality operator equivalence for programming is typically `bool equivalence(T a, T b){return !(a – Sir Demios Aug 26 '22 at 16:55
  • https://www.fluentcpp.com/2017/02/16/custom-comparison-equality-equivalence-stl/ better explanation for equality vs equivalence – Sir Demios Aug 26 '22 at 17:04
  • @SirDemios OP is talking about bools, so there's no difference. But even otherwise, any type for which the two are not the same is utterly broken. Normally (e.g. in C++20 ``) the difference is that "equivalence" can be true for objects that are "distinguishable" from one another, but deciding what that means is up to the programmer. – HolyBlackCat Aug 26 '22 at 19:06