-5

How to simplify these compound logical expressions?

!((x <= 5) && (y == 10) && (z < 5))  // 1
!(x == 10) || !((y == 5) || (z < 0)) // 2

I have read the rule for simplification, but I am not understanding what to do with ==.

This is from "Programing in ANSI C" written by E Balagurasy While designing decision statements, we often come across a situation where the logical NOT operator is applied to a compound logical expression, like !(x&&y || !z). However,a positive logic is always easy to read and comprehend than a negative logic. In such cases, we may apply what is known as De Morgan's rule to make the total expression positive.The rule is as follows: "Remove the parentheses by applying the NOT operator to every logical expression component, while complementing the relational operators." Example: !(x&&y || !z) becomes !x || !y && z.

  • 1
    I am guessing you want the negation normal form? The opposite of `==` is `!=`, by the way. I don't understand what you mean by "where there is no parentheses". I don't see anywhere where there are none. – Tim Seguine Dec 10 '13 at 17:27
  • The first step would be to add some whitespace to make the expressions more readable. The next step is to show us exactly what you've done so far. – Praetorian Dec 10 '13 at 17:27
  • 1
    some kind of. Me and my friends nedd it for assignment and class test. – user3087840 Dec 10 '13 at 17:27
  • so you are saying that !(x==10) will be !x!=10 ??@Tim – user3087840 Dec 10 '13 at 17:31
  • No `!(x==10)` is `x!=10` You are going to have to be more specific with your question though. There is no canonical definition of simpler. Your teacher probably asked you to do a specific thing I am guessing? – Tim Seguine Dec 10 '13 at 17:31
  • While designing decision statements, we often come across a situation where the logical NOT operator is applied to a compound logical expression, like !(x&&y || !z). However,a positive logic is always easy to read and comprehend than a negative logic. In such cases, we may apply what is known as De Morgan's rule to make the total expression positive.The rule is as follows: "Remove the parentheses by applying the NOT operator to every logical expression component, while complementing the relational operators." Example: !(x&&y || !z) becomes !x || !y && z. This is from "Programing in ANSI C"@Tim – user3087840 Dec 10 '13 at 17:45
  • Ok, then you do want the negation normal form. Taylor's answer should help you then. If it helped you, you should consider marking it as accepted. – Tim Seguine Dec 10 '13 at 19:38

1 Answers1

2

I'll give you some hints, so as to not do your homework for you:

!(a || b || c) = (!a && !b && !c)

!(a && b && c) = (!a || !b || !c)

!(a == b) = (a != b)

!(a <= b) = (a > b)

You should be able to take it from there.

Taylor Brandstetter
  • 3,523
  • 15
  • 24