views:

327

answers:

6

For one of my beginning CS classes, we are going over "truth functional logic."

My question pertains to English translations. Note that ^ is AND; v is (inclusive)OR; ~ is NOT. -> is IF

Well, we had this: "RENT being paid is a necessary condition for staying in BUSINESS"

RENT -> BUSINESS

Whenever we graded everything this was wrong. I asked the teacher why and she said nothing more then that "if there is no then in the sentence, then the antecedent is always last"

I would like some more explanation as to how this is wrong. And how the sentence is not ambiguous. Something more than "there was no then so it's always this way."

Also, a side note: Where did the IF boolean operator come from? I've never heard of such an operator that is basically equivalent in Cish code to a==true?b:true. I have a very hard time grasping it's usage.

edit: The correct answer was

BUSINESS -> RENT
+19  A: 

If you pay rent, you're not necessarily in business. Rent !(->) Business.

However, if you're in business, you must pay rent. Business -> Rent.

McWafflestix
Succinctly explained. +1
Byron Whitlock
Ok.. I think that last sentence helps. This is just so confusing.. Is it normal to have stuff like this in your first semester?
Earlz
@earlz: yes, that’s normal. In fact (at leasy in Germany), Boolean logic is actually a *recap* from high school and only mentioned very briefly in CS. Boolean logic is essential for all the rest of CS because it lays the foundation for *all* arguments pertaining to algorithms.
Konrad Rudolph
Well I mean I was taught boolean logic in my AP programming class in high school, but it was simple stuff represented in Java code. We just solved it with truth tables(which I hate, but fully understand). I mean that I've never seen such "formalness" I guess
Earlz
Yes. It is also normal to struggle with it a little. You can double-check work like this by reading back what you've written (`RENT -> BUSINESS` reads like this: "if RENT then BUSINESS") and seeing if that's really what the original English sentence says (in this case, no: it says rent is necessary, but not that it's sufficient).
Jason Orendorff
Agreed, this is very normal, and important, as Konrad says. For what it's worth, at my university, the Boolean Logic and Set Theory class was a prerequisite for any of the advanced CS classes (rightfully so), and was actually given by the department of Philosophy. Point being, boolean logic is very fundamental. Kudos to Germany for teaching it in high school...
McWafflestix
@earlz: Yes this whole new mathematical rigour is also a typical stumbling block for CS freshmen. Don’t worry, it will pass with practice. I remember that I had *great* difficulties with some of it, in particular the meaning of implication.
Konrad Rudolph
@earlz, the first few semesters of CS often separate the wheat from the chaff. In other words the people who don't really want to be there will switch majors fairly quickly. This stuff is confusing but don't give up. By your 2nd year it will actually get easier conceptually. in the mean time Boolean logic, discrete mathematics, finite autonoma etc. will be your best friends.
Byron Whitlock
+5  A: 

I think it should have been written:

BUSINESS -> RENT

"If you're staying in business, then you're paying rent."

P -> Q

can be stated "P implies Q," "If P, then Q," or "Q if P."

John at CashCommons
excellent answer imo.
ChadNC
+2  A: 

She is right. It is a classic a implies b but b does not imply a. What you are saying business is a necessary condition of paying rent which is wrong.

Byron Whitlock
+1  A: 

Where did the IF boolean operator come from? I've never heard of such an operator that is basically equivalent in Cish code to a==true?b:true. I have a very hard time grasping it's usage.

This operator is more commonly called “implication”. What do you mean by “where did [it] come from”?

And yes, implication is hard to grasp and your mistake is completely typical.

You can explain the implication by noting that under false premises, everything can be explained, even bogus (for example, we can mathematically prove that 1 = 2 if we use the premise that division by 0 is legal). For that reason, 0 -> x is always true, no matter the value of x (i.e. the implication can produce the result).

On the other hand, if your premises are correct, an implication will lead to a correct result, thus 1 -> 1 is true (a true premise implies a true result), and 1 -> 0 is false (a true premise cannot imply a false result).

Konrad Rudolph
+1, Also note that A -> B can be rewritten as !A OR B, which can make it easier to think about.
CBFraser
+1  A: 
!RENT -> !BUSINESS

If you're not paying rent, then you're not in business. This is the "contrapositive" of

BUSINESS -> RENT

If you're in business, then you're paying rent.

Other ways to say this (since a -> b === (!a || b) ):

!BUSINESS || RENT
RENT || !BUSINESS

Either you're not in business or you're paying rent or both (or vice-versa).

!(!RENT && BUSINESS)

You're not both not paying rent and in business (or vice-versa).

ADDED: BTW, this is how resolution works. Put your knowledge into conjunctive normal form, where each clause consists of a disjunction of atomic terms, each of which can be negated. If you know you're not paying rent, then that is a clause, which you can resolve (i.e. cancel terms) with the implication to deduce a new clause, namely that you are not in business.

RENT || !BUSINESS
!RENT
--------
!BUSINESS

Similarly, if you know that you are in business, you can cancel terms to conclude that you are paying rent.

RENT || !BUSINESS
BUSINESS
--------
RENT

That's the attraction of resolution theorem provers - one inference rule covers both forward and backward inference.

It also handles case-reasoning nicely, like if A->C and B->C, and A||B, it lets you conclude C:

1. !A || C
2. !B || C
3.  A || B
----------
4.  B || C  (resolve 3 and 1)
5.  C       (resolve 4 and 2)
Mike Dunlavey
A: 

The key here is the word "necessary." We have here a sentence of the form "X is necessary for Y." What this means is that X must be true for Y to be true. In everyday language we think of this as "Y can not be true unless X is true". And this translates very clearly into "if X is false then Y is false" because if X were false but Y were true then we would be violating Y can not be true unless X is true. But if X is false then Y is false translates symbolically to !X => !Y which has contrapositive Y => X. This is why "X is necessary for Y" is equivalent to Y => X.

Here is an example: being odd is necessary to be prime and larger than two. What this means is that if a number is prime and larger than two, it must be odd because being odd is a necessary condition of being prime and larger than two. Said another way, if a number is prime and larger than two, it must be odd. The converse (if a number is odd it must be prime) is absurd.

This should convince you that X is necessary for Y is equivalent to Y => X.

There is a different but related relationship between statements that takes the following form: "X is a sufficient condition for Y". In everyday language we would say that "knowing X is true is grounds for Y to be true", or X => Y.

These two implicational (it's a word now!) relationships are duals of each other. In fact, in mathematics, a very important form is "X is a necessary and sufficient condition for Y." This means that X => Y and Y => X, or that X <=> Y. We say that X and Y are equivalent, and we sometimes say "X if and only if Y" and sometimes abbreviate it "X iff Y."

Jason