如何在Coq中给出反例?
有没有可能给一个不适用于一般情况的陈述举个反例?比如,all-quantor不分布在连接词“or”上。首先,你会如何陈述如何在Coq中给出反例?,coq,Coq,有没有可能给一个不适用于一般情况的陈述举个反例?比如,all-quantor不分布在连接词“or”上。首先,你会如何陈述 Parameter X : Set. Parameter P : X -> Prop. Parameter Q : X -> Prop. (* This holds in general *) Theorem forall_distributes_over_and : (forall x:X, P x /\ Q x) -> ((forall x:X,
Parameter X : Set.
Parameter P : X -> Prop.
Parameter Q : X -> Prop.
(* This holds in general *)
Theorem forall_distributes_over_and
: (forall x:X, P x /\ Q x) -> ((forall x:X, P x) /\ (forall x:X, Q x)).
Proof.
intro H. split. apply H. apply H.
Qed.
(* This doesn't hold in general *)
Theorem forall_doesnt_distributes_over_or
: (forall x:X, P x \/ Q x) -> ((forall x:X, P x) \/ (forall x:X, Q x)).
Abort.
下面是一个快速而肮脏的方法来证明与你想要的相似的东西:
Theorem forall_doesnt_distributes_over_or:
~ (forall X P Q, (forall x:X, P x \/ Q x) -> ((forall x:X, P x) \/ (forall x:X, Q x))).
Proof.
intros H.
assert (X : forall x : bool, x = true \/ x = false).
destruct x; intuition.
specialize (H _ (fun b => b = true) (fun b => b = false) X).
destruct H as [H|H].
now specialize (H false).
now specialize (H true).
Qed.
我必须量化否定中的xp和Q,以便能够提供我想要的。你不能用你的
参数
s来做这件事,因为它们以某种方式固定了一个抽象的X
,P
和Q
,从而使你的定理可能是真的。一般来说,如果你想产生一个反例,你可以陈述公式的否定,然后证明这个否定是满足的