# [Community Puzzle] When pigs fly

https://www.codingame.com/training/expert/when-pigs-fly

Created by @UnicornP,validated by @Katie,@darynka_xo and @Djoums.
If you have any issues, feel free to ping them.

I donâ€™t understand test case 9 (Final Test). According to me, the answer should be â€śNo pigs can flyâ€ť.

I think the answer given â€“ â€śSome pigs can flyâ€ť â€“ would be justified as followed:
[A] Chickens with beaks can fly (from statements 7, 8, 9)
[B] Some llamas with mouths are chickens with beaks (statement 2)
[C] Some llamas with mouths can fly (A + B)
[D] All llamas with toenails are pigs (statement 5).
However, we cannot conclude that â€śsome pigs can flyâ€ť from (C + D), as we have no way of knowing that there are some llamas that have both mouths and toenailsâ€¦ which I suppose is overlooked by the solution???

Anyone could give me some help with this? Thanks

1 Like

Itâ€™s actually a question we had during the validation process, hereâ€™s the answer I came up with :

Step 1, from those facts :
CHICKENS with BEAKS are LLAMAS with MOUTHS
GEESE are CHICKENS
GEESE have BEAKS
BEAKS are TOENAILS
You get : some GEESE with TOENAILS are LLAMAS (technically with MOUTHS but we donâ€™t care).

Then step 2 :
LLAMAS with TOENAILS are PIGS
Combined with the result of step 1 you can say : some GEESE with TOENAILS are PIGS

And finally :
CHICKENS with TOENAILS are TREES that can FLY
Tells you that some GEESE with TOENAILS are TREES that can FLY, which combined with step 2 tells you that some PIGS are TREES that can FLY.

2 Likes

There is a flaw in your reasoning however: from â€śsome GEESE with TOENAILS are PIGSâ€ť and â€śsome GEESE with TOENAILS are TREES that can FLYâ€ť, you cannot deduce that â€śsome PIGS are TREES that can FLYâ€ť (the GEESE that are PIGS might not be the same GEESE that can FLY).

This is easily fixed though, as you have â€śall GEESE with TOENAILS are PIGSâ€ť and â€śall GEESE with TOENAILS are TREES than can FLYâ€ť (rather than just some). And from the former you can deduce â€śsome PIGS are GEESE with TOENAILSâ€ť (logically flawed, but this assumption is well specified in the puzzle description).

Yes step 1 should say all GEESE with TOENAILS are LLAMAS, that solves the problem.
I like this test, your program can get it right without you understanding why

Continuing the discussion from [Community Puzzle] When pigs fly:

I still donâ€™t follow this. Do the rules explain how we can deduce the existence of â€śGEESE with TOENAILSâ€ť? It seemed reasonably clear to me that only pure â€śObjectâ€ť categories would be guaranteed to be non-empty, as the mere existence of some combination of attributes shouldnâ€™t imply the existence of individuals that meet all of those attributes. In retrospect, I gather that thatâ€™s not the intent.

So, does the fact that â€śGEESE with TOENAILSâ€ť is mentioned on the left-hand side of an â€śareâ€ť statement imply that some member of such a set exists? Would it be the same if it were on the right? Has anyone else worked on this puzzle since then?

Some X can fly means that X has a subcategory that can fly. This subcategory might be empty, it is not questionned here.

Continuing the discussion from [Community Puzzle] When pigs fly:

I do not see the problem here in the last test case:

(a) GEESE are CHICKENS
(b) CHICKENS with BEAKS are LLAMAS with MOUTHS
(c) MOUTHS are HOLES
(d) GEESE have BEAKS
(e) LLAMAS with TOENAILS are PIGS
(f) PIGS are TREES that can WALK
(g) CHICKENS with EYES and TOENAILS are TREES that can FLY
(h) BEAKS are TOENAILS
(i) CHICKENS have EYES

You take a geese
with (a) it is a chicken
with (d) it have beaks
with (h) it have toenails
with (b) it have mouths and it is a llama
with (e) it is a pig ***
with (i) it have eyes
with (g) it is a tree and it flies**

So a geese is a pig than can fly !

Thatâ€™s all !

3 Likes

I just solved it and here is the reformulation of the problem I used:

if "PIGS" implies "FLY":
-> "All pigs can fly"
else if any category implies "PIGS" and also implies "FLY":
-> "Some pigs can fly"
else:
-> "No pigs can fly"

Of course you donâ€™t want to consider any possible category (or the category â€śPIGS that can FLYâ€ť would always work for second option).
Just consider categories that are actually present in the rules.

1 Like

Arg! Validator 7 fails for me, while all the tests pass.

2 Likes

Hey guys,
If you want to test your code :
[PINGS with WINGS are GODS, GODS with WINGS can FLY] , the answer should be â€śSome PIGS can FLYâ€ť
If you pass this one you can try that one :
[PINGS with WINGS are GODS, GODS with WINGS and MOUTH can FLY, PIGS have MOUTH] , the answer should also be â€śSome PIGS can FLYâ€ť
Best regards

2 Likes

Same here, but I fail validator 9 as well. I must be missing some subtle effect in large loopsâ€¦

Hi
I donâ€™t understand the test case #6. I donâ€™t see why we can conclude that â€śNo pigs can flyâ€ť. I think we canâ€™t conclude anything because we donâ€™t know anything about pigs having limbs. So all answers seem possible.
Thanks

1 Like

I think thereâ€™s are two implicit assumptions at play:

1. PIGS exist.
2. If no path through the explicit rules exists that indicates that PIGS â€śareâ€ť, â€śhaveâ€ť, or â€ścanâ€ť do something, then they donâ€™t. PIGS are just entities with no attributes in that case.

Another way to think about it is to change in your mind what the output statements are to the following three possibilities:

1. With these rules I can prove that all PIGS fly.
2. With these rules I can prove that some PIGS fly.
3. The rules present are insufficient to conclude that any PIGS fly.
5 Likes

Hi,
first thanks Nowis5, your sentences help me.

I have some other sentences what i created

[1] â€śPIGS that can RUN are GODSâ€ť, â€śGODS can FLYâ€ť the answer should also be â€śSome PIGS can FLYâ€ť
[2] â€śPIGS that can RUN are GODSâ€ť, â€śGODS that can RUN and EAT can FLYâ€ť, â€śPIGS can EATâ€ť the answer should also be â€śSome PIGS can FLYâ€ť
[3] â€śPIGS with WINGS that can RUN are GODSâ€ť, â€śGODS can FLYâ€ť the answer should also be â€śSome PIGS can FLYâ€ť
[4] â€śPIGS have WINGSâ€ť, â€śMOUTH are WINGSâ€ť, â€śGODS with MOUTH can FLYâ€ť, â€śPIGS are GODSâ€ť the answer should also be â€śSome PIGS can FLYâ€ť
[5] â€śPIGS with WINGS are GODSâ€ť, â€śMOUTH are WINGSâ€ť, â€śGODS with MOUTH can FLYâ€ť the answer should also be â€śSome PIGS can FLYâ€ť

Most importantly, to pass the test (7) after you submit your solution you need to reevaluate sentences you already check ! maybe you say one element are for some pigs but you know after itâ€™s for all pigs !

But we donâ€™t know if there are PIGS that can RUN.

This puzzle seems overrated with its â€śVery Hardâ€ť difficulty.
I know that it can be an endless debate, but this puzzle is easier that the logic puzzle â€śEinsteinâ€™s riddle solverâ€ť that is rated as an hard puzzle.
In my opinion this puzzle is average (parsing is not very difficult), but I set it as a â€śhardâ€ť puzzle.

4 Likes

If you solve both, then your average solved difficulty wonâ€™t suffer

There is a special note for this case in puzzle description:

Note for logicians and mathematicians : The statement (2) is not an hypothetical proposition, it implies that MICE with WINGS do exist. In a nutshell: All objects evoked are supposed to exist.

Obviously, â€śPIGS that can RUNâ€ť were evoked thus we know they exist by puzzle definition.