introduction to metamathematics -- Kleene

Background

I am reading the book to get more understanding of type theory and logics establishment underneath programing. Though the book itself is not that easy for me.

I found a pretty good summary here:

www.logicmatters.net

And here is what I got most:

Numbers

We can define numbers as an infinite set, naturally, start with 0 and combine with a successor function suc so suc(0) = 1, recursively 2, 3, ... With set theory, we can see we can have a set A with some numbers contain subsets, which is constructed by A's elements. In this process we define a predicate contain. Things works until we have a set E with infinite numbers. We can build a subset F contains infinite numbers as well. But can we say E contains F as well, since we can apply suc so elements in F to build a new elem not in E at the moment of observation. If we put the new element in E, then by applyingsuc to the new element in F we can keep this paradox.

Classic vs Intuitionistic Logic

Classic logic

P or not P is a full set.( P or not P == True) This is The excluded of middle, true or not true, only either one will stands

Intuitionistic Logic

Liar's Lie: A liar say: he is always lying. Then, is he lying as well on the above sentence? Like the paradox in the set theory example, we can never tell until we observe all elements/the liar's mind. So the excluede of middle is not true. There is a state besides true and false, where we can not tell.

Gödel’s incompleteness theorem

If an object(number, set) is consistent(P and not P cannot be both true) then the object is incomplete

Gödel’s number

let the world only have variable or function variable A, F.. And operator & | ~ .. we can assign them each with a number, then every proposition like A & B | C can be represented with a number, that is Gödel’s number

Primitive recursive and General recursive.

General recursive is like lambda-definable,Turing's computable. ? Not computable 1. Ackermann function, we can prove its Gödel’s number's increase speed is faster than primitive? recursive functions. So Ackermann function is not computable 2. Or through enumeration, we can find some number between computable function's Gödel’s number that is not computable.

Why Software Delivery time is hard to estimate?

Reading: Working with Coders: A Guide to Software Development for the Perplexed Non-Techie (English Edition)

f:id:pumbaacave:20200524161626p:plain
Delay

Under the name of engineer, software engineer is different from other engineering like construction where the cost will blow up beyond estimation. There are two general causes

Imagination Problem(outside eng part)

Building software is building human process. 1.the process itself is abstract so we have to imagine. Though we can use an MVP like user story to sketch out the though idea, most of the time we need to see the full cycle to judge yes or no the software work as we want. 2. Little spec change may lead to enormous change in codes. Some times the 5% of the not fulfill spec(automatic formatter or smart grouping) cannot be filled by the library taken somewhere, so eng have to rebuild an proprietary one. The result is long time with seemingly no progression. 3. One counteract of #2 is to design more detailed beforehand. But it will be paradoxical since more spec will lead to more uncertainty and therefore more change( 100spec * 5% < 200spec * 3%)

Estimation Problem(inside eng part)

Estimation from engineer is inaccurate. Because usually the estimation is something like: - Estimation time: 3Day But it turns out - 1st implementation: 3Days + 2nd impl after feedback 1Day + BugFix 1Day + Contingency(Server down or serious bug from else where) 1Day = 6Day See, 100% over. And this is a very conservative case when estimation goes young.

80% Syndrome

When eng think they are done 80%, actually they are at 50%.

One interpretation is that when planning, the main part( creating the api) looks 80%, but the remaining part(write test, update test, adjust config, integratino) seems minor as 20%, so when the 'main part' is done, engs feel 80% is done.

To deal with this estimation bias, we can apply - Buffer multiple, when told 3 days we count it with a multiple as 6, or more - Use scrum to calculate long term velocity of the team(not individual eng), and update the velocity in every sprint to reflect real velocity. This approach needs several sprint to estimate(require warm up time) and will changed greatly when new member joins.

Legendary CEO

The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company

Bob Iger, WOW Great guy. After one week's reading, finally I closed the book. My last company's CEO always touted "We want to become Disney", at that time my image is you want build an entertainment company with revenue that rival Disney's box revenue, yeah it is bold. But I was totally wrong about Disney. Today Disney ranks #25 of all open traded company(in US) and cover sports, news, Disney IP, Pixar, Marvel, Star Wars.

Reflection

Last Year I have read to book of former Pixar CFO, the guy was summoned by Steve to rebuild cracking down Pixar(The first CG movie The Toy was in its childhood, and rendering software business was so-so and employees didn't like Steve because he don't want to hand out stocks). In chapters describing their relationship with Disney, especially CEO at that time Micheal Eisner. Though early contract save Pixar financially, but as Pixar hit the screen and led the animation industry, their deal seems unfair and Steve want a new deal, which met with cold foot. But years later New CEO signed in that things turned around, Selling Pixar to Steve while preserve Pixar's spirit is the highlight.

I will use the lamp to light up our castle

From Iger's view, this deal is much critical, and is the start of his legendary CEO career. After 6 months' painstaking scrutiny and interview, finally he succeeded CEO from inside Disney, before he was COO. Most of the people doubt how he can changes the situation: 1. No hit animation in last decade 2. Bad Relationship with Pixar 3. Low morale around the company, because all business decisions are centralized and decided through a data analysis MBA holder elite team, frontline leaders can just followed decision from the top. Iger put up 3 strategy: 1. Great, branded animation, contents 2. Take in technology 3. Globalization And his first action(even first presentation to board member) was: what about buying Pixar. A crazy but legendary Idea

Tech

Reading through the book did I know Marvel, Star Wars are now Disney brands, so Strong. The fight time hearing Disney+ I contempting on the idea that a traditional company want to compete with Netflix. But now, the IP power lets me retreat my view. And their resolution to disrupt their own profit line, short term profit to realize the Innovate or die motto drag me pro to their future.

FOX

Holding ABC, acquiring FOX building up a entertainment, media giant. Disney's true power is much bigger than my past perception, awful. Also, shocked to read Disney think Twitter was buyable and once the board allow to buy Twitter, but Iger turn down later. If that happen, it will be a totally different world. How can Disney handle such a conflict piece and how the tech can boost Disney.

Parallel GC and Concurrent GC

Parallel GC and Concurrent GC

Parallel GC

Goal

Utilize multicore power to speed up GC

TradeOff

  • Need to sync works between different process(reside on different cpu), collector thread can have local work list and global work list and steal work from global list or other collector's list(thus requires sync)
  • Different architecture provide different memory model, need to implement with memory fences

Incremental GC

One GC cycle will be separated into multiple increments(smaller portion of work). Mutator and Collector will work one after another but not parallel.(When collector works mutator will stop).

Goal

Reduce duration of single GC pause

TradeOff

  • More work should be done such as record keeping(which objects are mark but not yet collected)
  • More head room required since heap will be fully collected several(or more) GC cycle later

Concurrent GC

Mutator and Collector and work at the same time(in parallel)

Goal

Reduce duration of single GC pause, or even erase GC pasu.

On the fly concurrent GC:

Different round GC cycle can run parallel, so Marking phase mutator of round 1st may work parallel with a marking phase mutator of round 2nd. Therefore must distinguish white obj from past round and current round. Solution: introduce purple color, etc

Note

Actually short period of stop the world will happened, like mark the roots for one collector thread and defer other GC thread's roots scan Total wait-free algo is possible but actually more costly than pause for a short while, otherwise multi phase hand shake can be used to sync all mutator into same phase(mark).

TradeOff

To let mutator and collector have a consistent view of heap, write and read barrier is required(more work added to mutator) For moving collectors, need read barrier since mutator may reading an obj being moved partially

Tricolor GC Model

GC works like DFS - White Objects: Not yet scanned(before scanned starts) or Unreachable(after scan finished), will be reclaimed - Grey: scanned with neighbors not fully scanned - Black: scanned with all neighbors scanned. Under concurrent GC, mutator may 1. let black obj ref a grey directly reachable white obj -> a reachable obj will be reclaimed wrongly 2. let black obj ref a white directly object but grey indirectly reachable, * ref means delete pointer from old obj and assign to new obj

General barriers
  • Insertion barriers: when insert a white obj to black obj, shade the white obj(black to defer to next round, grey for near rescan)
  • Deletion barriers: when deletion ref of a white/grey obj from white/grey obj, shade it or mark it, etc.
    Feeling
    deletion b' is wider than insertion b'

    Allocation

    Besides mutator, allocator also need to color obj based on specific strategy when allocating obj in mark/collect phase.

Reading List

f:id:pumbaacave:20200506103823j:plain
Reading List

Reading List 

2019-12

世界的優良企業の実例に学ぶ 「あなたの知らない」マーケティング大原則

同じオフィスの足立さんのご著書、示唆に富ます

  • どんなマーケティングでも仮説を立てて実行し、データで検証するべき(インスタ宣伝は大して効果がない:インスタのスターとプロダクトのペルソナが合わない、影響人数が少ないなどーーでも中国ではKOL(SNSの人気スターによる宣伝は必須になってる)
  • SNSを使うならTwitter一択、様々な話題性をを使ってmouth of wordから拡散されていくのが一番効果あり
  • プロダクト開発はマッケティング中心で行う、STP(segmentation target posistion)を決め、提供する価値を元に開発・ビジネスを進めるべき

P&Gウェイ―世界最大の消費財メーカーP&Gのブランディングの軌跡

マーケティングというものを作った企業をBiography

  • 最初に卸業者を飛ばしたことがある(大変だった)
  • 自社開発力も高い
  • Product Manager制度を作り、発展し、またそれが足かせになって脱却を狙う
  • とにかくいろんな製品の開発話:Springleの筒状パッケージ(省スペースでRetailer向けに圧倒的有利)のために最適なポテチの形を発明、洗剤パウダーの発明、Panteneにて便益だけでなくプロダクトペルソナ・ブランドで製品成功

    2020-01

    『プログラミングHaskell 第2版』 『プログラミングHaskell 第2版』www.lambdanote.com

Note: Data type is very interesting. From a OO world I first view functor as an interface works like function, or kind of protocol like python

# object of my_func are functions
Class my_func:
 def  __call__():
    pass

but actually it is more powerful. Seeing applicative enable extending map reduce and monad to handle exception case, IO state (normal list also), which will be tough in java. Approaching Haskell

qiita.com

2020-02

Design Patterns: Elements of Reusable Object-Oriented Software

Famous GoF - Type is not a class, rather it is more like a interface telling what( an object) can do c++ code is readable but small talk code we treat them as python and not understand a lot

失敗の科学 失敗から学習する組織、学習できない組織 Twitter上流れてきて、良さそうなので読みました - Only Open cycle can help people/organization learning. Comparing flight industry(Ultra-Low accident rate due to post-mortem) and medical industry(thousands of patients lost live annually), without open cycle to gain feed back and improve, people will lost sight even with great purpose.

2020-03

The Fifth discipline How can an organization start and keep growing?

Blog Entry pumbaacave.hatenablog.com

2020-04

The GC HandBook Great MasterPiece Blog Entry

pumbaacave.hatenablog.com

2020-07

introduction to metamathematics, introducing logic and math www.amazon.co.jp

SICP MIT's computer science text book, using scheme, many Jams. https://mitpress.mit.edu/sites/default/files/sicp/index.html

Finalizer and Reference Types(Strong, Soft, Weak, Phantom..)

Finalizer

Purpose: reclaim unmanaged resources:

Example: FileStream.close -> BufferStream.close -> work to let os release file descriptor(fd).

The fd resource is not managed by the program(not a object in the vm world), so GC will not clean it up.

Note:

Finalizer is for external/unmanaged resources with GC and destructor is for managed resources.

Concern:

  1. Dead lock or bugs can happen if finalizer holds a lock, or worse if reentrant lock is provided and thread scheduled out during object finalization -> undefined behaviour
  2. due to #1, usually finalizatin work is done by dedicated thread
  3. Resurrection: lifecycle of finalizer enabled object A is like:
  4. GC.mark
  5. find A 

  c.queue to a global queue to process after sweep/copy to avoid #1 issues 

  1. run finalizer  ** the A call its finalizer again or other cycle refed object's finalizers -> new strong ref created to itself ::: GOTO step a

In java the spec defines every finalizer will be called only once so #3 can be avoided

 

Reference Types

Reference Type are ordinal in strengths: stronger type of references are collected first(in an earlier pass). Because every type have their purpose and the corresponding actions need to be performed in some order

Strong Ref

Essential requirements by GC. Unreachable denotes (roughly) Dead objects, so help reclaimable objects.

Soft Ref

Under memory pressure objects refed by Soft Ref can be reclaimed(without refed from Strong Ref)

Weak Ref

Used by cache: if one cache works like a global registry and never be reclaimed, of cached object will be immortal without Weak Ref

Finalizer Ref

Interal type of Ref in java, as talked in Finalizer section, to postpone finalizer enabled object to be processed after Sweep/Copy phase

Phantom Ref

TODO: dig out later

roughly to control the reclaim order of objects: like a weak refed obj A with finalizer weak referring another obj B. The Phantom Ref will keep the B alive after A been cleaned up

Reading: The Fifth Discipline

 

www.amazon.co.jp

 

https://www.amazon.co.jp/dp/B000SEIFKK/ref=cm_sw_em_r_mt_dp_U_aV.OEbR6HCBFJ

Theme

Reading the book, the books' japanese name is very descriptive: disciplines the tells an organization how to learn.

By discipline, it means scientific learning.

How to achieve the Goal

Sytematic thinking:

  Rather than focus only on imminent or coming events, it is crucial to see how the system works. Like in the "beer game" example.

unsplash.com

 

Multiple player, whole sailer, retailer, factory all react strongly to their own events -- beer orders raise sharply. That result to overmuch backlogs, because the delay of feedback.

Key factors: vicious cycle(positive feed back), balance/negative feedback, delay

Personal Mastery

  Only an org full of, have an environment to serve people want to learn and keep learning, can the org itself keep learning. So let's talk about how to form Personal Mastery(learn to master)

  Mastery is not a transition like getting 99 from 100 points. It is understanding the system where people stands, knows how the components interact with each other(the hard stuff) and continue learn how the system change and how to perform well among them. 

  Thus Mastery is a state where people keep growing and learning.

  But how to learn?

  1. Have a direction( large scale of strategy, usually abstract but off topic here)
  2. Set a vision( a goal you can span effort on)
  3. The gap between vision and current reality is creative power encourage the learning

The gap is an incentive for growth as well as to lower the goal. Whenever take an action we should be aware or reflect afterwards.

Mental Models

Know the facts, several self-trap modesl:

- Self-unworthiness: nowadays  call imposter syndrome(is me really deserve so, i am not - capable of things, not secure)

- Will power oriented. Can solve tough cases but failed to deal with group, org difficulty. Fail in family, friendship.

 

 Advocative vs inquiry.

 Advocative: Without a malice, keep finding argument to convince, win the conversation. Taking this strategy, people will selectively skip facts will weaken their point. People will treat assumption of world the how the world it is. And in discussion one winner other loser.

  Inquiry: "My assumption is based on these facts." People can explore around 

  1. the idea
  2. the facts/experience support the idea
  3. the way facts support the idea.

  After discussion every party will have learning. The result is an assumption of the world, any change in the system possibly lead to change of the assumption. 

 

To be continued