Skip to main content

Posts

Showing posts from 2009

C++ initializer list order in a constructor matters?

This is a computer related article, and about THE hardest language, C++. So, I think the audience is again limited. gcc's -Wall option sometimes gives a warning as the order of initializer list in the constructor is wrong. For example, % g++ -Wall initializer_list.cc initializer_list.cc: In constructor 'InitializerListTest::InitializerListTest()': initializer_list.cc:30: warning: 'InitializerListTest::d_j' will be initialized after initializer_list.cc:29: warning: 'int InitializerListTest::d_i' initializer_list.cc:7: warning: when initialized here. This warning said that the order of initializer list in the constructor and the member variables declaration order are different. The following code is such an example. --- #include class InitializerListTest { public: /// constructor InitializerListTest() : d_j(123), // j = 123; d_i(d_j - 1) // i = j - 1; { // empty } /// print out void p

Visual C++ ... MD and MT compile option

This article is only for limited audiences. If you use Visual Studio C++ (2008) and have a question about What is the MD and MT, then you might be interested in this. When I made a Console Application on the Visual C++ 2008 using STL. I start to get the following error. error LNK2001: unresolved external symbol __imp___CrtDbgReportW It is related with a Windows runtime library. One thing is Unicode related, so I switched off. It seems this is related C/C++ Code generation, Multi-threaded Debug Dll (MT option) (/Mdd) or Multi-threaded debug (/MTd). (Note: only one character difference /MDd and /MTd.) In some reason while I develop an application, I got a warning about there is a library conflict, and suggested to ignore one of the runtime libraries. I followed the link's output and ignore the 'MSVCRT' library. But this is the problem. I removed it from the ignore library list. I set up all the Code Generation to Multi-threaded Debug DLL (/MDd) for debug, and not ignore any r

Is spamming really profittable?

Spam mails are everywhere and everyday. There is a question, "Is spamming really profitable?" One "academic" paper try to answer this question. They set up the bot net, set up fake web pages, send spam mails (350million spam emails in their experience), observe how many can go through, how many comes to the web page, and how many actually buy the medicine. This is the paper: Kanich et al. Spamalytics: an empirical analysis of spam marketing conversion. CASM, 2009, Vol.52, No.9, pp.99-107 I do not know how, but they claims it they cleared U.S. legal doctrine and ethics. The authors said, "We would be the first to admit that these results represents a single data point and are not necessarily representative of spam as a whole." and they even said there is some danger to interpret the result's means. But, for 28 days experience, 350 million spam mails are sent, 82 million delivered (but, of course they do not know how many are shown up in user's inbox

What is the rank of matrix

I will talk about the part of Introduction to Linear Algebra by Gilbert Strang, again. There is an important indicator of matrix called "rank". According to the http://mathworld.wolfram.com/, the rank of a matrix is the dimension of the image of the matrix, corresponding to the number of linearly independent rows or columns of the matrix. This is a common definition in a textbook. In the Strang book, the rank is explained from a bit different way. He explained rank and elimination together. The definition of rank is the number of pivots after the elimination. After all, they are the same, but I found interesting that how to approach to the concept of rank through the elimination. Gaussian elimination is employed to diagonalize of a matrix. Because if we could diagonalize a matrix, we can easily solve the linear equations. Let's think about a bit of elimination. We could use the following matrix as an example matrix. A = |1 2 2 2| |2 4 6 8| |3 6 8 10| Let's do elimin

C++ is hard... link considering dynamic library plugin.

This article might be interesting to someone who writes a plugin software with C/C++ using shared library (dynamic link library) mechanism. But, if you are not, I think this is totally rubbish. When I develop a plugin, I could compile it and link it, but when I run it, I happen to see an error message, ``no such symbol''. I see the symbol in the executable via nm/dumpbin, but, it is not recognized from the plugin code at runtime. Why this happens? Because the linker optimizes exposing symbols. Some of the software needs symbols that are only used by its plugin. When you need to build such software, you need to ask to the linker to keep those symbols. Otherwise linker trashes un-referenced symbols. This is usually useful, otherwise my disk and memory will be filled up by copies of unused symbols. To ask to the linker that ``please keep unused symbols since I might need them later,'' you need to specify --export-dynamic option (liker option) to the linker. If you use gcc

Using LaTeX CJK package to use three languages at once

(The English translation is below the German text.) Normalerweise verwende ich platex um Japanisch zu schreiben. Damit kann ich einen japanischen und einen englischen Text zusammen in einem LaTeX Dokument verfassen. Aber als ich einen deutschen Text unter Verwendung des Babel Pakets hinzugef"ugt habe, wurde die folgende Warnung angezeigt: Package babel Warning: No hyphenation patterns were loaded for the language `ngerman'. Ich habe im Internet danach gesucht, ob jemand diese drei Sprachen gleichzeitig verwendet hat, aber ich konnte nichts dazu finden. (In der Vergangenheit gab es ein "ahnliches Problem auf das sich die Warnung bezogen hat. Aber dieses wurde schon gel"ost.) Es scheint, als ob einige Dateien mit initex erneut kompiliert werden m"ussen. Das platex Paket von Ubuntu machte dies jedoch nicht. Ich vertraue immer auf die Worttrennung von LaTeX. Aber gestern hat meine Tandempartnerin bemerkt, dass der Bindestrich bei ,,in meiner Heimatstadt'' a

Logically speaking....

It is election time in Germany. I can find quite a lot of notice boards. I was surprised that one political party's motto is "More tax to everyone" This party got a lot of votes at Saarland recently. Actually, they did not directory say it, but they have two slogans: 1. Reichtum besteueren (Tax the rich: Front side) 2. Reichtum fuer alle (Rich for everyone: Back side) "More tax to rich people" and "Everyone should be rich", therefore, "More tax to everyone." Am I missing something? My friend L. told me this. Front side Back side

cool matrix (5)

Finally I would like to talk about cool matrices. Let's think about a three dimensional vector [x1 x2 x3]' = x1 [x2] x3. (Here ' means transpose.) The vector of difference of each term is [(x1 - 0) (x2 - x1) (x3 - x1)]'. Let's think about a matrix A that makes this difference in the right hand side. I will tell you why we think such a matrix. A is [ 1 0 0 -1 1 0 0 -1 1]. Let's check it out. [ 1 0 0 [x1 [ x1 - 0 -1 1 0 x2 = x2 - x1 0 -1 1] x3] x3 - x2 ] For instance, use [x1 x2 x3]' = [1 4 9]', [ 1 0 0 [1 [ 1 -1 1 0 4 = 3 0 -1 1] 9] 5 ]. The right hand side is the difference of each term. By the way, this matrix has its inverse matrix B, [1 0 0 1 1 0 1 1 1]. Let's compute A B, [ 1 0 0 [1 0 0 [ 1 0 0 [1 0 0 -1 1 0 1 1 0 = (-1+1) 1 0 = 0 1 0 0 -1 1] 1 1 1] (-1+1) (-1+1) 1] 0 0 1]. Therefore, A^{-1} = B. Please be patience a bit more

cool matrix (4)

There are so many applications of this linear operation. For example, one day's total sales of a supermarket can be computed in the same way: price of item 1 * number of sold of item 1 + price of item 2 * number of sold of item 2 + ... Again, price of item 1 * price of item 2 has no meaning here and therefore, we should not do that. Matrix is useful when we want to perform this kind of operation. Of course we can use matrix (so many) different ways, even so this is still useful. Until here, I hope this is understandable for a junior high school student. But, I realize I could not reach the entitled theme, a cool matrix, in this pace. Then, I will skip several topics, like, what is the relationship between a linear operation and a matrix. I am going to talk about a cool matrix in the next article. The audience would be a bit limited. I assume you know what is matrix or vector and how to write down this language, also can speak a bit. So I assume the audience is a high school stude

Cool matrix (3)

Today's abstract Let's talk about impossible multiplication. An impossible multiplication is just it doesn't make any sense. ``How much is 6 Euro pasta for 5 people?'' is 6 * 5 = 30 Euro. But, ``How much is 6 Euro pasta for 7 Euro salad?'' doesn't make any sense. If someone does 6 * 7 = 42. What does it mean? But it seems some people teach these stuffs to children. They make the students to hate mathematics. That's pity. - Main part Here multiplication is only with a number. If we have some variables x and y, we can do 3 * x + 5 * y, but not x * y. You might wonder what kind of mathematics we can not do x * y, that is such a simple operation. But I would like to emphasize, we have not so much freedom to compute numbers in real world with meaning. We all learned that we sometimes can not multiply numbers, again in real world. Let's think about in a restaurant as an example. For instance, x or y are a menu A and B's price, respectively. As mor

Cool matrix (2)

I am not sure it is a good idea that using music as an analogy of mathematics. But let me try it. Most of the music is combination of notes. These notes are not alone. We call a sound if it is alone. If we make sounds together in particular sequence, they become a music. Even I could make a C sound by a piano. But, music is different. Make a C sound by typing a key is an analogy to that we could add two numbers. We can't start the music or mathematics if we don't have this basis. These are fundamental, but, if we made a harmony or thought about vectors, they reach to another level. One sound and a music are different. One scaler operation and a matrix-vector operation are different as well. I think a deep insight of linear algebra comes from like that. Some of the music people might complain this analogy, but, some music are quite mathematical for me, like Bach's musical offering (inverse operation, recursive, infinite), I just think about the analogy. Well, I would like to

Cool matrix (1)

First I would like to introduce a bit of linear algebra. Then, I want to talk about a cool matrix. Here, a matrix is a mathematical object, not the movie's matrix. It becomes a long story about the matrix, but in short, this is about linear operator. But this is just a word substitute from ``matrix'' to ``linear operator,'' it seems I just fuzzify you. It is like saying Cat is Neko (in Japanese). Just substitute the words does not make sense for the people who don't know about cats. If I could add a bit more words, linear operator treats addition and multiplication only. It's bit strange when I said ``linear algebra,'' that sounds something great, especially in Japanese. I don't know why. Some people misunderstood that is lofty, this sometimes annoys me, oh well. On the other hand, linear operations are combination of addition and multiplication. These are the same, but, if I said ``I study addition and multiplication'' instead of saying

Vote from abroad II

The role of the rest of four people is following: 1. the one checks my vote registration is genuine. There is the number and name are recorded. 2. the one distributes the voting papers and envelopes. Then I go to a booth to write the vote and seal the envelopes. 3. the one records I voted. 4. the one seals the envelope A and took my vote. I asked how many people come to vote. The answer is almost 100 people. There is not so many Japanese lives in Berlin, but around 3000. The vote is not only from Berlin, I think the voting ratio is quite low. By the way, the embassy's people were so kind. There is no such reception in Germany even in a shop. The merit of voting from abroad is I need not to hear the election campaign. There is no disturbance campaign in Germany. Most of Japanese election campaign using the microphon car and just say the candidates name all the day. Everytime I was disturbed by such annoying campaign car, I swore I will never vote this disturbance person. If one did

Vote from abroad I

There is an election in Japan at August 30th, 45th Syuugiin sousenkyo (the House of representative). I don't live in Japan, but recently I can vote from the outside of Japan. Recently means it is possible after 2000. This was only for proportional representation, but after 2007, I can vote for small electoral district at my last Japanese address. There was a judgment of this, the result is a Japanese can not vote for small electoral district is against the constitution low. I got benefit of this judgment and I thank to the people who worked on this. However, the last time I mistook the election date. I need to vote in advance since my vote will send to Japan by mail. So it goes... I decided not to make the same mistake, I visited Japanese embassy 21st. If I made a mistake, I had still other days. There was a sign of ``Here is election'' in front of Japanese embassy (in Japanese!). Great! But, the gatekeepers don't speak Japanese. I said, ``Ich komme hier fuer die Wa

printf and va_args

Last time, I wrote about a problem with printf and size_t. However, I think it is better to say that this is caused by va_args. Because, a program needs to know what type of arguments are there when we use va_args. I think the promotion of arguments is invented to alleviate this problem. I met an bug as follows recently. This bug only lives in 64bit environment. Let's assume the following function using va_args. --- void vafunction(const char* p_name, ...) { va_list ap; va_start(ap, p_name); while(p_name != 0){ // do something p_name = va_arg(ap, const char*); } va_end(ap); } --- If I call this function as vafunction("This sometimes doesn't work in 64bit.", 0); // (1) then, this sometimes crashes. This does not always crash. When I traced this bug by a debugger, sometimes p_name never 0, then segmentation fault happens. But, if I call this as vafunction("This should always work in 64bit.", NULL); // (2) always works. The difference here is that

printf with size_t (in C)

When you print out a size_t data with printf, 32bit and 64bit has an issue. This is described at, for instance, http://www.mpi-inf.mpg.de/~hitoshi/otherprojects/tips/bugs/articles/11printftrap.shtml The horror of this problem is that it is just a one character typo and the output becomes not only incorrect, but also it could crash the program. Especially under above pages condition, usual compiler can not detects the problem. The conclusion is 'use stream,' then the problem itself does not happens unless you have a huge text data (but even so...). But there is an another question for this. Why float and double have %g and %f only? One of my colleague (D.S.) asked this question. The problem is caused by the size of size_t alters according to the environment, but the printf only see the format string and operates the stack memory (via va_args), therefore, if you have a mistake in the format string, the memory operation can't be right. Then, why float and double, their size o

Japan2009 19.6-20.6

19.6 One of my friend introduced a Karaoke-bar at night. This bar seems rare since it provides real German Beer and dishes. The atmosphere is also nice. PartIII Karaoke Lounge Mariko 164-0011 Yuni-buru nakano sakaue, Chuuou 1-32-7 Nakano-ku, Tokyo I came from Germany, so, I usually do not visit to German restaurant while I am in Japan. This is exception because of my friends. I never know this kind of bar in Germany. The most different part is the customer enjoys conversation with the bartender (usually woman). I almost never visit this kind of bar in Japan, because it is difficult to know what kind of bar it is. Some of them are kind of prostitute and super expensive. But most of them you can enjoy the conversation and reasonable price. However, I never visit these bars unless someone with me knows it. This is a nice bar. 20.6 I started 6 in the morning. I used Narita express from Shinjyuku to Narita. I came back to Berlin Tegel via Frankfurt. It is pity there is no direct connection

Japan2006 17.6-19.6

6/18 I moved to Tokyo. I met K again. But, first I almost visited O's lab. With K, we tried 8 Euro coffee. I think it tasted good, but I am not sure. But the atmosphere was great. I, K, and Y went to a Korean restaurant. Great. 6/19 I visited Shiosai park in the morning to see RX-78 type 2 (Gandum). Finally, there is. I took mechanical engineering in the University because of Atom and Gandum. Later, I changed my course to information science, but several of my friends continued to research on robotics. Some foreign people asked me, why there are so many Japanese robotics researchers? Or why Japanese researchers developed walking robot? Because this is a common dream of my generation. By the way, I can not help to stop reminding Minofski (?) particle with Minkowski sum. I visited Toukyo mentuu dan. Great. They research only Men (= Pasta) itself. Of course they also have great sauce, but the fundamental is so solid. Then, it is absolutely not necessary to make anything up.

Tezuka Osamu's Black Jack, "Shrinking"

I like several novel authors. My first favorite author is probably Teduka, Osamu. I still love him. The list grows by adding Hoshi, Shinichi, Agatha Christie, Hermann Hesse, and so forth. My first favorite article of Tezuka was Atom as most of the (boy's) Tezuka fans did. But my favorite is Black Jack. I try to summarize one story, it is still quite vivid in my memory. I first read this story when I was 13 - 15 years old. I re-read it at least several times since Black Jack is composed of many short episodes. The title should be "ちぢむ (SHRINKING)" or it might be "縮む(Shrinking)". (It is not so convenient to translate this to English, since English does not have a system to say the exact same word in several ways. So I just simulate it with capital letters.) Black Jack is a genius surgeon, but he does not have the license. In short, his medical activity is illegal. His skill is top level in the world, but, the fee is also out-of-law expensive. In the story &quo

Japan 2006 13.6-16.6

6/13 It's a bit surprised, but NHK (a Japanese broadcasting) has several interesting TV programs. Nikaku's Seikatu shouhyakka, Turubee no Kazoku ni kanpai, tameshite gatten, The death of Yugoslavia(1996 documentary), Suiensa, Degista, Bakushou gakumon, Alf, Fullhouse, etc.. I read Saisyuuheiki kanojyo (The ultimate weapon, my girlfriend or the last love song on the planet) by Shin Takahashi volume 1 to 7. What a sad story this is. Great. I read Satorate by Makoto Sato volume 1 to 3. The idea itself is classic like Fukuyama Keiko. A person broadcasts their mind, opposite of mind reader (= Satori in Japanese). However, this story makes this serious story. It's fun.6/14 I walk around in the city. I went though the green load of Fuji.This is the starting point. (picture) You can find some Japanese rice field. (picture) This road is originally a train track of Minobu line, that was single track. When the Minobu line becomes double track, the original line becomes a road. Here is

Japan 2006 9.6-12.6

9.6 My fixed phone right will be expire next year. I do not have any plan to use it next year, so I decided to sell that. But, I found there is no shop that buy a fixed phone right. There seems no demand. If youknow me and want it, please let me know. I read "Hitotu ue no puresen" (The next level presentation) Editor:Jun Maki. It seems each famous creators says different, but, I think the bottom line is that "a presentation is communication." I've got a message from a friend, that says "Problem." I could not read it. This word "Problem" makes me sick. I could not move and eat, so I read some books with drinking water in my bed. 10.6 Sick. Stay at home. 11.6 I read "the secret of the Jewish Mind" by Eran Katz. Maybe most important thing of learning is dialog or discussion. But, it is a bit questionable if this makes all the success. It seems others are well known. However, believing makes motivation. If I only doubt, I am sure that I

200906Japan 7.6-8.6

6/7 I read "Ginga Hitchhaiku Gaido" (Hitchhiker's guide to the galaxy) Douglas Adams. I have read it in English, but I might miss something, so I read this again in Japanese. But, it was so fun in English, it is not so fun in Japanese. But translation seems OK. The book is very difficult to translate, I presume. I read "The Rules" Ellen Fein and Sherrie Schneider.I see some of the rules. But in my case I give up such a woman. Maybe many of men will not give up and also I should not? But I think it is better to give up and move on. 6/8 Today I visited to Shizuoka and close Sumitomo bank account. This bank has no branch in my city, so it is a bit inconvenient. But around 2000, according my research, I believed this bank was the most convenient bank from outside of Japan. By the way, I found a nice shop called Yumekoubou in the city. This shop's clerk has a nice accessory and I asked where can I get. Then she introduced me a shop called Ernie Pyle Company &am

200906Japan 5.6-6.6

6/5 I visited a Soba restaurant. Great. I move to my family'splace. I read "Tensai Yanagisawa kyoujyu no seikatu 17" (A life of genius Prof. Yanagisawa Vol.17) Kazumi Yamashita. It's been long time not to read this series. I missed these books. 6/6 I read "Sugoi kaigi" (Great meetings) Zentaro Oohashi. I was once recommended this book from a company president in Aizu. This book is about meeting. I found it quite useful and maybe I could apply at my work. A nice book.

200906Japan 3.6(night)-4.6

3.6 Night Night, I met my friend G. He is now famous and gets inviatation letters from internatonal film festivals. I always complained ``I don't understand what is this article.'' But, he always try to explain how it is nice. Recently, I started to understand some of them. Just feel something. This is stereo shadow. This is fun. (picture) By the way, when I was a student, I bought a theater ticket. I felt that was unique, but, I did not understand it. Then I asked them after the play. Then the director answered, ``What? How impolite you are. How can't you understand my play?'' After few years, I lost the trail of her theatrical company. If you make a sincere question, and the answer was ``How impolite you are.'' Then you made a right question, I believe. The responders need to deceive the question since they cannot answer the question or answering question negates them. I believe both research and software development are based oncommunication. Ma

200906Japan 2.6-3.6

6/2 From the morning, I met N (we met yesterday) and T's family. T was my colleague and friend, but he was gone last year. We visit his grave. Good people dies first, Stupids remains. From Tokyo to Chiba, there is a tunnel-bridge. Half of the way is tunnel and the other is bridge. Why half the way is tunnel and the other half is bridge? A rumor told me that tunnel companies and bridge companies are connected to politician, but, they can not compromise each oher. Then, let's make half is bridge and half is tunnel. This could be lie, but, I can believe it. Connecting bridge and tunnel in the sea requires quite high technology. But here is Japan, politics and concession is more important. Developing a new technology is cheaper than that. The pictures ares from Umihotal, an artificial island connecting the tunnel and the bridge. (Up:Bridge side, Down Tunnel side) 大きな地図で見る This is the cutter for boring. This technology used Seikan-tunnel, and later exported to France and England. Th

200906Japan 30.5 - 1.6

Visit to Japan 5/30 Departure from Berlin. This is my staring point of this journey,Hohenzollerndamm(picture). This is Frankfurt (am Main) airport. Earlier, this airport is not non-smoking, but now they are separated(picture). This is my airplane.(picture) 5/31 Arrived at Narita. I stayed at Ueno. It has been long time to visit a Game center (an amusement place). But many of them are now network game, strategy game, or horse simulation. These are not my favorite. But I found PSIKYO's 1945 and I play it an hour. When I open the suitcase, surprise! A can bier has holes. This day, I washed all my cloths. This is not a hotel, but called weekly mansions. In Japanese, mansion is just a normal room. It's a marketing jargon. This is a bit cheaper than a usual hotel, but no room services. Therefore, I need to cook, wash, and clean the room by myself. If you stay a week, I could recommend this. 6/1 This is supermarket near by my ``mansion.'' Recent price tags seems all wireles

A mystery of transpose of matrix multiplication -- Why (AB)^T = B^T A^T?

At one Wednesday night party (meeting), there was a conversation: ``... I met the woman at that party. She was looking for her job...'' ``What does she look like? Pretty? Positive? Tall?'' ``Positive.'' ``I love a positive woman.'' A few minutes later at the same party, ``... I found this matrix in that paper. It was constructed by...'' ``What does the matrix look like? Symmetric? Positive definite? How large?'' ``Positive definite.'' ``I love a positive definite matrix.'' As you see, some of my friends like a positive definite quadratic form matrix. It is also interesting to think about the relationship of this matrix with transpose. But first I would like to talk about transpose only. One of my friend wrote an article `` A mystery of transpose of matrix multiplication -- Why (AB)^T = B^T A^T? '' By the way, it is not comfortable to write a mathematical blog since it is hard to write equations. I have a permission

Reflection Line in 3 minutes

Reflection lines are lines observed on a surface from tube lights. Car designers employed this to see the surface quality. Usually, parallel fluorescent tubes are placed above the car model. But this is quite common in Germany. This is Berlin Hauptbahnhof (main station). The large part of building is transparent (glass). Steel frames are aligned regularly on the ceiling. These are not fluorescent tubes, but reflection line only requires regularly arranged lines. If there is something specular surface, we could see reflection lines. Please look into the widows of this train. We could easily see that each window has a different quality. Most of the windows did not connects smoothly between windows. Link to the explanation slides References [1] Mario Botsch, Mark Pauly, Leif Kobbelt, Pierre Alliez, Bruno Levy, Stephan Bischo, Christian Roeossl, ``Geometric Modeling based on Polygonal Meshes,'' EG2008 Tutorial, 2008 [2] Takashi Kanai, Yusuke Yasui, ``High-quality Display of Subdi

e: The meaning of the base of natural logarithm's definition

Base of natural logarithm appears almost everywhere in mathematics. Many of the sciences also use this number. When I came Germany, I found it on the 10 DM note. 10DM note has a portrait of Gauss. I saw why Germany's science level is high when I found a graph of normal distribution on a 10 DM note. When children got allowance from their parents, they would ask ``what is this curve? who is this?'' Then the parents would answer ``This is Karl Friedrich Gauss. A great mathematician. This curve is called normal distribution. It represents....'' I'm not sure how accurate my imagination is. I think Euro is a good idea, but I missed Gauss on a note. Famous transcendental numbers are e and π. It is well known how the π is defined (circumference/diameter), why e's definition is was not on my high school text book. I found a slide of this explanation and put the link here with the author's permission. Thanks a lot.

Conclusion of lambda

Japanese version Recently I saw this advertisement, ``For the finance specialists: Let's start from the simple thing.'' I assume the simple thing means, 1+1=2. I try to explain in this blog that how to teach 1 + 1 to a machine. I took more than eight months and yet not quite complete. (By the way, this is a tobacco advertisement.) For human beings, this seems simple. But once you want to teach what 1+1 means to a machine, you must know more about it. For example, we discussed what is the numbers, and we represent it as Church numbers since a machine does not know what the meaning of '1' or '2''s sign. Someone may think this is paranoia since this is so natural. I believe ``natural'' does not mean simple. It is just familiar to us. It is not simple at all for me. Some of you might feel it is natural to spend time with your family or your lover. But it is just you are familiar with that, it is not simple thing. It is important for me to see back in

SUB

Japanese version These series of the examples might be not so fun if you don't try to apply them by yourself. If you do not follow them step by step, these are just a bunch of equations. Therefore, I recommend to try it. We will define the subtraction using PRED function. SUB := λ m n. n PRED m SUB 3 2 = (λ m n. n PRED m) (λ f x. f (f (f x))) (λ f x. f (f x)) = (λ n. n PRED (λ f x. f (f (f x)))) (λ f x. f (f x)) = (λ f x. f (f x)) PRED (λ f x. f (f (f x))) = (λ x. PRED (PRED x)) (λ f x. f (f (f x))) You see that the PRED is duplicated as the second argument (= 2). This is the trick. If the second argument (subtrahend) is ten, then PRED is repeated ten times. = PRED (PRED (λ f x. f (f (f x)))) This is PRED (PRED 3). = PRED 2 = 1 Therefore, 3 - 2 = 1. We can do subtraction.

PRED

Japanese version We have addition and multiplication. Next I would like to subtraction. But, we do not have minus numbers of Church numbers. Because we construct the numbers by number of f-s. For simplicity, we do not think about minus numbers here. If you want to know more, you can look up Wikipedia. We prepare PRED before we go to subtraction. The PRED (predecessor) function generates one Church number before the input number. Here we will not think about before the number 0. The definition of PRED is PRED := λ n f x. n (λ g h. h (g f)) (λ u. x) (λ u. u). Let's compute PRED 2. PRED 2 := (λ n f x. n (λ g h. h (g f)) (λ u. x) (λ u. u)) (λ f x. f (f x)) = (λ f x. (λ f x. f (f x)) (λ g h. h (g f)) (λ u. x) (λ u. u)) = (λ f x. (λ x. (λ g h. h (g f)) ((λ g h. h (g f)) x )) (λ u. x) (λ u. u)) = (λ f x. (λ x . (λ g h. h (g f)) (λ h. h (x f))) (λ u. x) (λ u. u)) = (λ f x. (λ g h. h (g f)) (λ h. h ( (λ u. x) f)) (λ u. u)) = (λ f x. (λ h. h ((λ h. h ( (λ u . x) f )) f)) (λ u. u)) Noti

MULT

Japanese version Multiplication is defined as the following. MULT := λ m n f . m (n f) Since 2 := λ f x. f (f x) 3 := λ f x. f (f (f x)), MULT 2 3 := (λ m n f . m (n f)) (λ f x. f (f x)) (λ f x. f (f (f x))) = (λ n f . (λ f x. f (f x)) (n f)) (λ f x. f (f (f x))) You can see that (n f) is copied as many as f-s. = (λ n f . (λ x. (n f) ((n f) x))) (λ f x. f (f (f x))) (n f) is copied the first argument (=2) times. The second argument (=3) is replaced with n of (n f). = (λ f . (λ x. ((λ f x. f (f (f x))) f) (((λ f x. f (f (f x))) f ) x))) = (λ f . (λ x. (λ x . f (f (f x))) (((λ x. f (f (f x)))) x))) = (λ f . (λ x. f (f (f (((λ x . f (f (f x)))) x ) x)))) = (λ f . (λ x . f (f (f (f (f (f x))) x)))) = (λ f . f (f (f (f (f (f x)))))) = 6 There is another multiplication definition. MULT := λ m n. m (PLUS n) 0 I thought this 0 is just number 0 instead of Church number 0, when I saw this in Wilipedia. This is not easy for beginners. MULT 2 3 := (λ m n. m (PLUS n) (λ f x. x)) (λ f x.

ADD

Japanese version Addition is defined by the following. PLUS := λ m n f x. m f (n f x) Let's calculate 1 + 2. 1 and 2 are 1 := λ f x. f x 2 := λ f x. f (f x), respectively. (λ m n f x. m f (n f x)) (λ f x. f x) (λ f x. f (f x)) = (λ n f x. (λ f x. f x) f (n f x)) (λ f x. f (f x)) = (λ n f x. (λ x . f x ) (n f x) ) (λ f x. f (f x)) = (λ n f x. f ( n f x)) (λ f x. f (f x)) = (λ f x. f ((λ f x. f ( f x)) f x)) = (λ f x. f ((λ x . f (f x )) x )) = (λ f x. f (f (f x))) = λ f x. f (f (f x)) = 3 Therefore 1 + 2 = PLUS 1 2 = 3. It seems a magic. But the principle is the same as the Pop1. Church number represents numbers by the number of 'f's. Therefore, addition is basically concatinate the numbers. If 1 = f and 2 = ff, 1 + 2 = f + ff = fff. In the sama way, for example 3 + 4 = fff + ffff = fffffff = 7.