Neumo’s Blogs

Let’s do some deep learning!

Potential Implementation of `PolynomialSumOfSquaresList`

How do we prove $x^2+2x+1 \geq 0$ by sum of squares(SOS)? Quite trivial $\text{LHS} = (x+1)^2 \geq 0$ Then, how to prove this by SOS? $$1024 x^{12} + 1024 x^{11} - 2304 x^{10} - 2304 x^9 + 1856 x^8 + 1856 x^7 - 672 x^6 - 688 x^5 + 96 x^4 + 120 x^3 + x^2 - 8 x + 21 > 0$$Note that $$ \begin{align*} & 1024 x^{12} + 1024 x^{11} - 2304 x^{10} - 2304 x^9 + 1856 x^8 + 1856 x^7 - 672 x^6 - 688 x^5 + 96 x^4 + 120 x^3 + x^2 - 8 x + 21 \\ =& \frac{953178310898788044405634417898675810098347314821670074294737731307329417300202257499761536478657283822781507633364642416166327278492431062378651278370657928662612204203551165032096670314311671897547870594071651961090916102146117367523334512377797063623918959641854483477219062452053117354701873293279721322207383101430406097244237282245639156393092313795413669142611049 x^{12}}{855628317881711343628447665505529353642205279926550721248508119951156125518248969209845948736002719280414541370639384443936720924614544681187805334420694749567400421129263862969704529965010066154381893028055449128137526516108909143872797671529580790648030301664407011259998219690161313333579998909002703175128634549361882868091571588610793879524527809926169868860955417600} \\ & +\frac{20730892603614552086030236791584376390584458016906737607737484410976414001063114786504571319170688941259188382102808494189006085284963556422616888222898922617541385760899893376535242468971667371887252593392744651799829664240827458028060434738895363938051839773370848251341085723828176528969737296885610550104284856922624395816262451042617170959861753944569051610115364975096073666531052259740236406867828388007841283785939762576367433335933838418591322151049217429629270341561448035039752629166572755121441300348424582513530988930032979543430868119319256707428034767673 \left(x^6-\frac{537192259959723196414608024276178584105895770740349990419864409450146859446360918141274261404347215931631797055464128276914916157874933032752787127367563050763626059546908325367179084235774333657723622129680953103417722133971649513536014377636992875729296614390814113462253672326830450300193835 x^5}{573436804488876102142203069716235581838573141198680442118406207394949540289519077190803351051243463518468145511138665086473396444014968827035817391723483821802914447475306468210874522306578884970990388833275010785029852472999820007452095481245595738959406070890816673619069129251781055609514481}\right)^2}{6206525292964998561634089879171420703703077222813245725237731062283243057781605384272715894893115688039561739976314528141440276348710982794310284305563578483338134927900379708528960238116906764065435465250988664286812424413087069804415610909501395560804213981736329016091614450301007081812989768771400716805356955326219422447174363315272321570725848811409107568938852180691630516174689224926595786145141068421753037366221895943861317367364438368687862455344412538507280470763541217796022531535278362226193304037113002012436942592035108049513404198504622679784592044800} \\ & +\frac{89049395936672352040168549073731104935508445899958191436161862318618887575473347824917288559803543779125075800645083670230091642794205786249413530141184376511491703526443536337740075607815663586644005996838313922814771433710991249266480332814634194309626307993872905338940207675367318393363919505638197260130676409010048261104018415934500084622706963281661906523350259253983921638707587 \left(x^6+\frac{1250035259177316292055552469386970079830476326367794092844767479864825753282605141675706859648589867835412955837749840441264047429340506451409551822678359781540767273795999093416096481298696046487871220 x^5}{8622143587826850910117502112533330587731675813130997925666043593533539304265371562476845710341277127329332016845355859683327927946544194588985145498192793223955868643181370645313715205428657738385563819}-\frac{250068555521657649046677562622926995400361492206054337746046763604698328360725525321979519080245347110841949526008580342735436820548070105753437244690660363635344349057576996446918551957050730363661467736795517432 x^4}{247000887631547219650362262267498217114359645814025727199754456680281704352551452248260792050311392387975177735397802907626080272289713051779703241439169224797693110058833779475283650861940201841910326516809614621}\right)^2}{341822602918637684462759803331862949268521644937598626784273477398092190810659753651937927998386651744723163423943913812097353506749855595813602901610410889636152000488013806377115269602857144079515823849827076508204604117044432065154126771800620953408005355692583886319844446768050888556173228514949931617518643948118914444108098243115937619771018949965589413350297216046547214310400} \\ & +\frac{114110582938612998704158659404514255051669057393030752659470219065049417311463468557376015892172386233408723378189272123039495190457682922779027347858586303115779007600668186892567924675431960334050645546500616838293445049 \left(x^6+\frac{170372215743602129824191290442816200114290980759432737980698537578762149431655574586767607141481342217936642217045286295 x^5}{79198978232815290130528655478941018199689976888747889206980181686545761334890064169317612189500341634270976992383855892}-\frac{10203953103929899682581976196753751277654908019629863829295675407122586862724024696782342783750780067856543386194463907683978113 x^4}{13451588692120113302853290112643611602282673701089314990715540684831684684396619555438945669199900573439855658045046218504735514}-\frac{1156921360237789757302485482040694552188225079328629147544405729241765179914524617193983587603792399575398269867536010269771984801215 x^3}{579480989267842360973616884762574144214735300369226600485034777161864144519121973828754340483462516803215541892922546046965501207606}\right)^2}{1366111482246106172696369013109580206661129472861465130693169324770543975649855414453178742347115059279451705556403540118352861235205455721219880514785580582513596385591992213465538746668601219072613820297212205392956700}\\ & +\frac{855170648996299453282826318597469637692688774342377279122588090583182914361725138849041618786410014540391013069612470521 \left(x^6+\frac{208824848701751946066177483431560679149593637501714562853898328 x^5}{1622430576418306376968793749919537014833913740547776937187465121}-\frac{1102891048931550800774133577726231389446852281283462307407302195510467736 x^4}{551125008995526254989473607432028592184518611427649841031577162693270089}-\frac{61451711586630000225725826920536158859746855484781118310242171140952718523128 x^3}{593547856562956888467288338364108993067921931542293187544982814791584554100775}+\frac{232473948787618155607377486386406989276269768205862051739439363838088892436 x^2}{237921979767491444391645439166417035735774063213781213491056607955450278625}\right)^2}{1734819496159721395301097762699887999566121344999250931454978497836495899386698353810674840031645076695859122690108416}\\ & +\frac{152625114303613097562970499342414182175024924456131965 \left(x^6+\frac{28563189249509387706470170536420805 x^5}{9315046557962779041251696063459844}-\frac{6454490216193107995064656609442859126128240 x^4}{6064787888379130847288192308311499387086309}-\frac{16732721532793552664373217343255126836816 x^3}{3553024507622509278691554818253293871345}+\frac{2619886181080527170645281731667006 x^2}{10684687385267909341688179834740825}+\frac{879726740067337452506895818594 x}{518598620844921096038838025275}\right)^2}{2087473500409210051198263446146771163219546655799312} \\ & +\frac{79747153878767503695019075279803 \left(x^6+\frac{740175552623215917780704 x^5}{8159383732850597703519153}-\frac{334868393274810914740397696 x^4}{120845381198458989757409079}-\frac{1582860475816375677208 x^3}{7966887686614702087275}+\frac{19812948366188776778252 x^2}{9085183041159657600375}+\frac{1284036836607616 x}{15467432289695097}-\frac{2247064464063328}{5155810763231699}\right)^2}{721328386522315927536627776512} \\ \gt &0 \end{align*} $$ ...

April 6, 2025 · 9 min

Maximum Value Derived from Basic Operations Given Positive Integers

Notation $[n]$ denotes $\{1,2,\cdots,n\}$. $[m:n]$ denotes $\{m,m+1,\cdots,n\}$ if $n\geq n$. It’s an empty set otherwise. $a_{m:n}$ denotes $a_m,a_{m+1},\cdots,a_n$. $\{\{1,1,2^{(3)}\}\}$ denotes the multiset with two 1s and three 2s in it. The Problem Given several positive integers $a_{1:n}$, what’s the maximum value that can be achieved by four basic operations, additions, subtractions, multiplications and divisions? Every number is used exactly once. (Provider: 雷伊布是真的狗 aka 雷狗) For example, given 1,1,2,3, a possible result is $4/3=(1+1)\times 2/3$ but the largest result is $12=(1+1)\times 2\times3$. ...

March 16, 2025 · 11 min

Existence of Points given Distances

Given the Euclidean distances between N points, what’s the minimum dimension where these N points exist? More formally, given a positive integer $N \geq 2$ and positive numbers $a_{ij}$ for any $1\leq i, j\leq N$(and $a_{ij}=a_{ji}$), how to determine whether there exist $N$ points in the K-dimensional Euclidean space such that the distance between point $i$ and point $j$ is $a_{ij}$ for for any $1 \leq i, j\leq N$? Yes. Adding new points iteratively to the construction solves this problem easily because the distances between the newly added point and the points in our current construction uniquely determine its position in the space. But here is a more linear-algebraic solution. ...

March 4, 2025 · 2 min

Behavior of Observers in Minecraft

Scroll down to read the English version. 问题 你真的理解侦测器吗? 问题1: 为什么两个面对面的侦测器,如果是用活塞推上去的, 获得的就是4gt周期的1/2占空比的方波;而如果是手动放置的, 则是6gt周期的1/3占空比的方波? 上面一行的朝右侧的侦测器是手动放置的,而下面一行的朝右侧的侦测器是由活塞放置的 问题2: 来看下面这个机械,BUD活塞会活动吗? 如果是这样呢?BUD活塞还会活动吗? 如果你无法回答这两个问题,那么这篇文章就是你所找的。 这篇博文将会从源代码的层面刨根问底去解释侦测器的微时序行为。 文中的源代码是用DecompilerMC 默认配置生成的1.21.4的代码。 在读之前,你应该先对微时序有初步了解。肥啾的这个视频 和 佛冷的博客都是不错的中文相关材料。 注意由于mapping与源代码的差异,在这些资料中对某个微时序称谓可能与本博客不同。 在本文关心的微时序中,命名差异见下表 上述材料中的命名 本文的命名 NTE(Next Tick Entry) TT(Tile Tick) NU(Network Update) PA(Player Action) 代码基础 太长不看版: 计划刻不包含“要让侦测器变亮”或“要让中继器暗掉”这样的信息, 计划刻的行为逻辑是每个方块根据当前状态自己决定的。 例如同样是计划刻,亮的中继器执行则是熄灭,暗的中继器执行则是亮起。 如果当前时刻有计划刻则侦测器首先会改变自己的状态, 之后给出对自己的毗邻方块给出PP更新, 再判断(如果新状态是亮起来,那么添加一个两个游戏刻后的计划刻;如果是暗掉,则不添加), 然后NC更新自己屁股对着的方块, 之后对自己屁股对着的方块为中心的一阶邻域(不包括侦测器自己和屁股对着的方块)给出一个NC更新。 详细版: 如果侦测器在当前游戏刻有一个计划刻需要执行,则在Tile Tick阶段将会执行以下代码 // net/minecraft/world/level/block/ObserverBlock.java protected void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, RandomSource randomSource) { if (blockState.getValue(POWERED).booleanValue()) { serverLevel.setBlock(blockPos, (BlockState)blockState.setValue(POWERED, false), 2); } else { serverLevel.setBlock(blockPos, (BlockState)blockState.setValue(POWERED, true), 2); serverLevel.scheduleTick(blockPos, this, 2); } this.updateNeighborsInFront(serverLevel, blockPos, blockState); } 这里数字2对应的是UPDATE_CLIENTS ...

January 24, 2025 · 11 min

Thoughts on IQ

Does IQ matter in terms of test score? Yes. But recently, upon deeper reflection, I come to realize that IQ is not the only factor that affects one’s exam performance. My Childhood When I was in the third year of junior high school, I stumbled upon the Math olympics by chance. It was then that I realized that all the math I had learned was so naive and boring up to that point seemed – it felt like it was only for test, for scoring higher rather than for challenging human’s talent and intelligence. I’ve always loved puzzle games like Sokoban, Cut the Rope, Where’s My Water, etc. For me, the visual effects in video games matter far less than the ingenious level design and mechanics. You might guess that I am a fan of redstone mechinery in Minecraft. – and you’d be right. In my perspective, Math felt like the perfect game: no flashy or gaudy visuals, just clever, sometimes obscure tricks to solve problems. I’d often sit for an entire day trying to crack a tough problem. And when I finally solved it, it was a sheer bliss. ...

January 3, 2025 · 5 min

解构主义方块

图为成品,更高清的视频滑到最下面。 缘由 DD 制作了一个钥匙扣,正面是四个“喜”,反面是四个“苦” 这让我想到《哥德尔,艾舍尔,巴赫:集异璧之大成》的封面,一个从三个方向看上去是三个不同字母的构造物。 图源自维基百科 那么我们是否能够做出一个从三个角度看得到三个不同汉字的构造物呢? 其中汉字的选取范围为中文互联网解构主义字符集“孝典批乐急蚌润麻赢”。 思考 通过结构自身的形状呈现出想要的图案的,我们称之为阳文; 通过结构的镂空呈现出想要的形状的,我们称之为阴文。 例如《集异璧》的封面就是阳文。 阴文的情况存在一个平凡解,即将三块同样大小的正方体木板两两正交粘在一起, 然后直接在三个面上进行镂空处理。 只要三个字符中任何一个连通区域都是单连通的,即不存在“口”这样的洞, 这个结构就可以在三个方向上呈现出镂空的图案,就像下面这样。 而另一方面,不能“有洞”恰恰是阴文最大的缺陷。所以我们下面讨论阳文情况。 在这个帖子中, 大家探讨了怎样的三个图形能够成功做出这样一个结构。 这里简单复述: 我们不妨设三个面上的图案是 $[0,1]^2$ 的子集$A_1, A_2, A_3$, 则最大可能的候选者是这个集合 $$ S = \{\,(x,y,z)\in [0,1]^3\mid (y,z)\in A_1, (x,z)\in A_2, (x,y)\in A_3\,\} $$然而可能由于 $A_2, A_3$ 的切割,导致 $A_1$ 的图案无法显示完全。例如你不可能在三个面上都显示“一”。所以我们需要进一步验证 是否对于任意 $(y,z)\in A_1$,都存在$x\in [0,1]$,使得 $(x,y)\in A_3$ 且 $(x,z)\in A_2$,同理对于另外两个面也有同样的要求。 对于一般的图案,大概率这个判据是无法满足的。 但是我们注意到一组特殊解: 如果存在 $x_0, y_0, z_0 \in [0,1]$ 使得对于任意 $x,y,z\in [0,1]$ 都有 $$(y_0, z), (y,z_0)\in A_1, \ (x_0, z),(x, z_0)\in A_2, \ (x_0,y),(x,y_0)\in A_3,$$ 那么 $S$ 就是符合要求的构造。 ...

December 22, 2024 · 1 min

Working Memory in Neural Networks

Classified by their duration, there are at least three kinds of memory in humans: Working Memory(WM), Short-Term Memory(STM), and Long-Term Memory(LTM). WM can be seen as the internal state of the system that varies across the entire process. STM can be considered the memory for a milestone or key objects in a multi-stage task. And finally, LTM can be conceived as the neural network itself. Persistent knowledge is embedded in architecture. ...

December 7, 2024 · 9 min

Comprend Drop Check with Simple Examples

Concepts in Drop Check What’s the drop glue? Why do we need #[may_dangle]? In which case is a PhantomData necessary? If you don’t know the answer the questions above, this post would show you the answers by concrete examples. This page and this page in Rustonomicon and this page in the RFC book may be helpful to you. But if you find them difficult to understand like what I feel about them or too cumbersome and abstract, this post is what you want. Additionally, reading materials from different sources has a synergic effect. So although I believe this post is enough, you are encouraged to turn to other resources like those links I mentioned above if you are stuck in some part of the post. Leave me a comment when you encounter those moments. I will try to improve it. ...

October 8, 2024 · 14 min

Reimagining Internal Family Systems Through the Lens of AI

IFS Concepts The Internal Family Systems is a psychotherapy proposed by Richard Schwartz in the 1980s. In this model, everybody is a combination of different parts like those characters in the film, Inside Out. But the difference is that only emotions are anthropomorphized in the animation while in IFS, a part can also be a piece of thought or mindset. For example, if you have a social appearance anxiety, there would always be a voice in your mind criticizing your appearance. In IFS we consider the source this voice as a part of your mind. It is kind of like the dramaturgical theory with IFS focusing more on internal feelings and dramaturgical theory emphesizing more on social characters. ...

August 8, 2024 · 8 min

Notes on Sauer's Lemma

Introduction Every binary classifier is a function mapping its input, which is an element in an enumerable dataset, to 0 or 1. Equivalently, we could regard the classifier as a function $ f : \mathbb{N} \rightarrow \{ 0, 1 \} $. We have a set of hypotheses $\mathcal{H}$ from which a function is chosen to maximize the classification accuracy. It is perfect if $\mathcal{H}$ contains all possible functions $ f : \mathbb{N} \rightarrow \{ 0, 1 \} $, which indicates a universal approximator. However, when the expressiveness of our model is limited by computational cost or the size of the magnitude of parameters, it remains a problem to quantitatively measure the ability to approximate the ground truth. For example, if $\mathcal{H}$ only consists of functions which produce 1 only on one data point, namely, ...

July 26, 2024 · 6 min