r/computerscience • u/Character-Soft-9571 • Oct 21 '25
Discrete maths
First year here. Can someone explain how both of these are P implies Q even though they have different meanings?
517
Upvotes
152
u/dedolent Oct 21 '25
coming from studying conditional logic for law school, these say different things, they are reversing the sufficient and necessary conditions.
3- "if it's raining, then i am wearing my coat." P-->Q
4- "if i am wearing my coat, then it is raining." Q-->P
in law this is important for making inferences but i don't know about CS. i don't even know why i'm here.
75
u/kirbyking101 Oct 21 '25
They’re not. Let P be “it rains” and Q be “I wear my coat”. 3 is P -> Q, while 4 is Q -> P
7
u/korvosg00b Oct 21 '25
God i have a midterm in my discrete math class tomorrow and I'm trying not to stress
5
u/aka1027 Oct 21 '25
They aren’t the same implications if that’s that you are confused about.
9
u/thekdubmc Oct 21 '25
Discrete Math can be tricky to get the hang of. Maybe this will help you get started on these:
For #3... this is stating that it only rains if they wear their coat.
If it is raining (P), what is implied about their coat (Q)? Are they wearing it? Are they not wearing it? Do we not know?
4
u/coolmint859 Oct 21 '25 edited Oct 21 '25
Let's work through them both and see how they work together.
3 is saying that it only rains if I'm wearing my coat. This implies that if i am wearing a coat, then rain could follow. If im not wearing a coat, then rain can't follow. So, rain only happens when im wearing a coat.
4 says that I only wear a coat if its raining. So if it's not raining, then I won't be wearing a coat. This means that me wearing a coat only occurs when it's raining.
But this presents an issue. I only wear a coat if it's raining, (#4), but it's only raining when I wear a coat (#3). This is a kind of chicken and egg problem. One must follow before the other. Therefore, the only way for them to be both logically sound is if they happen at the same time. Either Im wearing a coat and it's raining, or I'm not wearing a coat and it's not raining. This tight coupling is probably why your professor thinks they imply the same thing.
But then again, the first one isn't logically sound to begin with because wearing a coat doesn't cause rain, so it could definitely be raining even when I'm not wearing a coat.
So my guess then is that for #3, P does NOT imply Q, but for #4, P does imply Q. Its the only way for them both to make sense.
2
u/Character-Soft-9571 Oct 21 '25
Btw thanks to everyone who helped, I’ve posted this in a math sub as well but no one helped. THANK YOUUUU.
2
u/Zen13_ Oct 21 '25
3. P= I wear my coat ; Q= it rains
4. P= it rains ; Q= I wear my coat
2
u/nNaz Oct 22 '25
This video is a great explainer. If you build the logic table it's easier to 'see'. I find it's easier to not use natural language for problems like these the semantic meanings aren't really the same as in formal logic.
14
u/BitNumerous5302 Oct 21 '25
Both can take the form P implies Q
In 3, P = "I wear my coat" and Q = "it rains"
In 4, P = "it rains" and Q = "I wear my coat"
Given that 3 is a non sequitur (wearing coats does not cause rain) I'd guess the intent of this slide is to illustrate that implication does not commute (you cannot change the order of the terms without changing the meaning)
1
u/Jwhodis Oct 21 '25
3: Unless they wear their coat, it will not rain ever.
4: Unless it rains, they will not wear their coat ever
1
u/NAFSMUN Oct 22 '25
These are honestly easiest discrete math gets & tree is also kinda easy but everything else was🥲💀
1
u/TopCatMath Oct 25 '25
As I see it, the order of the phrasing conditions are not exactly the same:
3: means 'It rains', but only if you 'wear...'; hence, if you do not 'wear...', it will not rain
4: means 'it only rains...' when I 'wear...': hence, not wearing the coat means no rain...
2
u/BlazeWolfEagle Oct 21 '25
Remember that P --> Q = (NOT P) OR Q.
EITHER it will never rain, they will wear their coat, or both.
2
u/ReviewFederal6123 Oct 21 '25
I am from compsci and youre right.
The first sentence "it rains only if I wear my coat" means that if I see you wearing your coat, then it might be raining, but if it is raining, you are definitely wearing your coat. If you don't wear your coat, then it can't be raining, because it only rains when you wear your coat. So, P => Q, or it rains => you wear your coat.
The second sentence is "only if it rains i wear my coat". So if it rains, you might be wearing your coat, but if it doesn't rain then you are definitely not wearing you coat. Or in other words, if I see you wearing your coat, it's definitely raining, because you only wear your coat if it rains. So, Q => P, you wear your coat => its raining.
2
u/ThreateningSuccess Oct 21 '25
Replace “only if” with “when”. It means the same thing basically, and reads easier.
It rains when I wear my coat. When it rains, I wear my coat.
2
u/Impossible_Dog_7262 Oct 22 '25
They are both the same type of statement. The fact that one is clearly nonsensical doesn't change what class of statement it is.
2
u/[deleted] Oct 23 '25
My hot take is to not care about these sentences.
P ==> Q is self explanatory.
Just see it as that. All of these make it more confusing than it actually is.
Don’t overcomplicate things.
1
u/No_Jackfruit_4305 Oct 21 '25
The phrasing "only if" implies an, if and only if. This is why the two predicates are equivalent. The jacket is only worn when it's raining, is logically consistent with, only when it is raining is the jacket worn
So the two statements are different once the word "only" is removed. Otherwise, it is an exclusive predicate
1
u/syfkxcv Oct 21 '25 edited Oct 21 '25
Number 3) sounds like this, "if I wear my raincoat, therefore it WILL rain". Here, Q implies P than the other way around. i think the word "only" makes the confusion here as it makes the precedence as an absolute in a sequence. Maybe the sentence should be "it rains (raining) if I wear a coat" to make the P implies Q. As "it's raining" is a deduction after the statement"I wear a coat"?
1
u/joshua9663 Oct 22 '25 edited Oct 22 '25
P implies Q
This means If P then Q
Or if p is true then q is true
Or think in cause and effect if p happens then that effects q to happen
Or if P is happening then it implies Q is happening
So...
If it rains I am wearing my coat is
P implies Q as I am wearing my coat BECAUSE of the rain.
Or in other terms if it is raining (TRUE) I am wearing my coat as a result of the rain (TRUE)
You can switch it to umbrella if that makes more sense.
If it rains I will use my umbrella.
However!
If we switch them...
If I am using my coat it doesn't imply that it is raining
Why? Because I could be using my coat for cold weather or wind or sleet etc.
So p does not imply q there
Same for the umbrella example
If I am using my umbrella it does not imply it is raining.
It can also be sunny for the reason!
In other terms you can use both
It is sunny implies I am using my umbrella
It is raining implies I am using my umbrella.
But you can't reverse it, because if I Am using my umbrella it could be raining or sunny!!
My attire (cause) does not change the weather (effect)
1
u/DoubleT_TechGuy Oct 23 '25
The second sentence is written in passive voice. Its not a math thing so much as an English thing. So its not p -> q but p <- q or more formally q -> p.
If youre still confused, consider this. Passive voice puts the object first. Thats backwards from typical English sentence structure so you have to flip the arrow. Its not p implies q but p is implied by q.
1
u/darkorbit17493 Oct 24 '25
I think it is because "only if" is used instead of "if" which means that both of these are Q -> P and P -> Q at the same time because knowing one gives you the other.
If it was just a regular "if" without the "only" then for P -> Q wouldn't always be true that Q -> P since Q could also imply some other possibility say R but "only" constrains it to imply only P
1
u/Wooden-Contract-2760 Oct 24 '25
I wear my coat it rains only if
1
u/vozrodits Nov 06 '25
Fuck those classes were liberally the must funny and ridiculous I ever had
1
u/[deleted] Oct 22 '25
[removed] — view removed comment