AArch64をターゲットとしたgcc4.9.2ビルド

configureの階層にbuildディレクトリを作らないとエラーになった。

$ mkdir build
$ cd build
$ ../configure --target=aarch64-linux-gnu --disable-nls --disable-shared --disable-multilib --disable-libgomp --disable-threads --enable-languages=c,c++ --disable-libstdcxx-pch --disable-bootstrap

makeを実行するとエラーになるのでソースを修正する。

contrib/texi2pod.pl L.319 のbrace"{", "}"をエスケープする。

315     /^\@item\s+(.*\S)\s*$/ and $endw eq "multitable" and do {
316        @columns = ();
317        for $column (split (/\s*\@tab\s*/, $1)) {
318            # @strong{...} is used a @headitem work-alike
319            $column =~ s/^\@strong\{(.*)\}$/$1/;
320            push @columns, $column;
321        }
322        $_ = "\n=item ".join (" : ", @columns)."\n";
323     };

gcc/cp/cfns.gperf L.25〜27を追加

 23 #ifdef __GNUC__
 24 __inline
 25 #ifdef __GNUC_STDC_INLINE__
 26 __attribute__ ((__gnu_inline__))
 27 #endif
 28 #endif
 29 const char * libc_name_p (const char *, unsigned int);

gcc/cp/cfns.h L.56〜58を追加

 54 #ifdef __GNUC__
 55 __inline
 56 #ifdef __GNUC_STDC_INLINE__
 57 __attribute__ ((__gnu_inline__))
 58 #endif
 59 #endif
 60 const char * libc_name_p (const char *, unsigned int);

ビルド、インストールする

$ make
$ sudo make install

rustメモ

rustupを用いたrustコンパイラツールのインストール

以下のURLからインストーラをダウンロードする。

https://rustup.rs/

以下のように、binをPATHに追加する。

source $HOME/.cargo/env
  • インストールされるツール
    • cargo
    • rustc
    • rustdoc

新規プロジェクトの作成

以下のようにプロジェクト(e.g. hello)を作成する。

$ cargo new --bin hello

ビルドする。

$ cargo run

標準ライブラリのドキュメントを見る

$ rustup doc --std

crate(依存ライブラリ)のドキュメントを見る

以下のコマンドを実行すると、ドキュメントがプロジェクトのtarget配下にダウンロードされ、ブラウザで開かれる。

crateの例: iron

$ cargo doc -p iron --open

rust言語についてのメモ

  • 関数 fn get_form(_request: &mut Request) -> IronResult { ... } // 仮引数: 型、&は参照?、->の後ろは戻り値の型
  • 変数名を_で始めることでこの変数を使わないことをコンパイラに教える
  • ローカル変数 let mut var = xxx; // mutはmutableのこと?
  • raw string構文 r#\"...\"# ダブルクォートをエスケープなしで使える
  • 関数bodyの最後の式が暗黙に関数の戻り値になる。(注意: セミコロンをつけてはならない)

おまけ ASTダンプ

ASTダンプは、nightly rustでないとできないので、以下のように--channel=nightlyを指定してインストール

$ sh rustup.sh --prefix=/home/xxx/rust_nightly --channel=nightly

ASTダンプコマンド

$ rustc -Z ast-json main.rs

入力ファイル

fn main() {
    println!("Hello, world!");
}

以下のASTが出力されたが、よくわからない。

{
    "module": {
        "inner": {
            "lo": 0,
            "hi": 44
        },
        "items": [
            {
                "ident": "",
                "attrs": [
                    {
                        "id": {
                            "_field0": 1
                        },
                        "style": "Outer",
                        "path": {
                            "span": {
                                "lo": 0,
                                "hi": 0
                            },
                            "segments": [
                                {
                                    "ident": "prelude_import",
                                    "args": null
                                }
                            ]
                        },
                        "tokens": [],
                        "is_sugared_doc": false,
                        "span": {
                            "lo": 0,
                            "hi": 0
                        }
                    }
                ],
                "id": 2,
                "node": {
                    "variant": "Use",
                    "fields": [
                        {
                            "prefix": {
                                "span": {
                                    "lo": 0,
                                    "hi": 0
                                },
                                "segments": [
                                    {
                                        "ident": "{{root}}",
                                        "args": null
                                    },
                                    {
                                        "ident": "std",
                                        "args": null
                                    },
                                    {
                                        "ident": "prelude",
                                        "args": null
                                    },
                                    {
                                        "ident": "v1",
                                        "args": null
                                    }
                                ]
                            },
                            "kind": "Glob",
                            "span": {
                                "lo": 0,
                                "hi": 0
                            }
                        }
                    ]
                },
                "vis": {
                    "node": "Inherited",
                    "span": {
                        "lo": 0,
                        "hi": 0
                    }
                },
                "span": {
                    "lo": 0,
                    "hi": 0
                },
                "tokens": null
            },
            {
                "ident": "std",
                "attrs": [
                    {
                        "id": {
                            "_field0": 0
                        },
                        "style": "Outer",
                        "path": {
                            "span": {
                                "lo": 0,
                                "hi": 0
                            },
                            "segments": [
                                {
                                    "ident": "macro_use",
                                    "args": null
                                }
                            ]
                        },
                        "tokens": [],
                        "is_sugared_doc": false,
                        "span": {
                            "lo": 0,
                            "hi": 0
                        }
                    }
                ],
                "id": 3,
                "node": {
                    "variant": "ExternCrate",
                    "fields": [
                        null
                    ]
                },
                "vis": {
                    "node": "Inherited",
                    "span": {
                        "lo": 0,
                        "hi": 0
                    }
                },
                "span": {
                    "lo": 0,
                    "hi": 0
                },
                "tokens": null
            },
            {
                "ident": "main",
                "attrs": [],
                "id": 4,
                "node": {
                    "variant": "Fn",
                    "fields": [
                        {
                            "inputs": [],
                            "output": {
                                "variant": "Default",
                                "fields": [
                                    {
                                        "lo": 10,
                                        "hi": 10
                                    }
                                ]
                            },
                            "variadic": false
                        },
                        {
                            "unsafety": "Normal",
                            "asyncness": "NotAsync",
                            "constness": {
                                "node": "NotConst",
                                "span": {
                                    "lo": 0,
                                    "hi": 2
                                }
                            },
                            "abi": "Rust"
                        },
                        {
                            "params": [],
                            "where_clause": {
                                "id": 5,
                                "predicates": [],
                                "span": {
                                    "lo": 0,
                                    "hi": 0
                                }
                            },
                            "span": {
                                "lo": 0,
                                "hi": 0
                            }
                        },
                        {
                            "stmts": [
                                {
                                    "id": 22,
                                    "node": {
                                        "variant": "Semi",
                                        "fields": [
                                            {
                                                "id": 10,
                                                "node": {
                                                    "variant": "Block",
                                                    "fields": [
                                                        {
                                                            "stmts": [
                                                                {
                                                                    "id": 21,
                                                                    "node": {
                                                                        "variant": "Semi",
                                                                        "fields": [
                                                                            {
                                                                                "id": 9,
                                                                                "node": {
                                                                                    "variant": "Call",
                                                                                    "fields": [
                                                                                        {
                                                                                            "id": 8,
                                                                                            "node": {
                                                                                                "variant": "Path",
                                                                                                "fields": [
                                                                                                    null,
                                                                                                    {
                                                                                                        "span": {
                                                                                                            "lo": 7767836,
                                                                                                            "hi": 7767859
                                                                                                        },
                                                                                                        "segments": [
                                                                                                            {
                                                                                                                "ident": "$crate",
                                                                                                                "args": null
                                                                                                            },
                                                                                                            {
                                                                                                                "ident": "io",
                                                                                                                "args": null
                                                                                                            },
                                                                                                            {
                                                                                                                "ident": "_print",
                                                                                                                "args": null
                                                                                                            }
                                                                                                        ]
                                                                                                    }
                                                                                                ]
                                                                                            },
                                                                                            "span": {
                                                                                                "lo": 7767836,
                                                                                                "hi": 7767859
                                                                                            },
                                                                                            "attrs": {
                                                                                                "_field0": null
                                                                                            }
                                                                                        },
                                                                                        [
                                                                                            {
                                                                                                "id": 20,
                                                                                                "node": {
                                                                                                    "variant": "Call",
                                                                                                    "fields": [
                                                                                                        {
                                                                                                            "id": 11,
                                                                                                            "node": {
                                                                                                                "variant": "Path",
                                                                                                                "fields": [
                                                                                                                    null,
                                                                                                                    {
                                                                                                                        "span": {
                                                                                                                            "lo": 7767862,
                                                                                                                            "hi": 7767896
                                                                                                                        },
                                                                                                                        "segments": [
                                                                                                                            {
                                                                                                                                "ident": "$crate",
                                                                                                                                "args": null
                                                                                                                            },
                                                                                                                            {
                                                                                                                                "ident": "fmt",
                                                                                                                                "args": null
                                                                                                                            },
                                                                                                                            {
                                                                                                                                "ident": "Arguments",
                                                                                                                                "args": null
                                                                                                                            },
                                                                                                                            {
                                                                                                                                "ident": "new_v1",
                                                                                                                                "args": null
                                                                                                                            }
                                                                                                                        ]
                                                                                                                    }
                                                                                                                ]
                                                                                                            },
                                                                                                            "span": {
                                                                                                                "lo": 7767862,
                                                                                                                "hi": 7767896
                                                                                                            },
                                                                                                            "attrs": {
                                                                                                                "_field0": null
                                                                                                            }
                                                                                                        },
                                                                                                        [
                                                                                                            {
                                                                                                                "id": 14,
                                                                                                                "node": {
                                                                                                                    "variant": "AddrOf",
                                                                                                                    "fields": [
                                                                                                                        "Immutable",
                                                                                                                        {
                                                                                                                            "id": 13,
                                                                                                                            "node": {
                                                                                                                                "variant": "Array",
                                                                                                                                "fields": [
                                                                                                                                    [
                                                                                                                                        {
                                                                                                                                            "id": 12,
                                                                                                                                            "node": {
                                                                                                                                                "variant": "Lit",
                                                                                                                                                "fields": [
                                                                                                                                                    {
                                                                                                                                                        "node": {
                                                                                                                                                            "variant": "Str",
                                                                                                                                                            "fields": [
                                                                                                                                                                "Hello, world!\n",
                                                                                                                                                                "Cooked"
                                                                                                                                                            ]
                                                                                                                                                        },
                                                                                                                                                        "span": {
                                                                                                                                                            "lo": 25,
                                                                                                                                                            "hi": 40
                                                                                                                                                        }
                                                                                                                                                    }
                                                                                                                                                ]
                                                                                                                                            },
                                                                                                                                            "span": {
                                                                                                                                                "lo": 25,
                                                                                                                                                "hi": 40
                                                                                                                                            },
                                                                                                                                            "attrs": {
                                                                                                                                                "_field0": null
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    ]
                                                                                                                                ]
                                                                                                                            },
                                                                                                                            "span": {
                                                                                                                                "lo": 25,
                                                                                                                                "hi": 40
                                                                                                                            },
                                                                                                                            "attrs": {
                                                                                                                                "_field0": null
                                                                                                                            }
                                                                                                                        }
                                                                                                                    ]
                                                                                                                },
                                                                                                                "span": {
                                                                                                                    "lo": 25,
                                                                                                                    "hi": 40
                                                                                                                },
                                                                                                                "attrs": {
                                                                                                                    "_field0": null
                                                                                                                }
                                                                                                            },
                                                                                                            {
                                                                                                                "id": 19,
                                                                                                                "node": {
                                                                                                                    "variant": "AddrOf",
                                                                                                                    "fields": [
                                                                                                                        "Immutable",
                                                                                                                        {
                                                                                                                            "id": 18,
                                                                                                                            "node": {
                                                                                                                                "variant": "Match",
                                                                                                                                "fields": [
                                                                                                                                    {
                                                                                                                                        "id": 15,
                                                                                                                                        "node": {
                                                                                                                                            "variant": "Tup",
                                                                                                                                            "fields": [
                                                                                                                                                []
                                                                                                                                            ]
                                                                                                                                        },
                                                                                                                                        "span": {
                                                                                                                                            "lo": 25,
                                                                                                                                            "hi": 40
                                                                                                                                        },
                                                                                                                                        "attrs": {
                                                                                                                                            "_field0": null
                                                                                                                                        }
                                                                                                                                    },
                                                                                                                                    [
                                                                                                                                        {
                                                                                                                                            "attrs": [],
                                                                                                                                            "pats": [
                                                                                                                                                {
                                                                                                                                                    "id": 16,
                                                                                                                                                    "node": {
                                                                                                                                                        "variant": "Tuple",
                                                                                                                                                        "fields": [
                                                                                                                                                            [],
                                                                                                                                                            null
                                                                                                                                                        ]
                                                                                                                                                    },
                                                                                                                                                    "span": {
                                                                                                                                                        "lo": 25,
                                                                                                                                                        "hi": 40
                                                                                                                                                    }
                                                                                                                                                }
                                                                                                                                            ],
                                                                                                                                            "guard": null,
                                                                                                                                            "body": {
                                                                                                                                                "id": 17,
                                                                                                                                                "node": {
                                                                                                                                                    "variant": "Array",
                                                                                                                                                    "fields": [
                                                                                                                                                        []
                                                                                                                                                    ]
                                                                                                                                                },
                                                                                                                                                "span": {
                                                                                                                                                    "lo": 25,
                                                                                                                                                    "hi": 40
                                                                                                                                                },
                                                                                                                                                "attrs": {
                                                                                                                                                    "_field0": null
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    ]
                                                                                                                                ]
                                                                                                                            },
                                                                                                                            "span": {
                                                                                                                                "lo": 25,
                                                                                                                                "hi": 40
                                                                                                                            },
                                                                                                                            "attrs": {
                                                                                                                                "_field0": null
                                                                                                                            }
                                                                                                                        }
                                                                                                                    ]
                                                                                                                },
                                                                                                                "span": {
                                                                                                                    "lo": 25,
                                                                                                                    "hi": 40
                                                                                                                },
                                                                                                                "attrs": {
                                                                                                                    "_field0": null
                                                                                                                }
                                                                                                            }
                                                                                                        ]
                                                                                                    ]
                                                                                                },
                                                                                                "span": {
                                                                                                    "lo": 7767862,
                                                                                                    "hi": 7767896
                                                                                                },
                                                                                                "attrs": {
                                                                                                    "_field0": null
                                                                                                }
                                                                                            }
                                                                                        ]
                                                                                    ]
                                                                                },
                                                                                "span": {
                                                                                    "lo": 7767836,
                                                                                    "hi": 7767898
                                                                                },
                                                                                "attrs": {
                                                                                    "_field0": null
                                                                                }
                                                                            }
                                                                        ]
                                                                    },
                                                                    "span": {
                                                                        "lo": 7767836,
                                                                        "hi": 7767900
                                                                    }
                                                                }
                                                            ],
                                                            "id": 7,
                                                            "rules": "Default",
                                                            "span": {
                                                                "lo": 7767834,
                                                                "hi": 7767902
                                                            },
                                                            "recovered": false
                                                        },
                                                        null
                                                    ]
                                                },
                                                "span": {
                                                    "lo": 7767834,
                                                    "hi": 7767902
                                                },
                                                "attrs": {
                                                    "_field0": null
                                                }
                                            }
                                        ]
                                    },
                                    "span": {
                                        "lo": 7767834,
                                        "hi": 7767902
                                    }
                                }
                            ],
                            "id": 6,
                            "rules": "Default",
                            "span": {
                                "lo": 10,
                                "hi": 44
                            },
                            "recovered": false
                        }
                    ]
                },
                "vis": {
                    "node": "Inherited",
                    "span": {
                        "lo": 0,
                        "hi": 0
                    }
                },
                "span": {
                    "lo": 0,
                    "hi": 44
                },
                "tokens": [
                    {
                        "variant": "Token",
                        "fields": [
                            {
                                "lo": 0,
                                "hi": 2
                            },
                            {
                                "variant": "Ident",
                                "fields": [
                                    "fn",
                                    false
                                ]
                            }
                        ]
                    },
                    {
                        "variant": "Token",
                        "fields": [
                            {
                                "lo": 3,
                                "hi": 7
                            },
                            {
                                "variant": "Ident",
                                "fields": [
                                    "main",
                                    false
                                ]
                            }
                        ]
                    },
                    {
                        "variant": "Delimited",
                        "fields": [
                            {
                                "lo": 7,
                                "hi": 9
                            },
                            {
                                "delim": "Paren",
                                "tts": []
                            }
                        ]
                    },
                    {
                        "variant": "Delimited",
                        "fields": [
                            {
                                "lo": 10,
                                "hi": 44
                            },
                            {
                                "delim": "Brace",
                                "tts": [
                                    {
                                        "variant": "Token",
                                        "fields": [
                                            {
                                                "lo": 16,
                                                "hi": 23
                                            },
                                            {
                                                "variant": "Ident",
                                                "fields": [
                                                    "println",
                                                    false
                                                ]
                                            }
                                        ]
                                    },
                                    {
                                        "variant": "Token",
                                        "fields": [
                                            {
                                                "lo": 23,
                                                "hi": 24
                                            },
                                            "Not"
                                        ]
                                    },
                                    {
                                        "variant": "Delimited",
                                        "fields": [
                                            {
                                                "lo": 24,
                                                "hi": 41
                                            },
                                            {
                                                "delim": "Paren",
                                                "tts": [
                                                    {
                                                        "variant": "Token",
                                                        "fields": [
                                                            {
                                                                "lo": 25,
                                                                "hi": 40
                                                            },
                                                            {
                                                                "variant": "Literal",
                                                                "fields": [
                                                                    {
                                                                        "variant": "Str_",
                                                                        "fields": [
                                                                            "Hello, world!"
                                                                        ]
                                                                    },
                                                                    null
                                                                ]
                                                            }
                                                        ]
                                                    }
                                                ]
                                            }
                                        ]
                                    },
                                    {
                                        "variant": "Token",
                                        "fields": [
                                            {
                                                "lo": 41,
                                                "hi": 42
                                            },
                                            "Semi"
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    },
    "attrs": [],
    "span": {
        "lo": 0,
        "hi": 44
    }
}

TensorFlowをインストールしてみた

今さらですが、TensorFlowをインストールしてみました。

pipのインストール

$ sudo pacman -S pip

TensorFlow 1.5のインストール

1.9だとillegal instruction (core dumped)になってしまったので1.5を指定しました。

$ pip install tensorflow=1.5 --user

ちなみに--userはローカルインストールするためのオプションです。

次のようにして、インストールパスが確認できます。

$ pip show [パッケージ名]

動作確認

$ python
Python 3.6.4 (default, Jan  5 2018, 02:35:40) 
[GCC 7.2.1 20171224] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2018-04-19 21:12:12.121902: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2
>>> print(sess.run(hello))
b'Hello, TensorFlow!'

Conceptual Mathematics 10.4 Relation between fixed point and retraction theorems

Exercise 1がわからなかった。

円板Dの境界(円周)をCとする。包含写像 j: C \to Dに対して、連続写像 g: D \to D g \circ j = jを満たすとき、別の連続写像f: D -> Dに対して、 \exists x \in D . f(x) = g(x)が成り立つことを示す。

 \forall x \in D . f(x) \neq g(x)を仮定する。
円板D上に異なる2つの点f(x), g(x)をとることができる。この2点を結ぶ線分を延長し、円周Cとの交点をh(x)とする。
hは連続写像であり、jのレトラクション( h \circ j = 1_C)である。なぜなら、 x \in Cに対して g(x)=x=h(x)が成り立つからである。
jの連続なレトラクションは存在しないので、仮定 \forall x \in D . f(x) \neq g(x)は偽、すなわち、 \exists x \in D . f(x)=g(x)