The OPTIMAL algorithm for factoring!

Поделиться
HTML-код
  • Опубликовано: 31 мар 2023
  • Our program:
    github.com/polylog-cs/univers...
    RSA factoring challenge: en.wikipedia.org/wiki/RSA_Fac...
    Big thanks to: Tomáš Gavenčiak, Matěj Konečný, Jan Petr, Hanka Rozhoňová, Tom Sláma
    Our Patreon: / polylog
    Credits:
    To make this video, we used manim, a Python library: docs.manim.community/en/stable/
    The color palette we use is solarized: ethanschoonover.com/solarized/
    music: Thannoid by Blue Dot Sessions: app.sessions.blue/browse/trac...
    music: Ride of the Valkyries from R. Wagner from wikimedia commons

Комментарии • 105

  • @alansmithee7549
    @alansmithee7549 Год назад +487

    My computer is currently using 80% of its memory to find the factorization of 15. In other words, it will crash asymptotically.

    • @minoubrc4773
      @minoubrc4773 Год назад +23

      Nailed it asymptotically

    • @SuperNolane
      @SuperNolane Год назад +6

      They say memory's cheap nowadays

    • @hadibq
      @hadibq Год назад

      😄

    • @TymexComputing
      @TymexComputing Месяц назад

      maybe 15 is a hidden gem prime - i dont get why my comment hasnt showed up (or i cant see it)

  • @RadioactivePretzels
    @RadioactivePretzels Год назад +169

    Awesome, it can also be used to find ideal chess moves, or reduce GPT4 down to an optimal set of weights! Very versatile, though it does take a computer that's a little faster than mine.

    • @PolylogCS
      @PolylogCS  Год назад +28

      Yep, although it is a bit more tricky! The way we use this trick works very well for "NP problems" where checking is easy and computing hard. You can also use it for more complicated problems like finding ideal chess moves, but you need to throw in one more idea (I want to drop link to this in the video description of the followup video).

  • @santius0
    @santius0 Год назад +295

    Currently attempting to find the factorization of 8. Truly masterful work, this will bring a revolution 😂

    • @alansmithee7549
      @alansmithee7549 Год назад +27

      A wise usage of memory :^)

    • @PolylogCS
      @PolylogCS  Год назад +86

      Wow, you got past 4?

    • @jerichaux9219
      @jerichaux9219 Год назад +5

      @@PolylogCS Look at Mr. Chips over here, getting over 2!

    • @romain.guillaume
      @romain.guillaume Год назад +16

      Well 8 is not the product of two primes, thus even with infinite power you won’t find out…

    • @paulkanja
      @paulkanja 4 месяца назад

      ​@@romain.guillaume jokes on you, I'm checking complex numbers as well

  • @y_arml
    @y_arml Год назад +101

    April 1st should go into history as being the day the Internet was broken.

  • @YellowBunny
    @YellowBunny Год назад +162

    This is a pretty neat example of how misleading asymptotic complexity can be. :)

  • @electra_
    @electra_ Год назад +39

    Running simultaneously is very clever. This was the first solution I thought of with respect to "asymtoticaly optimal" but didnt know how to get around the Halting Problem

  • @machitoons
    @machitoons Год назад +23

    a lecture into why smaller big O doesnt always mean faster, wonderful

  • @timschulz9563
    @timschulz9563 Год назад +107

    Just save the prime factors before multiplication. O(1). Easy.
    I don't understand why the engineer forget the obvious solution to just always pack the prime factors alongside the product.

    • @anupbarua6151
      @anupbarua6151 Год назад +3

      i think for security. the products are sent over the internet and valid receiver finds out the primes. if invalid receivers get the primes bad things can happen.

    • @Megaranator
      @Megaranator Год назад

      @@anupbarua6151 why don't you encrypt them then?

    • @anupbarua6151
      @anupbarua6151 Год назад +1

      @@Megaranator i studied these things a long ago, i think they de-encrypt the messages by the primes. send the primes alongside the message? why? now will you encrypt the primes also?

    • @Megaranator
      @Megaranator Год назад +1

      @@anupbarua6151 yes. enough recursions in and it's gotta be not worth it go trough all the that decrypting for the attackers right?
      /s (I hope you know that the video and the comments are a joke)

    • @anupbarua6151
      @anupbarua6151 Год назад

      @@Megaranator all jokes aside.

  • @lane_m
    @lane_m Год назад +14

    Brazissimo
    Reminds me of some of the more "Creative" sorting algorithms that got thrown around when I was in school 😆

  • @redsteph
    @redsteph Год назад +8

    I was a bit thrilled until I saw we were April 1st... Good one!

  • @thomasmackay4
    @thomasmackay4 Год назад +6

    had several confusions... then i realized that the date arithmetic revealed critical context.

  • @purplenanite
    @purplenanite Год назад +15

    Oh, tricky!
    If it was linear in execution time (1 step of n-1, 2 steps of n-2, 3 steps of n-3), then it would be the square of the most efficient algorithm
    Instead, since it is exponential, the sum of the terms becomes linear instead!
    Amazing!

  • @2kadrenojunkiegaming655
    @2kadrenojunkiegaming655 2 месяца назад

    this is... beautiful.

  • @anon_y_mousse
    @anon_y_mousse Год назад +1

    If only every channel would do an April Fool's day video. I'd give you extra points if I could for the fact that you used my favorite esoteric language. All that's needed is the program to generate a BF program from an input algorithm. That would really sell it.

  • @johnchessant3012
    @johnchessant3012 Год назад +3

    Universal search!

  • @9fran9rosatti9
    @9fran9rosatti9 Год назад

    omg the thumbnail is so good

  • @bailey6112
    @bailey6112 7 месяцев назад +1

    I knew when I saw BrainFuck in the code this was gonna be a wild one

  • @oresteszoupanos
    @oresteszoupanos Год назад +3

    I saw mention of the "Brainfuck" language, so I ran away screaming.

  • @johannesrauch8931
    @johannesrauch8931 Год назад +3

    I see, some universal turing machine stuff is coming

  • @mihajloantic4422
    @mihajloantic4422 Год назад +4

    I wonder how does this algorithm deal with Encabulator?

  • @Tumbolisu
    @Tumbolisu Год назад +12

    is this the same situaiton as the sorting algorithm that just makes a new cpu thread for each element and just tells them to wait as long as their input number says? yeah its the best possible time complexity, but thats not necessarily a good thing.

  • @TymexComputing
    @TymexComputing Месяц назад

    Tha computer program either has all the composite numbers precompiled and looks up the solution (or that its a prime number) or its just a composition of all the bf programs starting with the shortest one.

  • @AlessandroBottoni
    @AlessandroBottoni Год назад

    Great video! 🤣😂 We are eager to see its first commercial implementation. 😂😂

  • @rutvikrana512
    @rutvikrana512 Год назад +3

    So I am now waiting for getting answer of 15 for last 5 days, should I continue?? 😢

  • @scottwilliams895
    @scottwilliams895 Год назад +1

  • @vnc.t
    @vnc.t Год назад +6

    I'll bet if someone wrote that code in assembly he'd crack rsa

  • @casenc
    @casenc Год назад +2

    Can't believe I fell for it...

  • @reversefulfillment9189
    @reversefulfillment9189 7 месяцев назад

    Get your algorithms! We have the finest and freshest algorithms! Step right up!

  • @hansisbrucker813
    @hansisbrucker813 Год назад

    I thought this was going to be about Shor's algorithm. Nice surprise 😊

  • @aidangomez9852
    @aidangomez9852 Год назад +1

    Took a course with Levin, he's a genius

  • @personanongrata987
    @personanongrata987 Год назад

    I'm so glad that viewing your video wasn't a waste of my time.
    --

  • @VCC1316
    @VCC1316 Год назад +3

    So if I find a d^2 factoring algorithm I shall worry for my life or expect a Field medal?

  • @logician1234
    @logician1234 11 месяцев назад

    What is the memory complexity of this algorithm?

  • @347573
    @347573 Год назад +1

    Fermat invented this solution before, even if he didn't have the space to write it on his napkin

  • @Amonimus
    @Amonimus Год назад

    I don't quite get it. It draws a large triangle with two dots at the end of each line and at some point freezes, it acts the same with any input.

    • @PolylogCS
      @PolylogCS  Год назад +8

      The triangle is there to help you understand what's happening, but try to look at the code, too!

  • @Darth_Bateman
    @Darth_Bateman Год назад

    Anyone else reading these types of ads in the smug yet smarmy and sultry voice of a Hollywood commercial advertisement?
    "He breaks RSA with this one trick, Computer scientists hate him!"

  • @lefteriseleftheriades7381
    @lefteriseleftheriades7381 Год назад +7

    Me watching the video on April 5, trying to figure out why a brainfck interpreter is relevant to factorization

  • @aze4308
    @aze4308 Год назад

    woah

  • @rohithpokala
    @rohithpokala 10 месяцев назад

    Small mistake.size of the number with d digits is 9*10^(d-1). Most significant digit cannot zero right? It will have only 9 possible digits.

  • @SK_1337
    @SK_1337 Год назад +2

    NOT ME NOT ON APRIL FIRST! NEVER! EVER! NEVER ME!

  • @simonstebbins3838
    @simonstebbins3838 Год назад +1

    Wow and this was created without any understanding of the general number field sieve. 😆

  • @tokajileo5928
    @tokajileo5928 5 месяцев назад

    my PC reported this:
    File "it.py", line 11
    def __init__(self, program: str, input: str):
    ^
    SyntaxError: invalid syntax

  • @nonsencephilosophy
    @nonsencephilosophy 6 месяцев назад

    i wonder why this video was uploaded 1st april :)

  • @rujon288
    @rujon288 2 месяца назад

    i forget april 1st videos still exist after april the 1st. i can get fooled all year round (;

  • @aashsyed1277
    @aashsyed1277 Год назад

    Is it true ?

  • @Stopinvadingmyhardware
    @Stopinvadingmyhardware Год назад

    They said that it couldn’t be done.

  • @Nioub
    @Nioub Год назад +4

    Wow! Does this prove that P = PN?

    • @toebel
      @toebel Год назад +1

      Factorization is not known to be np complete, so regardless of whether the alg is polytime, it wouldn’t be enough to prove p=np

    • @toebel
      @toebel Год назад +2

      (Or rather I should say, *wasnt* known to be NP complete. I came up with quite a marvelous proof this morning…)

    • @PolylogCS
      @PolylogCS  Год назад +6

      Turns out, you can use this trick also to get asymptotically optimal algorithm for any NP complete problem! (but it gets a bit more tricky, for factoring it's easier to explain what's happening)

  • @HoSza1
    @HoSza1 6 месяцев назад

    8 months passed so far, any news on this?

  • @Dardasha_Studios
    @Dardasha_Studios Год назад

    I got kyphosis watching this.

  • @handsanitizer2457
    @handsanitizer2457 Год назад

    I would but I'm a pretty average dev lol so I doubt I could make it better 😂😂😂 . But, this is great thanks

  • @ferverrel5519
    @ferverrel5519 Месяц назад

    Where’s the other video

  • @angelamusiemangela
    @angelamusiemangela Год назад

    Le risultanze della tavola di lettura , ASCII.

  • @priyanshugoel3030
    @priyanshugoel3030 Год назад +1

    The words might be hint brainfuck and universal search.

  • @otbot8925
    @otbot8925 Год назад +19

    You didnt get me... Its April 1th. Nice try though

    • @Stopinvadingmyhardware
      @Stopinvadingmyhardware Год назад

      People still play that game?

    • @codeway4374
      @codeway4374 Год назад +2

      @@Stopinvadingmyhardware this video is a material proof

    • @ryanqvincent144
      @ryanqvincent144 Год назад +2

      I actually watched this on the 13th of April. It took me a while to appreciate the humor of it. It made me smile. :)

  • @JonDisnard
    @JonDisnard Год назад

    I recommend optimizing python more. This could probably go a lot fast by eliminating while loops, and going with for loops instead, which run in C code in the python runtime. I'm not sure what all that brainfuck is about, but whatever... Might try finding a more optimal way to evaluate commands than branching all over the place.... Slow. And, just use sets instead of lists... Your eating memory.

  • @simonwillover4175
    @simonwillover4175 Год назад

    So, you didn't even TRY to come up with a good factoring algorithm? Also, how can we "know" that there isnt an algorithm which gets better than 10^d factoring time?

    • @pigworts2
      @pigworts2 Год назад

      There are algorithms that do better than 10^d... (e.g the general number field sieve) - this whole video is meant as a joke.

    • @the_cheese_cultist
      @the_cheese_cultist 11 месяцев назад

      this is the universal search algorithm, which can be mathematically proven to be optimal
      it's also extremely impractical

  • @totally_lost1602
    @totally_lost1602 8 месяцев назад

    Actually the basic flaw in their assertion, is that all solution paths are similar, and have the same algorithmic costs. This is clearly false in that brute force trials, sieve, statistical attacks, and symbolic SAT attacks all have very different solution complexities. For example, certain classes of two prime products can be solved by SAT in a few minutes or hours, others have no solution via SAT like most of the RSA numbers. When SAT can factor certain 512 bit two prime products in hours, then it's pretty clear the assertion made in this work is flawed, IE their algorithm is not the lower bound. This is further complicated by the fact that precompuation attacks will also reduce the time needed to solve a particular class of factoring, by using precomputed partial solutions that are then easily brute forced to solve the remaining portion of the factors. Rainbow tables are one example, which are used to crack passwords which have a similar computational complexity as certain factoring algorithms.

  • @trinitrotoluene3D
    @trinitrotoluene3D 10 месяцев назад

    why do programmers have to name classes such weird names *1:28*

  • @supposta6860
    @supposta6860 Год назад

    You can't keep this secret for yourself

  • @briankleinschmidt3664
    @briankleinschmidt3664 Год назад +1

    I'm not a programmer. Is "brainfuckexecution" a system command?

  • @hhehe24
    @hhehe24 Год назад

    haha blazni

  • @JohnDlugosz
    @JohnDlugosz Год назад

    The Python listing that starts at 1:28 has nothing to do with the prime algorithm or the narration at this point. What gives? Did you insert the wrong file into the video?

  • @danielfaller5617
    @danielfaller5617 Год назад

    I havent watched the video yet, but im guessing its social engineering.

    • @PolylogCS
      @PolylogCS  Год назад

      Not really, it's legit! Go and watch it, I think you'll enjoy it!

  • @RicardoSantos-oz3uj
    @RicardoSantos-oz3uj 8 месяцев назад

    Or at least you think you can.
    As maths are not perfect.

  • @SoI-
    @SoI- Год назад

    ok, but how will you do numbers with more than two factors, like 21790298087899097494373776975583044612659582164942154887813609701190909992130650129784168219399742498394590?