Halting Problem in Python - Computerphile

No need to understand Turing machines to comprehend the halting problem. Professor Thorsten Altenkirch has a way of using Python to demonstrate the issue.
Thorsten's Python programming book: bit.ly/2p3r5IT
/ computerphile
/ computer_phile
This video was filmed and edited by Sean Riley.
Computer Science at the University of Nottingham: bit.ly/nottscomputer
Computerphile is a sister project to Brady Haran's Numberphile. More at www.bradyharan.com

Пікірлер: 430

  • @ThorstenAltenkirch
    @ThorstenAltenkirch4 жыл бұрын

    I forgot to say that the impossibility of writing a function that decides the Halting problem shows that many other problems are unsolvable too. For example we cannot write a program that decides wether a logical formula (in predicate logic) is true. We can write a program that translates the halting problem for any program into a logical formula that is true exactly if the program holds. Hence if we had a program that decides logic we could also decide the halting problem. Which we can’t and hence we can’t decide predicate logic either.

  • @AnarchoAmericium

    @AnarchoAmericium

    4 жыл бұрын

    What are some of the consequences of this for computer scientists? For instance, does it affect how we do type checking? Also, this may be presumptuous of me Professor, but could you and Computerphile make a video on the BHK interpretation and the failure of the excluded middle to hold for programs?

  • @scowell

    @scowell

    4 жыл бұрын

    And yet... MU! Credit to Doug Hofstadter.

  • @stensoft

    @stensoft

    4 жыл бұрын

    The usual way to solve this is to allow false negatives: we allow the halting function to return false for the weird function, even when it will halt in that case (or more generally, we allow it to return false for _some_ functions that will halt), but never to return true when it may not halt. This is how formal verification (= proof that an algorithm can't return incorrect or unintended results) works.

  • @peteriddqd

    @peteriddqd

    4 жыл бұрын

    Get a proper keyboard please

  • @DaVince21

    @DaVince21

    4 жыл бұрын

    @@peteriddqd That type of keyboard is very pleasant to type on, FYI.

  • @xetera
    @xetera4 жыл бұрын

    Technically, that code terminates with "NameError: name 'true' is not defined" Capitalization: 1 Halting problem: 0

  • @DavisOfAllTrades

    @DavisOfAllTrades

    4 жыл бұрын

    that is True

  • @mathis8210

    @mathis8210

    4 жыл бұрын

    Thats why i like to write with a nice editor like spyder. If you miss something so obvious it is immediately visible, either through an warning message or in the case of (T/t)rue through color.

  • @oliverking02
    @oliverking024 жыл бұрын

    *cries in PEP 8*

  • @TaiiwoLlort

    @TaiiwoLlort

    4 жыл бұрын

    true

  • @oliverking02

    @oliverking02

    4 жыл бұрын

    @@TaiiwoLlort def holds(fun, arg): Much better

  • @swagatochatterjee7104

    @swagatochatterjee7104

    4 жыл бұрын

    cries in black

  • @chicharrero3884

    @chicharrero3884

    4 жыл бұрын

    amazing photo

  • @charudattamanwatkar8340

    @charudattamanwatkar8340

    4 жыл бұрын

    I scrolled down the comment section specifically to make sure that someone has said this. xD

  • @tnb178
    @tnb1784 жыл бұрын

    The title should say "the wierd holding problem"

  • @hetulbhatt5787
    @hetulbhatt57874 жыл бұрын

    Weird has to have a 'wierd' spelling.

  • @zaraf

    @zaraf

    4 жыл бұрын

    Mind blown

  • @micr0xchip0xverflow6

    @micr0xchip0xverflow6

    4 жыл бұрын

    Vierd is spelt veird

  • @imveryangryitsnotbutter

    @imveryangryitsnotbutter

    4 жыл бұрын

    Oh, it's def wierd, but (fun).

  • @dipi71

    @dipi71

    4 жыл бұрын

    Similarly with »hold«; I'm sure »halt« was intended because of, you know, the halting problem.

  • @finalhourhd8822

    @finalhourhd8822

    4 жыл бұрын

    Hetul Bhatt what if weird is the “weird” spelling?

  • @azertyQ
    @azertyQ4 жыл бұрын

    "Is logic inconsistent?" Gödel: hold my beer

  • @ErikB605

    @ErikB605

    4 жыл бұрын

    We may never know if this comment is complete.

  • @vojtechstrnad1

    @vojtechstrnad1

    4 жыл бұрын

    Turing: halt my beer

  • @allmhuran
    @allmhuran4 жыл бұрын

    I can't get enough of Prof Altenkirch.

  • @therocksaysop

    @therocksaysop

    4 жыл бұрын

    Don't Stop Until You Get Enough haha

  • @finalhourhd8822

    @finalhourhd8822

    4 жыл бұрын

    TheRockSays when will that be?

  • @lawrencedoliveiro9104
    @lawrencedoliveiro91044 жыл бұрын

    1:16 Space before colon, but not after comma. *‌twitch‌*

  • @Shibzzeg
    @Shibzzeg4 жыл бұрын

    I had to watch this twice, but I understand it now, it's a beautiful way to explain it from a different angle. Thank you, professor Altenkirch! :)

  • @CaptainWumbo
    @CaptainWumbo4 жыл бұрын

    proof by contradiction huh. how dare you bring math into my sweet sweet world of making the computer do the math for me.

  • @joshuahillerup4290

    @joshuahillerup4290

    4 жыл бұрын

    But programming is just applied math, and by "applied" I mean getting a computer to do the math for you.

  • @CatoSierraWasTaken

    @CatoSierraWasTaken

    4 жыл бұрын

    I write or hear at least 4 contradiction proofs a week from one senior level CS class; and the ones from previous semesters were worse. What kind of CS are you doing where you aren't doing proofs?

  • @cabbageman

    @cabbageman

    4 жыл бұрын

    You just watched a video proving that the computer cant do proofs for you

  • @joshuahillerup4290

    @joshuahillerup4290

    4 жыл бұрын

    @@cabbageman not exactly. A computer in theory could do proofs just as well as you can, although we're certainly nowhere near to that point with proof assistants yet.

  • @AndersJackson

    @AndersJackson

    4 жыл бұрын

    @@CatoSierraWasTaken he said nothing about CS, he just mention programming. Or not even that, just using computers. :-)

  • @TheSienn
    @TheSienn4 жыл бұрын

    In German, if you want to make the "e" sound in English, you usually have "ie". If you want to make the "i" vowel sound, you use "ei", like in Leibniz. I imagine English is his second language and he is defaulting to that Germanic "ie" e sound. Just to clear up where his "wierd" spelling is probably coming from.

  • @RoyRope

    @RoyRope

    4 жыл бұрын

    Yeah very recognizable for me.

  • @CaptainWumbo

    @CaptainWumbo

    4 жыл бұрын

    That's funny because in English we just make it up as we go along and 90% of native speakers did not notice the mistake. Until it was pointed out of course.

  • @guinea_horn

    @guinea_horn

    4 жыл бұрын

    It's a very common mistake among native English speakers as well. Your explanation very well could be true but we make the same mistake all the time.

  • @umchoyka

    @umchoyka

    4 жыл бұрын

    It could be that. Also in english there is a common pneumonic: "i before e, except after c or when sounding like 'ay' as in neighbour or weigh". But "weird" breaks that "rule" too. I can sympathize with someone that has english as a second language

  • @markkeilys

    @markkeilys

    4 жыл бұрын

    @@umchoyka I mean half of the english language breaks that rule.. it is, after all, just multiple languages in a trenchcoat.

  • @youtoobfarmer
    @youtoobfarmer4 жыл бұрын

    the more important typo is "holds" instead of "halts"

  • @ltdowney

    @ltdowney

    4 жыл бұрын

    It’s not a typo. It’s a logical term, like “this proposition holds.” It returns true if the input “fun” logically holds.

  • @youtoobfarmer

    @youtoobfarmer

    4 жыл бұрын

    @Luke Downey - Interesting, though I'm not convinced. The use of "holds" in "the proposition holds" isn't analogous to what the function "holds" is supposed to do. It doesn't return True if the input "logically holds" but, rather, it returns True if the input terminates, and False if it loops forever. The argument presented in this video (as well is in Turing's proofs) is that there is no general function that can determine whether or not a computer program will halt. The problem is that, given an input like the function "wierd" and its argument "wierdstr", we end up in a kind of self-referential paradox, where if the input to "holds" halts, then it loops indefinitely, and if it loops indefinitely, then it halts. The function "holds" is therefore self-contradictory in this case, which means it cannot exist (note that it's never defined, for that reason). So my point is that, since it's a hypothetical algorithm for determining whether or not a computer program halts, the name "holds" makes no sense in this context, and it should be "halts".

  • @ltdowney

    @ltdowney

    4 жыл бұрын

    Criminy Jicket - You don’t have to write an essay to explain the halting problem to me. I know what it is, and I know the terminology the professor is using. If you’re not convinced then that’s fine.

  • @youtoobfarmer

    @youtoobfarmer

    4 жыл бұрын

    @Luke Downey - sorry for the long-winded answer; I didn't mean it to be patronising...I just assumed from your (incorrect) statement that "holds" returns True if the input "logically holds", that you didn't understand what it was supposed to do. I stand corrected.

  • @fredoverflow

    @fredoverflow

    4 жыл бұрын

    So this video is not about the halting problem, but the holding problem? Got it.

  • @casperes0912
    @casperes09124 жыл бұрын

    I genuinely thought it was easier with Turin machines...

  • @MrMelon247
    @MrMelon2474 жыл бұрын

    Finally a Computerphile video I can follow! - Data Scientist

  • @mrcake4525
    @mrcake45254 жыл бұрын

    Pinocchio: "My nose grows now"

  • @JeanDAVID

    @JeanDAVID

    4 жыл бұрын

    length dilation paradox

  • @XoNasX
    @XoNasX4 жыл бұрын

    Wow, very nice video. This was a very enjoyable ride explained at the exact correct level of depth to understand and still enjoy it.

  • @whuzzzup
    @whuzzzup4 жыл бұрын

    Took me way too long to realize he said "true" and not "two".

  • @root42

    @root42

    4 жыл бұрын

    whuzzzup well, „two“ is truthy in many languages, so it’s ok. ;)

  • @JxH

    @JxH

    4 жыл бұрын

    Me true.

  • @gemyellow

    @gemyellow

    4 жыл бұрын

    When you are in university long enough enrolling the CS program, you actually get used to heavy accents, and find it weird to have a prof that speaks English/American/Canadian accent

  • @Flackon
    @Flackon4 жыл бұрын

    That was a pretty elegant explanation. Very nice

  • @aayushf
    @aayushf3 жыл бұрын

    have you tried pip install does-halt? There's a Python package for everything

  • @brhh

    @brhh

    Жыл бұрын

    no there is not, also why couldn't it work by detecting the code's logic?

  • @unvergebeneid
    @unvergebeneid4 жыл бұрын

    People are commenting on his spelling of "weird" but nobody realised that when he mixed up "halts" and "holds" because he pronounces them the same way.

  • @vyli1

    @vyli1

    4 жыл бұрын

    most people noticed both mistakes, don't think you're special ;-)

  • @Contradel

    @Contradel

    4 жыл бұрын

    If he had called it halts it would not have make sense for it to return true if fun applied to args did not loop or crash

  • @mcg6762

    @mcg6762

    4 жыл бұрын

    @@Contradel If a function halts it means that it returns in finite time, i.e. does not loop forever.

  • @procactus9109

    @procactus9109

    4 жыл бұрын

    He is used to eating with a thick straw.

  • @stoppernz229

    @stoppernz229

    4 жыл бұрын

    the name of the problem is irrelevant.... the logic of the problem itself is what matters

  • @benjaminwagner5440
    @benjaminwagner54404 жыл бұрын

    This is explained very nicely. Someone give this guy a python.

  • @mcg6762
    @mcg67624 жыл бұрын

    I am a bit puzzled by how this guy named the function "holds" when he's demonstrating the Halting problem to a large KZread audience. It's just confusing and peculiar. I mean the guy wrote a book about Python with a section on the Halting problem. Shouldn't he know how to spell "halts"?

  • @vojtechstrnad1

    @vojtechstrnad1

    4 жыл бұрын

    I agree. Even though I understand the halting problem, this video was too confusing for me to follow.

  • @willfalls8068
    @willfalls80683 жыл бұрын

    I’ve always been slightly less than satisfied with the halting problem. I feel like I get what’s going on but I feel like you’ve only proven that this algorithm for telling if a function will run forever or be finite cannot exist for every input but wouldn’t be useful for the inputs that it could solve?

  • @sbutler7069
    @sbutler70694 жыл бұрын

    Maybe it’s just me but I didn’t understand anything he said

  • @SakyTalks
    @SakyTalks4 жыл бұрын

    We need Tom Scott's energy here. Awesome video BTW 👏👏👏

  • @jentwickler
    @jentwickler4 жыл бұрын

    I think i will save this as a task for the next year apprentice. That will be fun.

  • @jackhindbrain6833
    @jackhindbrain68334 жыл бұрын

    This is that dude!

  • @unperrier5998
    @unperrier59984 жыл бұрын

    *QUESTION* : are there other classes of functions for which it's not possible to write *holds()* other than those functions that do call *holds()* (just like *weird()* does)? thanks.

  • @ivanskyttejrgensen7464

    @ivanskyttejrgensen7464

    4 жыл бұрын

    Instead of self-referencing functions you an give it unproven conjectures, eg Collatz conjecture. If you give holds() a function that contain the 3n+1, ½n computation then the only thing hold() can do is to compute it itself, but then holds() may not terminate...

  • @unperrier5998

    @unperrier5998

    4 жыл бұрын

    @@ivanskyttejrgensen7464 makes sense, thanks.

  • @schmoab
    @schmoab4 жыл бұрын

    I’m going as this guy for Halloween.

  • @Oldf0x

    @Oldf0x

    4 жыл бұрын

    Genuinely hilarious!

  • @AcornElectron
    @AcornElectron4 жыл бұрын

    The Rick Wakeman of computerphile.

  • @kmac499

    @kmac499

    4 жыл бұрын

    Nah; he's only usng one keyboard :-)

  • @AcornElectron

    @AcornElectron

    4 жыл бұрын

    He’s not, you just can’t see the others 😉

  • @JeanDAVID
    @JeanDAVID4 жыл бұрын

    is holds(fun, fun) a correct boolean test ?

  • @alwysrite
    @alwysrite4 жыл бұрын

    This professor looks pretty cool and smart !

  • @IndrajitRajtilak
    @IndrajitRajtilak3 жыл бұрын

    Does it matter that the weird function needs to pass it's own source as input? I am not able to follow that aspect of logic.

  • 4 жыл бұрын

    Just paperback version ? No digital format ?

  • @cameronmonks1561
    @cameronmonks15614 жыл бұрын

    Isn’t it True and not true in python

  • @ayanbaqur571

    @ayanbaqur571

    4 жыл бұрын

    Also strings that are not empty will return True, in Python 3 anyway.

  • @Spongman
    @Spongman4 жыл бұрын

    what's really going to bake your noodle later on is Chaitin's Omega constant...

  • @eightrice
    @eightrice4 жыл бұрын

    Isn't the "try" block basically that holds function?

  • @unclerojelio6320
    @unclerojelio63204 жыл бұрын

    I just came here to order the book.

  • @jeffreybrunken556
    @jeffreybrunken5564 жыл бұрын

    Pretty sure I’m going to have to watch this more than once. Book order placed. Which I will also need t read more than once ...

  • @lawrencedoliveiro9104
    @lawrencedoliveiro91044 жыл бұрын

    3:41 Why did you need to pass the string source of the function? You could have passed the function itself. That’s perfectly valid Python.

  • @corpsiecorpsie_the_original

    @corpsiecorpsie_the_original

    4 жыл бұрын

    Because he defined the second input of holds to be an argument and not a function, so to make it clear for newbies he passed the function as a string

  • @IlhanNegis
    @IlhanNegis4 жыл бұрын

    i just can’t stop thinking “big summer blowout”

  • @955565265
    @9555652653 жыл бұрын

    To me that sounds like you're doing recursion in a different way; it's the same as writing " if holds(wierd, fun) :" which would cause maximum recursion exception.

  • @vojtechstrnad1
    @vojtechstrnad14 жыл бұрын

    You sure you didn't mean "halts" instead of "holds"?

  • @IronCandyNotes

    @IronCandyNotes

    4 жыл бұрын

    omg englisch nerd stopp es alredi

  • @charstringetje

    @charstringetje

    4 жыл бұрын

    Are *you* sure he isn't talking about the holding problem?

  • @GermanRumm

    @GermanRumm

    4 жыл бұрын

    OMG, thank you, I was looking for this comment! It seems that everybody else in the comment section are linguists, not programmers

  • @benhetland576

    @benhetland576

    4 жыл бұрын

    I think you got a point there; "holds" would be the opposite of "halts", actually... sort of ... (in the sense that it doesn't continue to completion and return) But "halts" also conveys both meanings, oh dear!

  • @GabrielVelasco
    @GabrielVelasco4 жыл бұрын

    Great vid.

  • @AsbjornOlling
    @AsbjornOlling4 жыл бұрын

    Great video - here have some viewer engagement.

  • @ThisIsEduardo
    @ThisIsEduardo4 жыл бұрын

    What if there was a programming language that solves p vs np ?

  • @JeffSmith-vc9ii
    @JeffSmith-vc9ii4 жыл бұрын

    Greatest quote ever "if Touring had known Python then..."

  • @sagsriv
    @sagsriv2 жыл бұрын

    Love the proof!!

  • @ayanbaqur571
    @ayanbaqur5714 жыл бұрын

    Python 2 is deprecated after the end of this year. Although I agree with the result of your argument, using an outdated syntax irks my nerd brain, as this will resolve successfully (with None) in Python 3.

  • @redpillsatori3020

    @redpillsatori3020

    4 жыл бұрын

    Thumbs up for mentioning Python 2 deprecated..bout time people move on to 3

  • @Kram1032
    @Kram10324 жыл бұрын

    I can relate to that wierd spelling of weird

  • @warlax5658
    @warlax56583 жыл бұрын

    1 minute in you put a space before your colon for your function definition and my soul left my body

  • @perschistence2651
    @perschistence26514 жыл бұрын

    What, I don't understand what the point is?? When holds returns true it will run forever and if holds returns false it will terminate...

  • @JakeFace0
    @JakeFace04 жыл бұрын

    I've always wondered this: doesn't the halting problem only show that there is a specific class of functions which cannot be determined to halt?

  • @lawrencedoliveiro9104

    @lawrencedoliveiro9104

    4 жыл бұрын

    It’s the other way round. There are specific classes of programs that can be shown to halt, but this is undecidable in the general case.

  • @JakeFace0

    @JakeFace0

    4 жыл бұрын

    @@lawrencedoliveiro9104 I don't even know what your reply is trying to say. It's not undecidable in the general case it's just not decidable. Regardless, I wonder what proportion of programs are undecidable.

  • @sin3divcx

    @sin3divcx

    4 жыл бұрын

    @@lawrencedoliveiro9104 Could you give an example of such a program?

  • @pararera6394
    @pararera63944 жыл бұрын

    Don't get it 😥

  • @NuclearCraftMod

    @NuclearCraftMod

    4 жыл бұрын

    I think the idea is that we have a function, *weird,* which takes in a function *fun.* If *fun* halts, *weird* doesn't halt. If *fun* doesn't halt, *weird* halts. So if we feed the *weird* function to itself, we have that if *weird* halts, *weird* doesn't halt, and if *weird* doesn't halt, *weird* halts - this is a contradiction. The solution is that there is no function that can answer the question of whether *weird* halts or not, thus there is no function that can answer the question of whether a *general* function halts or not.

  • @unperrier5998

    @unperrier5998

    4 жыл бұрын

    @@NuclearCraftMod well it's a corner case: because *weird()* calls *holds()* it's then possible to create *weird()* so that it bears a contradiction resulting in the impossibility to write *holds()* . But if *weird()* didn't call *holds()* then it would have been possible to write the function *holds()* such that it determines if *weird()* can stop or not. I know/understand that *weird()* calling *holds()* is a counter example that suffice to prove the halting problem.

  • @benhetland576

    @benhetland576

    4 жыл бұрын

    @@NuclearCraftMod That is a lot of weird fun ...

  • @kunns123

    @kunns123

    4 жыл бұрын

    @@NuclearCraftMod bruh.

  • @peetabix
    @peetabix4 жыл бұрын

    For a second i thought it was a blond haired Dave Grohl.

  • @worf7271
    @worf72714 жыл бұрын

    I love his accent.

  • @panda4247

    @panda4247

    4 жыл бұрын

    I don't

  • @WacKEDmaN

    @WacKEDmaN

    4 жыл бұрын

    im usually ok with accents...but this guy has to be the worst ive ever heard!.. couldn't understand anything he said.. i think its a combination of the accent aswell as him mumbling...his mouth moves but his jaw doesnt!

  • @joshnoble07
    @joshnoble074 жыл бұрын

    Can i PLEASE get a link to Prof's shirt. I will accept an amazon affiliate link

  • @famitory
    @famitory4 жыл бұрын

    all functions halt because the universe has a finite entropic lifespan

  • @QuintarFarenor

    @QuintarFarenor

    4 жыл бұрын

    for example, or I would code some kind of thread watchdog with a timeout. If the correct but looping function timeouts then it is "false". The timeout might be a few hours, days or years even, depending on the kinds of problems and underlying hardware though.

  • @benhetland576

    @benhetland576

    4 жыл бұрын

    @@QuintarFarenor yet, that is not a correct implementation... it can only answer the question "does the function terminate in less than some time t". Let that t be another input, and for correctness the function now has to work for t=infinity too. :-)

  • @CatoSierraWasTaken

    @CatoSierraWasTaken

    4 жыл бұрын

    but an algorithm is an abstract mathematical construct that exists irrespective of a specific physical universe in which it's implemented.

  • @phillipotey9736
    @phillipotey97364 жыл бұрын

    But I don't understand. I can write code that will run forever and I can write code that will put out an answer. There is code that idk if it will stop? If so what?

  • @xizar0rg
    @xizar0rg2 жыл бұрын

    This feels like a restatement of Russell's "set of sets which don't contain themselves".

  • @mattlm64
    @mattlm644 жыл бұрын

    Can it be easily shown that the halting problem is correct without any self-referencing?

  • @AndersJackson

    @AndersJackson

    4 жыл бұрын

    Not with programs that I know. Someone else might though.

  • @vojtechstrnad1

    @vojtechstrnad1

    4 жыл бұрын

    Can it be shown that the halting problem cannot be proved without any self-referencing?

  • @neuron1618
    @neuron16184 жыл бұрын

    Summary: Dr. Okun explains the code that disabled alien shields during the invasion on Independence Day, 1996.

  • @jbrady1725

    @jbrady1725

    3 жыл бұрын

    I laughed.

  • @Painless201

    @Painless201

    2 жыл бұрын

    this should have more likes hahaha

  • @gianluca.g
    @gianluca.g4 жыл бұрын

    And that's why the halting problem should be explained with pseudo code instead of an actual programming language like python: otherwise people will start arguing that the compiler should thorw an error, that the libraries could be better, that the memory is finite etc.. etc..

  • @prakamyakhare7505
    @prakamyakhare75053 жыл бұрын

    Programmers:- see logics of the code Non-Programmers:- see spellings of the code Xd

  • @JoeWong81
    @JoeWong814 жыл бұрын

    This guys awesomely amazing accent is worth watching these vids alone.

  • @unperrier5998

    @unperrier5998

    4 жыл бұрын

    personally I find the accent difficult to understand... and since computerphile never enables subtitles I tend to avoid him because of his accent, precisely.

  • @youknowitMavs214
    @youknowitMavs2144 жыл бұрын

    Should do a dining philosopher problem video..

  • @jackriahi7346
    @jackriahi73464 жыл бұрын

    Thanks dr Thanks to you, I learnt that logic can be illogic. I am going to Print("I am crying 😭😂😂😂")

  • @alejandrodeharo9509
    @alejandrodeharo95094 жыл бұрын

    Talk about hypercomputing super Turing machines that solve the halting problem or other undecidable problems

  • @serrato987
    @serrato9874 жыл бұрын

    Awesome

  • @Lightn0x
    @Lightn0x4 жыл бұрын

    3:12 syntax error it's "True" not "true"

  • @HoD999x
    @HoD999x4 жыл бұрын

    aren't the halting problem and gödel's incompleteness theorem fancy ways of saying "infinite recursions never end"?

  • @gordonfreeman5958
    @gordonfreeman59582 жыл бұрын

    This seems far less clear to me than the Turing machine explanation (though that itself seems like a muddy explanation to me as well). I don't see how there is a contradiction at 4:07 - he says "if the function loops then it terminates" but that's not what's happening. What's happening is "if the function loops [i.e. holds(fun, fun) returns false], then wierd(fun) terminates", which is not a contradiction. What am I missing? Edit: Or is the 'contradiction' in this context supposed to be the fact that a looping function can never return an answer, and thus holds(fun, fun) can never provide the 'false' needed to complete the execution of the wierd function code?

  • @TheAibt

    @TheAibt

    2 жыл бұрын

    It is a contradiction because if the halt function says weird does not halt on itself, then weird returns, effectively halting- therefore weird DOES halt on itself which is not what the halt machine said it would do.

  • @raconvid6521
    @raconvid65212 жыл бұрын

    The solution would be to say that “*not*Haults(notHaults)” would find that this case is logicly impossible, so would see that as being a sort of syntax error, and so would return false. “notHault(notHaults)” can be considered a different function than “notHaults”.

  • @raconvid6521

    @raconvid6521

    2 жыл бұрын

    Same thing if you do try to pass a function that you define as being `logically impossible` or `does return or run forever`. Its not fair to pass functions that cant exist into haults and then decide it’s the haults function that doesn’t exist

  • @rikkathemejo
    @rikkathemejo4 жыл бұрын

    Is the use of wierdstr necessary? couldn't he just use wierd(wierd)? I took extra steps to understand the video due to weirdstr

  • @lawrencedoliveiro9104

    @lawrencedoliveiro9104

    4 жыл бұрын

    Yeah, that’s what I thought. Python has full support for functions as first-class objects.

  • @rikkathemejo

    @rikkathemejo

    4 жыл бұрын

    Thinking better about it I guess the problem is that you cannot access the function code that way

  • @InverseAgonist
    @InverseAgonist4 жыл бұрын

    I'm a bit confused by the use of weirdstring, because I don't know how the interpreter is seeing that as anything other than an arbitrary string. Is there an implied eval function somewhere that I'm missing?

  • @RobertRoskam

    @RobertRoskam

    4 жыл бұрын

    With the way he's speaking, yes, it is implied. I honestly don't know why he chose to do that instead of just doing wierd(wierd).

  • @SunShine-xc6dh
    @SunShine-xc6dh3 күн бұрын

    Seems to me that more proves you cant feed your do the opposite function it's own output as input. It doesn't really say anything about there being no determine if a function doesn't halt function, the problem with does not halt is the problem of how many steps is infinitely many steps

  • @morbulten
    @morbulten4 жыл бұрын

    Every time he writes a space before colons: PEP8!!!

  • @DiomedesDominguez
    @DiomedesDominguez4 жыл бұрын

    What about C#?

  • @sharkinahat
    @sharkinahat4 жыл бұрын

    'weird' is the usb of spelling.

  • @cannaroe1213

    @cannaroe1213

    4 жыл бұрын

    i'd say "friend" is USB, while "weird" is TOS-Link

  • @Anvilshock

    @Anvilshock

    4 жыл бұрын

    @@TheDudesRug I before e except when your foreign neighbour Keith receives eight counterfeit beige sleighs from feisty caffeinated weightlifters.

  • @pgriggs2112
    @pgriggs21124 жыл бұрын

    Is this not a false assertion? How can a function determine if another function will terminate without examining the context of the function as well as the function itself? Does that not imply running the function? For this mystery function to actually do what he is saying would require a reimplementation of the runtime, only under the direct supervision and control of the function.

  • @KohuGaly

    @KohuGaly

    4 жыл бұрын

    Consider this C statement: "while(true);" Do you have to compile it and run it to know it will loop forever?

  • @pgriggs2112

    @pgriggs2112

    4 жыл бұрын

    That’s the question. Do you? Can you evaluate the output without duplicating the function and the runtime? You have to duplicate the execution of the function to accurately predict it’s output. Or do you? Otherwise, you are requiring your function to understand all the nuances of the input function. Can you write a function that understands all other functions you yourself cannot understand?

  • @KohuGaly

    @KohuGaly

    4 жыл бұрын

    ​@@pgriggs2112 Yes, the halting function would have to analyse the function without running it. That is the whole point - it has to be able to tell you in finite ammount of steps whether the input function will run forever or not. Trying to run the input function is an automatic fail, because it may run forever. Note however, the halting function doesn't care what the output of the examined function is. It only cares if it returns or not.

  • @Vidaric1

    @Vidaric1

    4 жыл бұрын

    Well, that's the point! It's intuitive that you'd have to run it, but this is an actual proof that such a program cannot exist.Proofs are important.

  • @Spongman

    @Spongman

    4 жыл бұрын

    functions in math don't have context.

  • @AloisMahdal
    @AloisMahdal4 жыл бұрын

    I'm not sure this works so well. You're passing function to function vs. passing string to function, so it actually does make sense for it to behave differently.

  • @ThorstenAltenkirch

    @ThorstenAltenkirch

    4 жыл бұрын

    Alois Mahdal my spec was that the holds function gets a string containing the code of the function. You need an explicit description of the function it doesn’t work with a higher order function.

  • @SVVV97

    @SVVV97

    4 жыл бұрын

    @@ThorstenAltenkirch I guess the __code__ member on a function you pass in would be an explicit description of it. Not saying that that would solve the problem or that it would be better - but I think it's also possible to do this as a HOF

  • @EngIlya
    @EngIlya4 жыл бұрын

    shouldn't the function be named "halts", and not "holds"?

  • @Lecopivo
    @Lecopivo4 жыл бұрын

    If you have a fixed upper bound on memory use, then you can solve the halting problem. The upper bound gives you that there are only finitely many possible states, you can just test them all and check if they loop or not. I'm curious where does this Python proof use potentially unbounded memory.

  • @leMaik

    @leMaik

    4 жыл бұрын

    Actually, you can't, even with unlimited memory. If you check all possible memory states and none of them loops, you know that the program halts. But if one of the memory state loops, you can't know if it loops or if it just takes a long time to compute. If it loops forever, your check will never complete and you don't know if the program halts.

  • @vojtechstrnad1

    @vojtechstrnad1

    4 жыл бұрын

    Fixed upper bound on memory means two things: the algorithm will always either terminate or eventually get into a memory state it has already visited (and loops forever from then on), and almost all algorithms won't be able to run with that memory bound. So yes, for algorithms that can run on that machine you can check if they halt or loop, but there's really nothing special about deciding the halting problem for an infinitely small subset of all algorithms.

  • @mrembeh1848
    @mrembeh18484 жыл бұрын

    It’s the halting , not the holding problem

  • @IainEmslie
    @IainEmslie4 жыл бұрын

    Dr Strangelove or: How I Learned to Stop Worrying and Love the Halting Problem

  • @Jeacom
    @Jeacom4 жыл бұрын

    Likes to spell "wierd" Destroys pep8.

  • @slasherman4999
    @slasherman49994 жыл бұрын

    In other words, it's impossible to determine the truth of a program, or function, which inverts/lies to you, because the inverter cannot be evaluated in absolute terms, therefore there's a bound on consistency. I feel like this is a thought experiment that evolved from the idea of a oracle evaluating itself. A program that tells you if it halts, must halt to do so. But, what if it doesn't halt, it runs forever and you can't tell if it halts unless you have an infinite existence, depending on how big that infinity is. But, so you develop a wrapper that does the opposite and this has a finite run time and can be evaluated, but it always gives the wrong answer. So when it's run on itself, the oracle really has no meaning and thus is an utter impossibility.

  • @Milan_Rosko

    @Milan_Rosko

    Жыл бұрын

    Now you could argue, to grab your argument, the machine is so clever that it thinks a way to get out of this situation. It can wait or get stuck, because giving no answer is not a false answer. However, this would be a machine that never gives a false p answer if it comes to the halting problem, which is different than predicting the halting.

  • @joshuahillerup4290
    @joshuahillerup42904 жыл бұрын

    See, this is why I like total programming languages, where weird would always be considered invalid.

  • @xybersurfer

    @xybersurfer

    4 жыл бұрын

    how would those languages deal with partial functions like division (can't divide by 0)

  • @joshuahillerup4290

    @joshuahillerup4290

    4 жыл бұрын

    @@xybersurfer two main strategies. Either you include a proof as a parameter to the function (which can be implied so you ususally don't have to include it explicitly) that the denominator is not zero, or the division function return something like a Maybe Int (or whatever the numeric type is) instead of just an Int.

  • @phillipotey9736
    @phillipotey97364 жыл бұрын

    Oh so the halting problem can't be written? But that's like saying count to 10 in base zero...

  • @undefBehav
    @undefBehav4 жыл бұрын

    i don't think you necessarily have to understand turing machines to understand the halting problem. it's enough you have an understanding of cantor's diagonalization

  • @idk-bv3iw
    @idk-bv3iw4 жыл бұрын

    Just remember: I before E except after C. :) Oh, wait...

  • @benhetland576

    @benhetland576

    4 жыл бұрын

    Who conceived that rule...?

  • @MadocComadrin

    @MadocComadrin

    4 жыл бұрын

    Tell all your friends and n ei ghbors!

  • @GuildmasterWigglytuff

    @GuildmasterWigglytuff

    4 жыл бұрын

    How about after Python? ;)

  • 4 жыл бұрын

    It's actually wrong more often than right.

  • @Anvilshock

    @Anvilshock

    4 жыл бұрын

    I before e except when your foreign neighbour Keith receives eight counterfeit beige sleighs from feisty caffeinated weightlifters.

  • @TheCrashToaster
    @TheCrashToaster4 жыл бұрын

    "wierd" is a weird way to write weird

  • @666Tomato666

    @666Tomato666

    4 жыл бұрын

    matches the formatting used: not putting spaces after comma but before colons is non PEP-8 compliant

  • @AndersJackson

    @AndersJackson

    4 жыл бұрын

    @@666Tomato666 "command" -> "comma" ;-)

  • @666Tomato666

    @666Tomato666

    4 жыл бұрын

    @@AndersJackson ah, yes, fixedaded ;)

  • @Some_Beach
    @Some_Beach4 жыл бұрын

    You got an actual yeti

  • @MrNacknime
    @MrNacknime4 жыл бұрын

    Why make this specifically about python? The halting problem can easily be demonstrated just in the terms of algorithms (pseudocode or anything)...

  • @AndersJackson

    @AndersJackson

    4 жыл бұрын

    Python works great as pseudo code.

  • @b1odegradable559
    @b1odegradable5594 жыл бұрын

    Somehow this sounds pretty Goedel-like to me, or maybe Russell.

  • @gregoryfenn1462

    @gregoryfenn1462

    4 жыл бұрын

    b1odegradable his accent is almost nothing like a Russell’s posh British accent. Have you even listened to the radio debates with him..?

  • @lawrencedoliveiro9104

    @lawrencedoliveiro9104

    4 жыл бұрын

    @@gregoryfenn1462 I think the OP is referring to the thought processes, not something superficial like the accent.

  • @b1odegradable559

    @b1odegradable559

    4 жыл бұрын

    Lawrence D’Oliveiro Exactly, the problem described just reminded me of Gödel, the technology used somewhat of Russell. Sorry if I was unclear.

  • @ANTIMONcom
    @ANTIMONcom4 жыл бұрын

    So it makes sense.... because it does not make sense! Briliant

  • @borntolose_livetowin
    @borntolose_livetowin3 жыл бұрын

    If I will ever meet the Professor, I will probably buy him a gym membership.

  • @HechTea
    @HechTea4 жыл бұрын

    Wierd. Nice, I'm gonna do that from now on as well.

  • @KieranDevvs
    @KieranDevvs4 жыл бұрын

    Isn't this simpler to prove that it wouldn't work? You're essentially doing: if pass : Which is syntactically incorrect because if expects a condition? Otherwise it would be like saying this sentence: if, then we should x.

  • @KPkiller1671

    @KPkiller1671

    4 жыл бұрын

    You're missing the point. He wants you to assume there is an implementation for holds (that returns True or False). But from that, you reach a contradiction, thus proving the assumption false.

  • @mrakvladar2034
    @mrakvladar20344 жыл бұрын

    I'm sorry But can you please put up subtitles For this video.