简体   繁体   English

(A -> B) /\\ (B -> C) -> (A -> C) 在 Coq 中?

[英](A -> B) /\ (B -> C) -> (A -> C) in Coq?

I am learning Coq via the book software foundations, and have trouble proving the following lemma (which I require to prove other theorems.)我正在通过书籍软件基础学习 Coq,并且无法证明以下引理(我需要证明其他定理。)

Lemma if_trans : 
  forall (P Q R: Prop),
    (P -> Q) /\ (Q -> R) -> (P ->R).
Proof.
  intros P Q R [E1 E2]. 
Admitted.

This is where I get stuck.这就是我卡住的地方。 I can't destruct on propositions, and I although I can apply E2 in E1 , it generates two subgoals (I don't understand why), and the second subgoal is logically incorrect to prove.我不能破坏命题,虽然我可以apply E2 in E1 ,但它会生成两个子目标(我不明白为什么),第二个子目标在逻辑上不正确地证明。 Please help.请帮忙。 Also I know only the following tactics:另外我只知道以下策略:

simpl , reflexivity, symmetry, destruct, induction, apply, replace, .. in , exfalso, discriminate, injection, split, left , right, intros, unfold, assert, rewrite.简单、反身性、对称性、破坏、归纳、应用、替换、.. in、exfalso、歧视、注入、拆分、左、右、介绍、展开、断言、重写。

Q2: Another question on somewhat similar lines. Q2:关于有点相似的另一个问题。 I need to use the above proved lemma for proving other theorems.我需要使用上面证明的引理来证明其他定理。 So suppose I have two hypothesis H1: P -> Q and H2: Q -> R and the goal is P -> R .所以假设我有两个假设H1: P -> QH2: Q -> R并且目标是P -> R How can I use the above lemma to prove the goal in this case ie how can I combine H1 and H2 into a single hypothesis H : (P ->Q ) /\\ (Q -> R) ?在这种情况下,我如何使用上述引理来证明目标,即如何将H1H2组合成单个假设H : (P ->Q ) /\\ (Q -> R)

You're trying to prove the following:你试图证明以下几点:

Lemma if_trans :
  forall (P Q R : Prop),
    (P -> Q) /\ (Q -> R) -> (P -> R).

but you only introduce P, Q, R the proof of P -> Q and that of Q -> R so it leaves you to prove P -> R .但是你只介绍P, Q, R P -> Q的证明和Q -> R证明,所以它让你证明P -> R In the same way you can use intro p to get p : P as an extra assumption and then prove R .以同样的方式,您可以使用intro p得到p : P作为额外的假设,然后证明R

To summarise you have总结一下你有

P, Q, R : Prop
E1 : P -> Q
E2 : Q -> R
p : P
===============
R

after the tactic战术之后

intros P Q R [E1 E2] p.

(notice the extra p ). (注意额外的p )。

Perhaps then it will appear clearer how to prove it.也许到那时,如何证明它会显得更清楚。


When you use apply E2 in E1 it basically sees that E1 proves Q under the assumption that P holds, so it applies E2 : Q -> R in it to obtain R and asks on the side that you provide evidence for P .当您apply E2 in E1使用apply E2 in E1它基本上看到E1P成立的假设下证明Q ,因此它应用E2 : Q -> R在其中获得R并询问您是否为P提供证据。


For your second question, if you apply your lemma, it will ask for (P -> Q) /\\ (Q -> P) which you can prove with split and then assumption .对于你的第二个问题,如果你应用你的引理,它会要求(P -> Q) /\\ (Q -> P)你可以用split然后assumption来证明。 You should not try to combine P -> Q and Q -> R into (P -> Q) /\\ (Q -> P) though, but if really you must you can use pose proof (conj H1 H2) as H .您不应该尝试将P -> QQ -> R(P -> Q) /\\ (Q -> P) ,但如果真的必须,您可以使用pose proof (conj H1 H2) as H

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM