Coq中普遍量化的ponens方式
我是Coq定理证明者的新手。因此,在阅读教程时,我很可能错过了一些基本的东西 在我提问之前,让我假设一些假设,并重述一些假设 那太好了 所以,现在我想知道:在具有普遍量化命题的Coq中,这样的假设推理是可能的吗 在我的示例中,我让变量的范围超过Coq中普遍量化的ponens方式,coq,Coq,我是Coq定理证明者的新手。因此,在阅读教程时,我很可能错过了一些基本的东西 在我提问之前,让我假设一些假设,并重述一些假设 那太好了 所以,现在我想知道:在具有普遍量化命题的Coq中,这样的假设推理是可能的吗 在我的示例中,我让变量的范围超过nat,但这是一个任意选择。任何集合(任何集合s?)的组合(任何类型?)都可以 这是错误输出: > exact (forall n : nat, QuantifiedMajor n (QuantifiedMinor n)) . >
nat
,但这是一个任意选择。任何集合
(任何集合
s?)的组合(任何类型
?)都可以
这是错误输出:
> exact (forall n : nat, QuantifiedMajor n (QuantifiedMinor n)) .
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: In environment
n : nat
The term "QuantifiedMajor n (QuantifiedMinor n)" has type
"FunctionConsequent n" which should be Set, Prop or Type.
我的问题是:
Set
,Prop
或type
,未量化)?如果Coq更加宽松,是否会出现任何不一致当然,诀窍在于这里使用的
forall
是错误的,forall
建立了一个类型抽象,但相应的术语是一个函数
Theorem fancy : forall (p q : nat -> Prop),
(forall n, p n) -> (forall n, p n -> p q) -> (forall n, q n).
exact (fun P Q pproof impl =>
fun n => impl _ (pproof n)).
Qed.
这也可以通过良好的旧auto
解决。如果你不把打字分层一点,你可以推导出一个罗素悖论式的悖论,如果我们允许Set:Set
而不是Set:Type
,那么我们就有大问题了
这里您似乎唯一缺少的是,
forall
只是->
的一般化版本,要见证一些普遍量化的语句将是一些lambda。您以前之所以避免使用它,是因为猜测,而不是将所有内容都包含在一个术语中。当然,这里使用的技巧是forall
是错误的,forall
建立了对某个内容的类型抽象,但相应的术语是一个函数
Theorem fancy : forall (p q : nat -> Prop),
(forall n, p n) -> (forall n, p n -> p q) -> (forall n, q n).
exact (fun P Q pproof impl =>
fun n => impl _ (pproof n)).
Qed.
这也可以通过良好的旧auto
解决。如果你不把打字分层一点,你可以推导出一个罗素悖论式的悖论,如果我们允许Set:Set
而不是Set:Type
,那么我们就有大问题了
这里您似乎唯一缺少的是,forall
只是->
的一般化版本,要见证一些普遍量化的语句将是一些lambda。您以前之所以避免使用它,是因为猜测,而不是将所有内容都包含在一个术语中。当然,这里使用的技巧是forall
是错误的,forall
建立了对某个内容的类型抽象,但相应的术语是一个函数
Theorem fancy : forall (p q : nat -> Prop),
(forall n, p n) -> (forall n, p n -> p q) -> (forall n, q n).
exact (fun P Q pproof impl =>
fun n => impl _ (pproof n)).
Qed.
这也可以通过良好的旧auto
解决。如果你不把打字分层一点,你可以推导出一个罗素悖论式的悖论,如果我们允许Set:Set
而不是Set:Type
,那么我们就有大问题了
这里您似乎唯一缺少的是,forall
只是->
的一般化版本,要见证一些普遍量化的语句将是一些lambda。您以前之所以避免使用它,是因为猜测,而不是将所有内容都包含在一个术语中。当然,这里使用的技巧是forall
是错误的,forall
建立了对某个内容的类型抽象,但相应的术语是一个函数
Theorem fancy : forall (p q : nat -> Prop),
(forall n, p n) -> (forall n, p n -> p q) -> (forall n, q n).
exact (fun P Q pproof impl =>
fun n => impl _ (pproof n)).
Qed.
这也可以通过良好的旧auto
解决。如果你不把打字分层一点,你可以推导出一个罗素悖论式的悖论,如果我们允许Set:Set
而不是Set:Type
,那么我们就有大问题了
这里您似乎唯一缺少的是,forall
只是->
的一般化版本,要见证一些普遍量化的语句将是一些lambda。您以前之所以避免使用它,是因为猜测,而不是将所有内容都放在一个术语内。谢谢您,jozefg。我想出来了
我需要使用的策略是intro
Coq < Theorem QuantifiedConsequentProof : forall n : nat, FunctionConsequent n .
QuantifiedConsequentProof < Proof .
QuantifiedConsequentProof < intro .
QuantifiedConsequentProof < exact (QuantifiedMajor n (QuantifiedMinor n)) .
QuantifiedConsequentProof < Qed .
然后我可以看到这个构造好的证明,从中我可以推断出另一种定义它的方法:
Coq < Theorem QuantifiedConsequentProof : forall n : nat, FunctionConsequent n .
QuantifiedConsequentProof < Proof .
QuantifiedConsequentProof < exact (fun n : nat =>
QuantifiedMajor n (QuantifiedMinor n)) .
QuantifiedConsequentProof < Qed .
Coq<定理量化的结果证明:对于所有n:nat,函数结果n。
定量的结果证明。
量化结果证明<精确(乐趣n:nat=>
量化的主要名词(量化的最小名词)。
量化结果证明
所以,基本上我的错误是,证明应该是一个函数,而不是所有
-表达式的。证明的类型是所有
-命题的,但证明本身是一个函数
Theorem fancy : forall (p q : nat -> Prop),
(forall n, p n) -> (forall n, p n -> p q) -> (forall n, q n).
exact (fun P Q pproof impl =>
fun n => impl _ (pproof n)).
Qed.
事实上,我想得越多,它就越有意义:这个证明,作为一个函数,可以反过来应用于一个论点,产生一个新的证明。当应用于类型为nat的表达式时,这将导致实例化定理的证明。谢谢,jozefg。我想出来了
我需要使用的策略是intro
Coq < Theorem QuantifiedConsequentProof : forall n : nat, FunctionConsequent n .
QuantifiedConsequentProof < Proof .
QuantifiedConsequentProof < intro .
QuantifiedConsequentProof < exact (QuantifiedMajor n (QuantifiedMinor n)) .
QuantifiedConsequentProof < Qed .
然后我可以看到这个构造好的证明,从中我可以推断出另一种定义它的方法:
Coq < Theorem QuantifiedConsequentProof : forall n : nat, FunctionConsequent n .
QuantifiedConsequentProof < Proof .
QuantifiedConsequentProof < exact (fun n : nat =>
QuantifiedMajor n (QuantifiedMinor n)) .
QuantifiedConsequentProof < Qed .
Coq<定理量化的结果证明:对于所有n:nat,函数结果n。
定量的结果证明。
量化结果证明<精确(乐趣n:nat=>
量化的主要名词(量化的最小名词)。
量化结果证明
所以,基本上我的错误是,证明应该是一个函数,而不是所有
-表达式的。证明的类型是所有
-命题的,但证明本身是一个函数
Theorem fancy : forall (p q : nat -> Prop),
(forall n, p n) -> (forall n, p n -> p q) -> (forall n, q n).
exact (fun P Q pproof impl =>
fun n => impl _ (pproof n)).
Qed.
其实越