TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: If n is prime than n is uneven

2 pointsby moedersmooisteover 3 years ago
Next to my daytime job as a data engineer I'm doing some basic computer science courses. Currently I'm studying a book on logic. According to the truth table for material implication, the material implication in the title is true for n = 6. I find this very hard to accept. Have any of you swallowed this?

4 comments

PaulHouleover 3 years ago
Welcome to the illogical world of logic.<p>If the number 6 was both prime and even it would disprove the implication<p><pre><code> X prime and X != 2 -&gt; X odd </code></pre> But so long as the left hand side is false, the facts are compatible with the implication so it is ‘true’.<p>I am fascinated with all of the ways logic breaks down as you try to use it as a tool for decision making. Conventional programming languages assume that events happen in some specific sequence, but in the case of logic you can work forwards or backwards. A practical system needs to be restrained from trying to infer true but irrelevant facts. Kurt Godel’s work indicates just one kind of trouble logic can get you into but the problems of reasoning with uncertainty are an absolute bear unless you impose a causal structure of some kind.<p>So I am on the side of McCoy vs Spock and think ‘rationalists’ just call themselves that so they can accuse everyone else at being irrational. Logic will probably disappoint you like it disappointed Whitehead and Russel.
评论 #29693615 未加载
bjourneover 3 years ago
Yes, barely. :) Implications work as the following code:<p><pre><code> def f(n): if is_prime(n): return not is_even(n) else: return True </code></pre> What is the value of f(6)? True is returned in the else-clause because this is an example of a vacuous truth. <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Vacuous_truth" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Vacuous_truth</a>
zaikover 3 years ago
Consider the statement &quot;If it rains the street is wet&quot;. If it doesn&#x27;t rain you would still accept the statement even if the street was dry. Now consider &quot;If 6 is prime then 6 is uneven&quot;, which is true - because 6 is not prime.
_0ffhover 3 years ago
Yeah, sure!<p>As n=6 is not prime, the implication is true whether n is even or not.