Mais conteúdo relacionado
ゆとりが数週間でC++を始めるようです
- 4. ゆとりが数日間でC++を
始めるようです
• えりっく さーとる(@siritori)
• ここの情報科学類2年生
• C++わかんない
• 論理やったり(Alloy)
• 分散しようとしたり(Erlang)
• 自然言語処理しようとしたり
• こういうタイトルで発表するのって
どうかと思いますよねorz
- 5. ゆとりが数日間でC++を
始めるようです
• 水曜日(23日)から勉強開始
• C++歴 : 3日
• コケたとことか挙げてみます
• 勉強がてら作ったものとか紹介します
- 10. 「使うな!」
っていう仕様が大杉
把握してるだけでも
・auto_ptr
・独立参照
・const_cast
・protected
お前は
ハウルの動く城か
- 21. 証明木の例
仮定aからB Aが導け
ればOK
[a:A∧B]
⊃I,a
A∧B⇒B∧A
- 22. 証明木の例
A BなんだからBは成
り立つよね
[a:A∧B]
∧E2
B
⊃I,a
A∧B⇒B∧A
- 24. 証明木の例
BもAも成り立つから、
B Aっていえるよね
[a:A∧B]
[a:A∧B]
∧E
2
∧E
1
B
A
∧I
⊃I,a
B∧A
A∧B⇒B∧A
- 25. 証明木の例
[a:A∧B]
[a:A∧B]
∧E
2
∧E
1
B
A
∧I
⊃I,a
B∧A
A∧B⇒B∧A
- 28. Prop
class Prop {
public:
virtual PropType type() const = 0;
friend ostream &operator<<(ostream &stream, const Prop *p) {
return p->print(stream);
}
private:
virtual ostream &print(ostream &stream) const = 0;
};
- 29. Prop
OrProp : public Prop {
const Prop *lp_;
const Prop *rp_;
public:
explicit OrProp(const Prop *lp, const Prop *rp):lp_(lp),rp_(rp){}
private:
ostream &print(ostream &stream) const {
if(OR >= lp_->type()) stream << "(" << lp_ << ")";
else stream << lp_;
stream << " ∨ ";
if(OR > rp_->type()) stream << "(" << rp_ << ")";
else stream << rp_;
return stream;
}
};
- 32. で、どんなのできたの
Theorem *a = new Theorem(
new AndProp(
new AtomicProp('A'), new AtomicProp('B')
),'a');
cout << a << endl;
Theorem *t1 = Rule::and_elim2(a);
cout << t1 << endl;
Theorem *t2 = Rule::and_elim1(a);
cout << t2 << endl;
Theorem *t3 = Rule::and_intro(t1, t2);
cout << t3 << endl;
Theorem *con = Rule::implication_intro(t3, 'a');
cout << con << endl;
- 33. で、どんなのできたの
Theorem *a = new Theorem(
new AndProp(
new AtomicProp('A'), new AtomicProp('B')
),'a');
cout << a << endl;
Theorem *t1 = Rule::and_elim2(a);
cout << t1 << endl;
[a : A B]をつくる
Theorem *t2 = Rule::and_elim1(a);
cout << t2 << endl;
Theorem *t3 = Rule::and_intro(t1, t2);
cout << t3 << endl;
Theorem *con = Rule::implication_intro(t3, 'a');
cout << con << endl;
- 34. で、どんなのできたの
Theorem *a = new Theorem(
[a:A B]から
new AndProp(
BとAを導く
new AtomicProp('A'), new AtomicProp('B')
),'a');
cout << a << endl;
Theorem *t1 = Rule::and_elim2(a);
cout << t1 << endl;
Theorem *t2 = Rule::and_elim1(a);
cout << t2 << endl;
Theorem *t3 = Rule::and_intro(t1, t2);
cout << t3 << endl;
Theorem *con = Rule::implication_intro(t3, 'a');
cout << con << endl;
- 35. で、どんなのできたの
Theorem *a = new Theorem(
new AndProp(
new AtomicProp('A'), new AtomicProp('B')
),'a');
cout << a << endl;
BとAから
Theorem *t1 = Rule::and_elim2(a);
cout << t1 << endl;
B Aを導く
Theorem *t2 = Rule::and_elim1(a);
cout << t2 << endl;
Theorem *t3 = Rule::and_intro(t1, t2);
cout << t3 << endl;
Theorem *con = Rule::implication_intro(t3, 'a');
cout << con << endl;
- 36. で、どんなのできたの
Theorem *a = new Theorem(
new AndProp(
new AtomicProp('A'), new AtomicProp('B')
),'a');
cout << a << endl;
Theorem *t1 = Rule::and_elim2(a);
cout << t1 << endl;
B Aと仮定aから
Theorem *t2 = Rule::and_elim1(a);
cout << t2 << endl;
A B B Aを導く
Theorem *t3 = Rule::and_intro(t1, t2);
cout << t3 << endl;
Theorem *con = Rule::implication_intro(t3, 'a');
cout << con << endl;
- 37. 実行すると
Theorem *a = new Theorem(
new AndProp(
new AtomicProp('A'), new AtomicProp('B')
),'a');
cout << a << endl;
- 38. 実行すると
Theorem *t1 = Rule::and_elim2(a);
cout << t1 << endl;
Theorem *t2 = Rule::and_elim1(a);
cout << t2 << endl;
- 41. 仮定なしで導けた→証明完了
,.へ
___ ム i
「 ヒ_i〉 ゝ 〈
ト ノ iニ(()
i { ____ | ヽ
i i /__, , ‐-\ i }
| i /(●) ( ● )\ {、 λ
ト‐┤. / (__人__) \ ,ノ  ̄ ,!
i ゝ、_ | ´ ̄` | ,. '´ハ ,!
. ヽ、 `` 、,__\ /" \ ヽ/
\ノ ノ ハ ̄r/:::r―--―/::7 ノ /
ヽ. ヽ::〈; . '::. :' |::/ / ,. "
`ー 、 \ヽ::. ;:::|/ r'"
/ ̄二二二二二二二二二二二二二二二二ヽ
| | 動作確認 │|
\_二二二二二二二二二二二二二二二二ノ
- 42. おぼえたこと
• 演算子オーバーロードってすごい
– 泣きながら関数定義してたCがバカみたい
• clang++の優しさに泣く
– ありがとう、キミのお陰でめげずにいられた
• すみません... constを前置してすみません...
• いろんな書き方ができるせいで流儀を身に
付けるまでに結構な時間がかかりそう
• 闇の軍団の人たち優しい(何度も助けられ
ながらお勉強しました)