X



トップページ数学
274コメント91KB
【Coq】コンピューターで証明しよう【コック】©2ch.net
■ このスレッドは過去ログ倉庫に格納されています
0104片山博文MZ ◆T6xkBnTXz7B0
垢版 |
2015/02/13(金) 02:36:25.72ID:4T+ZQiA6
同値変換だけで命題論理式を最も単純な節形式にするって未解決だよな?
0108132人目の素数さん
垢版 |
2015/02/16(月) 06:52:55.96ID:eGQOGV7p
私、O'Camlなどでのプログラミング経験はあるが数学の力に自信がないもので、数学書を一人で読み進める時にきちんと証明出来ている確信が欲しくて久しぶりにCoqを触り始めました。
証明のコードを生成してみるのもまた愉し。
0112132人目の素数さん
垢版 |
2015/03/17(火) 11:09:06.79ID:p3znTvh+
検証と証明ってどう違うの
一例の場合か全ての場合かってこと?
0113132人目の素数さん
垢版 |
2015/03/17(火) 12:42:17.91ID:SwDWqZM9
具体的に人間が与えた証明が正しい推論になっているか確かめるのが検証。
証明システムなら人工知能が結論までの道筋を自ら見つけるということになるはず。
0115132人目の素数さん
垢版 |
2015/03/19(木) 15:02:35.75ID:g9YALw9l
Variable A:Type.
Variable B:(A -> Type) -> A -> Type.
Definition mu := fun (x:A) => forall P:(A -> Type), (forall (y:A), B P y -> P y) -> P x.
Hypothesis m : forall (P Q:A -> Type), (forall (x:A), P x -> Q x) -> (forall (x:A), B P x -> B Q x).
での
Theorem r1:forall (x:A), B mu x -> mu x.
の証明なんだけど、
2 subgoals
A : Type
B : (A -> Type) -> A -> Type
m : forall P Q : A -> Type,
(forall x : A, P x -> Q x) -> forall x : A, B P x -> B Q x
x : A
a : B mu x
P : A -> Type
b : forall y : A, B P y -> P y
x0 : A
y : mu x0
============================
forall y0 : A, B (fun x1 : A => P x1) y0 -> P y0
subgoal 2 is:
B mu x
のあとどうすればいいでしょうか?上記のsubgoalの中の
(fun x1 : A => P x1)をPに変える命令とかあるんでしょうか?
0116追加
垢版 |
2015/03/19(木) 15:03:19.56ID:g9YALw9l
ちなみに、
Proof.
intros x a.
unfold mu.
intros P b.
apply b.
apply (m mu P).
intros x0 y.
apply y.
までが上記の結果です。
0117132人目の素数さん
垢版 |
2015/03/23(月) 21:55:09.34ID:hFhIEEUk
>>95
>数学の体系は、公理系によって成り立っている。すなわち、
>当たり前の真実である「公理(axiom)」の集合から「定理(theorem)」を証明により導出し、
>さらに既存の公理の集合と、証明された定理の集合から導出された、新しい定理をさらに土台とする。
>そのように数学は、間違いのない証明によって次々と築き上げるものである。

ゲーデルの不完全性定理によれば
あんたの言ってる事は数学の本性の上っ面でしかない
0121132人目の素数さん
垢版 |
2015/04/17(金) 21:21:52.45ID:oyQOgKjs
>>116
Proof.
intros x a.
unfold mu.
intros P b.
apply b.
apply (m mu P).
intros x0 y.
apply y.
intro y0.
apply (b y0).
apply a.
Qed.
0123132人目の素数さん
垢版 |
2015/04/18(土) 09:18:54.32ID:Q1uVLxMU
直観主義では証明できないので
Require Import Classical.
Variable (p q r:Prop).
Theorem T:((p /\ q) -> r) -> ((p -> r)\/(q -> r)).
Proof.
apply NNPP.
intuition.
Qed.

もっと手を抜くなら
Proof.
tauto.
Qed.
0124132人目の素数さん
垢版 |
2015/04/18(土) 10:22:46.84ID:Q1uVLxMU
p, q に関する排中律だけ仮定して

Variable (p q r:Prop).
Hypotheses (EM_p: p\/~p) (EM_q: q\/~q).
Theorem T:((p /\ q) -> r) -> ((p -> r)\/(q -> r)).
Proof.
intro H.
elim EM_p.
intro H0.
elim EM_q.
intro H1.
apply or_introl.
intro.
apply H.
apply conj.
exact H0.
exact H1.
intro.
apply or_intror.
intro.
contradiction.
intro.
apply or_introl.
contradiction.
Qed.
0125132人目の素数さん
垢版 |
2015/04/18(土) 11:34:32.18ID:Q1uVLxMU
pに関する排中律だけで

Variable (p q r:Prop).
Hypothesis EM_p: p\/~p.
Theorem T:((p /\ q) -> r) -> ((p -> r)\/(q -> r)).
Proof.
intro H.
elim EM_p.
intro H0.
apply or_intror.
intro H1.
apply H.
apply conj.
exact H0.
exact H1.
intro H2.
apply or_introl.
intro H3.
absurd p.
exact H2.
exact H3.
Qed.
0126115
垢版 |
2015/04/18(土) 16:08:27.46ID:Ch74qrhJ
>>121
レス大感謝です。しかし、
apply (b y0).
のところで、
Error: Impossible to unify "B P y0 -> P y0" with
"B (fun x0 : A => P x0) y0 -> P y0".
と叱られました。Coqのバージョンが
Welcome to Coq 8.3pl3
で古いのでしょうか。
0127122
垢版 |
2015/04/18(土) 18:57:48.32ID:CUF6Decr
>>123-125
ありがとうございます。
知らなったタクティクがいっぱいありますね。
0128132人目の素数さん
垢版 |
2015/04/19(日) 20:01:47.33ID:wQv7TFhy
>>126
coq8.4からη変換が入ったみたいね
多分これでη変換無しで行けると思う

Variable A:Type.
Variable B:(A -> Type) -> A -> Type.
Definition mu := fun (x:A) => forall P:(A -> Type), (forall (y:A), B P y -> P y) -> P x.
Hypothesis m : forall (P Q:A -> Type), (forall (x:A), P x -> Q x) -> (forall (x:A), B P x -> B Q x).

Theorem r1:forall (x:A), B mu x -> mu x.
Proof.
intros x a.
unfold mu.
intros P b.
apply b.
apply (m mu P).
intros x0 y.
apply y.

intros y0 c.
apply b.
apply (m (fun x : A => P x) P).
trivial.
exact c.
exact a.
Qed.
0129115
垢版 |
2015/04/21(火) 16:23:18.95ID:X1phHP6G
>>128
レス大感謝です。さて、また私にとって難題です。エラーが出る最小限の
手順を用意しましたので、偉い方、どうかお付き合いください。
第1の例
Definition Eqt (A B:Type): Prop := (A = B) \/ (B = A).

Axiom Ee : forall (a b:Set), Eqt a b -> ((a = b) /\ (b = a)).

Theorem Eab : forall (a b:Set), ((a = b) \/ (b = a)) -> a = b.
Proof.
intros a b Hab.
assert (Hta:(a = b) /\ (b = a)).
apply Ee.
unfold Eqt.
assumption.(*ここでエラーが出ます*)
Qed.

これは、Display implicit argumentsとDeactivate notations display
をすることによって、Implicitな変数が原因であることがわかりました。
0130129
垢版 |
2015/04/21(火) 16:25:47.49ID:X1phHP6G
そこで、次のように証明手順を変えてみると、なんと、最期のassumptionで
Proof completed.が表示されるのに、Qedの後エラーとなるのです。
第2の例
Definition Eqt (A B:Type): Prop := (A = B) \/ (B = A).

Axiom Ee : forall (a b:Set), Eqt a b -> ((a = b) /\ (b = a)).

Theorem Eab : forall (a b:Set), ((a = b) \/ (b = a)) -> a = b.
Proof.
intros a b Hab.
assert (Hta:(a = b) /\ (b = a)).
apply Ee in Hab.
assumption.
elim Hta.
intros H H0.
assumption.
Qed.

どうかお救いください。トホホ
0131132人目の素数さん
垢版 |
2015/04/24(金) 23:44:49.27ID:RQUiSeMS
@eq Set a b と @eq Type a b は違う型なのが原因な気がする。
130のようなQedでエラーになるのは結構あって、証明モードの途中ではあんまり頑張って型検査しないから、
こういう微妙な型の差しかないときはしかたないかな。
0132129
垢版 |
2015/04/29(水) 09:13:55.74ID:Z8S8LZWA
レス大感謝です。結局は反則をすることによって解決しました。つまり、
証明法を探すのではなく、>>129
>Definition Eqt (A B:Type): Prop := (A = B) \/ (B = A).
の部分を
Definition Eqt (T:Type) (A B:T) : Prop := (eq (A := T) A B) \/ (eq (A := T) B A).
Implicit Arguments Eqt [T].
と変えました。これで、>>129の証明の仕方でもエラーは出なくなりました。
ちなみに最期まで証明すると、
Axiom Ee : forall (a b:Set), Eqt a b -> ((a = b) /\ (b = a)).

Theorem Eab : forall (a b:Set), ((a = b) \/ (b = a)) -> a = b.
Proof.
intros a b Hab.
assert (Hta:(a = b) /\ (b = a)).
apply Ee.
unfold Eqt.
assumption. (*ここでエラーが出ずに先へ進めます*)
elim Hta; intros H1 H2.
assumption.
Qed.
0133132人目の素数さん
垢版 |
2015/04/29(水) 21:07:39.24ID:DcI2ISH9
Coqで作られたCコンパイラがあるそうですが、
詳しいことがわかるURLないでしょうか。
0135133
垢版 |
2015/04/30(木) 11:12:49.99ID:YN5jSrOT
ありがとうございます。
読んでみます。
0139132人目の素数さん
垢版 |
2015/05/29(金) 21:19:13.70ID:sppsbb3D
Coqだと停止しないコードは書けないそうですが、
停止するコードは必ずCoqでも等価なコードがかけるのかどうか気になります。
書けるんでしょうか?
0140132人目の素数さん
垢版 |
2015/06/01(月) 20:03:21.42ID:vP0/D1Ed
停止するかどうかわかるということは停止までのステップ数も見積もれるんでしょうか。
大まかでいいので。
0141132人目の素数さん
垢版 |
2015/06/17(水) 02:15:51.60ID:w70GpJG/
Coqそのものの話じゃなくてすいませんが、software foundationsと言うCoqの解説書↓
http://www.cis.upenn.edu/~bcpierce/sf/current/index.html

があって、ここのdownloadから拾ってきたものでPDF作る(make, make pdfする)と章順が逆になって、最初にPostscriptが
最後がPrefaceとSymbolになったものができてしまいます。

正しくmakeできた方いたら、やり方教えて下さい。
0143141
垢版 |
2015/06/21(日) 09:25:51.67ID:szLD4AMj
make all.pdfした時に実行されるcoqdepの出力が逆順になっているので、
これをシェルスクリプトで逆順にしたら、それらしい順番のPDFになりました。
書き忘れましたが、使ってた環境はcoq 8.4pl6です。
お騒がせしました
0144132人目の素数さん
垢版 |
2015/06/23(火) 19:05:42.67ID:y39xeCDy
>>142
返信遅れてすいません。
読んでもよく理解できないTT

たとえば2つのプログラムが与えられて、
どちらが後に停止するか、みたいなことはできるんでしょうか。
アッカーマン関数のような巨大な関数との比較がしたいのですが。
0146132人目の素数さん
垢版 |
2015/11/02(月) 15:40:58.39ID:voHQlbVG
数学セミナーvol.54 no.11 649
特集 コンピュータにできる数学・できない数学
 Coq:型理論から来た証明支援系, Jacques Garrigue
0147132人目の素数さん
垢版 |
2016/05/25(水) 19:39:54.39ID:EB6pp118
質問よろしいでしょうか。
「x>1ならば、そのべき乗は、いつか特定の数を追い抜く」という命題が証明できません。
Require Import Omega.

Theorem multi_inf_gt3:
forall (x : nat), x>1 -> exists m : nat, x^m > 1000.
proof.
intros.
exists 1000.
induction x.
omega.

assert (x>1 -> x^1000<S x^1000).
intro.
apply (Nat.pow_lt_mono_l_iff x (S x) 1000).
auto.
auto.

assert ((x>1->x^1000>1000)->(x>1->x^1000<S x^1000)->(x>1->S x^1000>1000)).
omega.

apply H1 in H0.
apply H0.
apply IHx.
ここで、仮定は「S x > 1」、ゴールは「x > 1」となって、証明できません。
お知恵を貸していただけないでしょうか……
0148132人目の素数さん
垢版 |
2016/05/25(水) 20:46:14.27ID:EofZeTbn
まずはこれを解いてみるとか。

Require Import Omega.

Theorem t:
exists m : nat, 2^m > 1000.
0149132人目の素数さん
垢版 |
2016/05/25(水) 20:55:32.32ID:EofZeTbn
俺の環境じゃ以下のもOmega解いてくれなかったわ。なぜ?

Theorem t:
2^10 > 1000.
0150132人目の素数さん
垢版 |
2016/05/25(水) 23:04:16.75ID:EB6pp118
僕のCoqバージョンはversion 8.5pl1 (April 2016)ですが、
僕もomega単独では解けませんでした。

Theorem t1:
2^10 > 1000.
(* proof. *)
simpl.
omega.
Qed.

Theorem t2:
exists m : nat, 2^m > 1000.
(* proof. *)
exists 10.
simpl.
omega.
Qed.
0152132人目の素数さん
垢版 |
2016/05/25(水) 23:39:51.15ID:fzY8lffh
omegaは基本的に掛け算には無力
プレスバーガー算術を対象としているから、らしい

simplは単に定義に従って簡約してくれる
よって>>149には適用できるが、>>148はmatchできなくて無理
0153132人目の素数さん
垢版 |
2016/05/26(木) 00:17:18.47ID:vUOIQwNh
できました!
2^10=1024 > 1000を使うのがポイントだったみたいです。

Require Import Omega.

Theorem multi_inf_gt4:
forall (x : nat), x>1 -> exists m : nat, x^m > 1000.
(* proof. *)
intro.
intro.
destruct x.
omega.

exists 10.

assert (S x>1 -> 2^10 <= S x^10).
intro.
apply (Nat.pow_le_mono_l_iff 2 (S x) 10).
auto.
auto.

change (S x > 1 -> 1024 <= S x ^ 10) in H0.
apply H0 in H.
omega.
Qed.

レスして下さった皆様、ありがとうございます。
次は実数でチャレンジするかも!?
0155132人目の素数さん
垢版 |
2016/05/27(金) 03:19:24.12ID:ItPB2mak
実数でもx>2の場合はできました。
x^10を原始的にxで割っていく方法です。 右辺が10000だったらどーするんだwww

Require Import Rbase.
Require Import Fourier.

Theorem multi_inf_gt6:
forall (x : R), x>2 -> exists m : nat, (Rpow_def.pow x m)>1000.
Proof.
intro.
intro.

exists 10%nat.

simpl.

apply Rmult_le_0_lt_compat.
fourier.
fourier.
apply H.

apply Rmult_le_0_lt_compat.
fourier.
fourier.
apply H.

apply Rmult_le_0_lt_compat.
fourier.
fourier.
apply H.

assert (2*/2*125=125).
apply Rinv_r_simpl_r.
discrR.
assert (forall (a b c d:R), a*b*c = a*(b*c)).
intros.
ring.
rewrite H1 in H0.
rewrite <- H0.
apply (Rmult_le_0_lt_compat 2 x (/2*125) (x*(x*(x*(x*(x*(x*1)))))) ).
fourier.
fourier.
apply H.

all: cycle 1.
apply x.
0156132人目の素数さん
垢版 |
2016/05/27(金) 03:25:03.30ID:ItPB2mak
assert (2*/2*(/2*125)=/2*125).
apply (Rinv_r_simpl_r 2 (/2*125)).
discrR.
rewrite H1 in H2.
rewrite <- H2.
apply (Rmult_le_0_lt_compat 2 x (/2*(/2*125)) (x*(x*(x*(x*(x*1))))) ).
fourier.
fourier.
apply H.

assert (2*/2*(/2*(/2*125))=/2*(/2*125)).
apply (Rinv_r_simpl_r 2 (/2*(/2*125)) ).
discrR.
rewrite H1 in H3.
rewrite <- H3.
apply (Rmult_le_0_lt_compat 2 x (/2*(/2*(/2*125))) (x*(x*(x*(x*1)))) ).
fourier.
fourier.
apply H.

assert ( 2*/2*(/2*(/2*(/2*125))) = /2*(/2*(/2*125)) ).
apply (Rinv_r_simpl_r 2 (/2*(/2*(/2*125))) ).
discrR.
rewrite H1 in H4.
rewrite <- H4.
apply (Rmult_le_0_lt_compat 2 x (/2*(/2*(/2*(/2*125)))) (x*(x*(x*1))) ).
fourier.
fourier.
apply H.

assert ( 2*/2*(/2*(/2*(/2*(/2*125)))) = /2*(/2*(/2*(/2*125))) ).
apply (Rinv_r_simpl_r 2 (/2*(/2*(/2*(/2*125)))) ).
discrR.
rewrite H1 in H5.
rewrite <- H5.
apply (Rmult_le_0_lt_compat 2 x (/2*(/2*(/2*(/2*(/2*125))))) (x*(x*1)) ).
fourier.
fourier.
apply H.

assert ( 2*/2*(/2*(/2*(/2*(/2*(/2*125))))) = /2*(/2*(/2*(/2*(/2*125)))) ).
apply (Rinv_r_simpl_r 2 (/2*(/2*(/2*(/2*(/2*125))))) ).
discrR.
rewrite H1 in H6.
rewrite <- H6.
apply (Rmult_le_0_lt_compat 2 x (/2*(/2*(/2*(/2*(/2*(/2*125)))))) (x*1) ).
fourier.
fourier.
apply H.
0157132人目の素数さん
垢版 |
2016/05/27(金) 03:29:56.38ID:ItPB2mak
fourier.
apply x.
apply x.
apply x.
apply x.
apply x.
Qed.

1<x<2の場合はどうするんだろう?
0159132人目の素数さん
垢版 |
2016/05/30(月) 01:07:49.80ID:nh+30MzG
1<x<2の場合は、lim[x->∞](1+1/x)^x=eをヒントにできないかな、と思っています。

今日のCoq:
Require Import Rbase.
Require Import Fourier.

Lemma l2:
forall (x y:R), y>1 -> x=1+1/y -> 1<x<2.
Proof.
intros.
rewrite H0.

assert (forall (a b:R), a<b -> 1+a<1+b).
intro.
intro.
intro.
fourier.

apply conj.

assert (1+0=1).
ring.

replace (1<1+1/y) with (1+0<1+1/y).
apply (H1 0 (1/y)).

all: cycle 1.
rewrite H2.
reflexivity.

all: cycle 1.
assert (0<1 -> 0<1/y -> 1/y*0<1/y*1).
intro.
apply (Rfourier_lt 0 1 (1/y)).
auto.
assert (1/y*0 = 0).
ring.
rewrite H4 in H3.
assert (1/y*1 = 1/y).
ring.
rewrite H5 in H3.
ここまでで、仮定が0 <1 -> 0<1/ y -> 0 <1/ y、
サブコールが0 < 1 / yで頓挫。。。
0161132人目の素数さん
垢版 |
2016/06/01(水) 20:28:33.76ID:Ih6s2JtZ
1<x<2 -> x^m>1000、こんな感じになりました。existの形では出来なかったです。
まず1<x<2 -> x^m>2^10を証明して、それから1<x<2 -> x^m>1000を証明しています。

Require Import Rbase.
Require Import Fourier.

Theorem multi_inf_gt7':
forall (x y:R), 1<x<2 ->
x=1+1/y ->
(Rpow_def.pow x (Z.to_nat (up y)))>2 ->
(Rpow_def.pow x ((Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+
(Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+
(Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+
(Z.to_nat (up y))))>2*2*2*2*2*2*2*2*2*2.
Proof.
intros.

rewrite Rdef_pow_add.
(↑を9回)

apply Rmult_le_0_lt_compat.
fourier.
fourier.
(↑を9回)

apply H1.
(↑を10回)
Qed.
0162132人目の素数さん
垢版 |
2016/06/01(水) 20:31:57.00ID:Ih6s2JtZ
Theorem multi_inf_gt7:
forall (x y:R), 1<x<2 ->
x=1+1/y ->
(Rpow_def.pow x (Z.to_nat (up y)))>2 ->
(Rpow_def.pow x ((Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+
(Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+
(Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+
(Z.to_nat (up y))))>1000.
Proof.
intros.

assert ((Rpow_def.pow x ((Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+
(Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+
(Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+
(Z.to_nat (up y))))>2*2*2*2*2*2*2*2*2*2 ->
(Rpow_def.pow x
((Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+
(Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+
(Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))+(Z.to_nat (up y))))>1000).
intro.
fourier.

apply H2.

apply multi_inf_gt7'.
apply H.
apply H0.
apply H1.
Qed.
0163132人目の素数さん
垢版 |
2016/06/01(水) 20:37:28.80ID:Ih6s2JtZ
仮定に使ってる(1+1/y)^y>2ですが、
これをCoqで証明するのは難しそうなので、
このへんにしておきます。
0164片山博文MZ ◆T6xkBnTXz7B0
垢版 |
2016/07/04(月) 17:27:13.86ID:I+l74NfK
今考えていることを書きます。

1.都内でCoq大会を開きたい。ゲーム形式でCoqの技能を競う。
2.Coqの数式操作をGUIでできるようにしたい。部分数式ごとに適用できるタクティクを「見える化」したい。
3.Coq Twitter BotやCoq onlineを作りたい。
0165片山博文MZ ◆T6xkBnTXz7B0
垢版 |
2016/07/04(月) 17:34:29.59ID:I+l74NfK
でもOCamlを勉強する時間がないんだ。
やらないといけないことが他にもあるし。
0167132人目の素数さん
垢版 |
2016/07/04(月) 20:23:53.31ID:lwP0CPv1
日本語の良いチュートリアルが欲しい。
インタラクティブなやつならなお良し。
0168132人目の素数さん
垢版 |
2016/07/04(月) 21:14:49.99ID:b2jsrh3I
>>164
onlineはproofwebやらjscoqやらあるしbotの方が面白そうだな
140字でどの程度のことができるのかわからんが
0171132人目の素数さん
垢版 |
2016/07/08(金) 09:21:21.88ID:LlF6GjmQ
proofwebでcoqを使うと、画面の右下にGentzenのproof treeを
表示してくれるのですが、その機能をローカルに自分のパソコンでも
使えるようにできるのですか?できるのでしたらやり方を教えてもらえないで
しょうか。
0173171
垢版 |
2016/07/09(土) 13:47:50.56ID:n5Zs2sWR
>>172
レスありがとうございます。でも今Linuxは無理です。
残念です。
0176132人目の素数さん
垢版 |
2017/06/18(日) 16:49:48.59ID:v2schHZM
苗■

405 : 猫は唯の馬鹿 ◆MuKUnGPXAY [age] 投稿日:2011/04/09(土) 15:29:50.46
0177◆2VB8wsVUoo
垢版 |
2017/06/18(日) 17:35:53.09ID:ze+BLRMV
★★★数学徒は馬鹿板をしない生活を送り、日頃から真面目に学問に精進すべき。★★★

0190◆2VB8wsVUoo
垢版 |
2017/06/19(月) 05:24:06.21ID:pqzlCEdf
★★★数学徒は馬鹿板をしない生活を送り、日頃から真面目に学問に精進すべき。★★★

■ このスレッドは過去ログ倉庫に格納されています

ニューススポーツなんでも実況