1

I'm trying to write a function in Python that takes it argument as a Python list and returns a boolean value based on the truth vale of the proposition $E(x) \to \exists y \text{ s.t. } x=2y$, where here the proposition $E(x)$ means 'x is even'.

print(check_prop([-2,-1,0,1,2,3])) gives an output true

print(check_prop([-2,-1,0,1,3,4])) gives an output false

I don't quite understand how the truth value is true in the first case and false in the second.

chi
  • 14,564
  • 1
  • 30
  • 40
  • Python questions are off-topic here. – Yuval Filmus Sep 22 '17 at 09:20
  • This is not a question about programming languages, or logic, but a purely Python question. – chi Sep 22 '17 at 14:04
  • @chi Did you create the "python" tag, there? If so, I don't think that was a good idea at all. When people find a tag like that, it suggests to them that their python programming questions are on-topic. – David Richerby Sep 23 '17 at 16:00
  • @DavidRicherby We already have C and Java tags, which explicitly state that the programming questions are off topic. The Python tag I created has a similar text. I think we should either use all such "warning" tags, or none of them. Currently, the PL tag is being often misused for off-topic programming questions, which is worse for its followers/subscribers. I completely agree on us needing a more effective solution to avoid programming questions here. Ideally, low rep users should need to confirm a question with often-wrong tags (?) Perhaps this should be discussed on meta. – chi Sep 23 '17 at 16:43
  • @chi The warning tag is good but, as I just demonstrated -- nobody ever reads them. :-( – David Richerby Sep 23 '17 at 16:57
  • 1
    @DavidRicherby Indeed. I wish that, when a question is about to be submitted with such tags, an additional confirmation was required, forcing the posters to read the tag, or maybe pointing to StackOverflow as an alternative. Or something like that. I don't think the tags existence attracts more questions, though, since they would mostly get tagged PL otherwise. (This is only my expectation, not a hard fact, of course. -- if I am wrong on this, I'd propose to delete all the off-topic tags.) – chi Sep 23 '17 at 18:39
  • @chi I think there is a way setting certain tags so that people who use them have to click to confirm that they've read the tag description. Unfortunately, I can't remember the name of it or produce a Google search term that will show me the thread I'm thinking of on meta. Please do propose this on Meta -- it's an excellent idea that I'd definitely support. And it makes the off-topic tags actually rather valuable. – David Richerby Sep 23 '17 at 19:02
  • 1
    @DavidRicherby Done. – chi Sep 23 '17 at 20:36

1 Answers1

0

The predicate whose truth value you're trying to check states the following:

For every even number $x$ in the list, $x/2$ is also in the list.

This holds in the first case: the even numbers are $-2,0,2$, and indeed $-1,0,1$ are in the list, but not in the second case, since $4$ is in the list but $2$ isn't.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503