Can operators ==, ===,! = e! == be considered "fuzzy logic"?

17

Doubt is simple and just out of curiosity, from a mathematical point of view, we have something like comparators by proportion (or from

asked by anonymous 06.03.2018 / 17:36

2 answers

20

It is not a fuzzy logic operator itself. Not heavily. But it could be considered a boolean operator, so would in some way be too diffuse. So, for the question "is a fuzzy logic operator?", I answer 11.39%.

To begin with, we need to define what a type operator is, and then define what is a fuzzy logic operator .

The description of what a BinaryOperator of Java 8 is that a binary operator a binary function in which the operands and output are of the same type. Read the documentation . On top of that, it's like this:

public interface BinaryOperator<T> extends BiFunction<T,T,T> {
}

Mathematically, an n-ary operator is a function that receives n operands of the same type and the return is of the same type. In this case, to consider == , === , != and !== as operators, they should only be considered at the level of operands that are also of fuzzy logic.

But for those in particular, regardless of what the operands are, the return is only SIM or NÃO . No third term.

But what is Boolean logic? Formally, it is composed of 3 axioms:

  • identity
  • Non-contradiction
  • third excluded

You can read more about this in this answer . And what is fuzzy logic? It is a change in these axioms, more specifically the removal of the excluded third. In case, fuzzy logic allows you to have something 11.3% true. The change is that there are 2 values (already provided in Boolean) and that there is a continuous interval between these values.

In this case, Boolean logic can be mapped to diffuse as follows:

  • SIM ==> 1
  • NÃO ==> 0

Counter-mapping is not possible. The cardinality of the Boolean value set is finite, it can not do a bijection to the continuum which is the set of diffuse values. You can even overcharge, but it would not be the inverse function. If there is a function that transforms boolean values into diffuse calling bool2fuzzy and the function that converts from fuzzy logic to boolean called fuzzy2bool , the following formulas are correct:

seja fuz uma variável pertencente a Difuso
se fuz não pertencer a {0, 1}:
    bool2fuzzy(fuzzy2bool(fuz)) != fuz
senão:
    bool2fuzzy(fuzzy2bool(fuz)) == fuz

Operators in programming language vs operators in mathematics

Well, I must have made a mess in your head, would it? Yes or no? 67%?

In math, a (binary) operator looks something like this:

Inprogramminglanguages,wedonotusethenotionpuremathematicsofwhatanoperatoris.Forexample,youcan"123" + 4 in PHP, Java and other languages. In this case, programming languages use syntactic operators . A syntactic operator does not enter into the realm of mathematics, but into the realm of syntax. In case, for binary syntactic operator it fills the space of <op> in the grammatical production below:

So,inthecaseofprogramminglanguages,thestructuredetermineswhethersomethingiscalledanoperatorornot.

Conclusion

  • binaryoperatorsinmathematicsmap2objectsintoathirdobject,providedthatall3objectsbelongtothe"same universe"
  • programming languages call "operators" something that fits into the operating structure
  • Comparison, strong or loose, equality or difference, are operators of Boolean logic (mathematically speaking when dealing with input Boolean values)
  • Comparison, strong or loose, equality or difference, are 11.39% fuzzy logic operators
  • This answer is 73% correct
08.03.2018 / 17:47
6

It has nothing to do with one thing with another. The presence of different equality operators has to do with "weak typing".

== e! = test equality, and if necessary implicitly convert the type of one of the compared values to make the comparison feasible. For example, "2" == 2 is true because the string is converted to number before making the comparison. But there is nothing fuzzy: "2" == 2.0000000001 remains false.

Something similar happens with other operators, so PHP has a specific concatenation operator, because "2" + "2" returns 4, then "2". "2" returns "22".

Already === and! == test identity , which for simple types is the same as equality without type conversion. "2" === 2 is false, "2" === "2" is true, 2 === 2 is true.

Taking advantage of the opportunity, some concepts referring to types:

Poor typing: Implicit conversions. Examples: Javascript, PHP.

Strong typing: does not do implicit conversions. Examples: Python, C, C ++ ...

Dynamic typing: a variable can change type over the scope. Examples: Python, PHP, Javascript.

Static typing: a variable can not change type. Examples: C, C ++.

Although each language has a character, there are almost always exceptions. For example, Python, C, and C ++ use strong typing, but they allow the use of variables of other types instead of a Boolean condition, making conversion implicit. It is also common to "automatic type promotion" when e.g. an integer is added to a floating point.

Ultra-modern languages like Swift, Rust, Go tend strongly to typing strong and do not even do type promotions, nor automatic conversion between numeric types.

    
14.03.2018 / 08:31