Problem with logical operators precedence

81 Views Asked by At

I'm studying logical operators for school and there's a weird question that keeps bugging me even though it seems pretty basic.
I was asked to evaluate the proposition : p -> q -> r with p, r are False and q is True.
I tried evaluating it from left to right like this: ( ( p -> q ) -> r ) and got wrong answer.
Then, I checked my result with an online tool at https://web.stanford.edu/class/cs103/tools/truth-table-tool/ and it evaluates the proposition from right to left like this: ( p -> ( q -> r ) ) ( you can see in this picture ). I tried calculating the result again with this order and it was accepted as right answer !
That's really odd because my lecturer said that if operators are at the same level then the proposition should be evaluated from left to right. Have I misunderstood something ?

2

There are 2 best solutions below

6
On BEST ANSWER

Well, the operations $\wedge,\vee,\Leftrightarrow$ are left-associative while the operation $\Rightarrow$ is right-associative. So

$[p\Rightarrow q\Rightarrow r ]\Longleftrightarrow [p\Rightarrow (q\Rightarrow r)].$

0
On

The full convention is as follows: Outermost parentheses may be omitted, and in the absence of parentheses, the order of operations is

  1. $\lnot$
  2. $\land$
  3. $\lor$
  4. $\impliedby $ and $\implies$ have equal precedence
  5. $\iff$

$\impliedby$ is left associative, and as Wuestenfux stated, $\implies$ is right associative while $\iff$ is left associative.

An example using everthing would be: $a\lor b\impliedby ~a\iff a\land\lnot a\lor b$, which reads $(a\lor b\impliedby (~a\iff ((a\land\lnot a)\lor b)))$.