我注意到,这auto忽略了双条件。这是一个简化的示例:
Parameter A B : Prop.
Parameter A_iff_B : A <-> B.
Theorem foo1: A -> B.
Proof.
intros H. apply A_iff_B. assumption.
Qed.
Theorem bar1: B -> A.
Proof.
intros H. apply A_iff_B. assumption.
Qed.
Theorem foo2_failing: A -> B.
Proof.
intros H. auto using A_iff_B.
Abort.
Theorem bar2_failing: B -> A.
Proof.
intros H. auto using A_iff_B.
Abort.
Run Code Online (Sandbox Code Playgroud)
现在,我知道这A <-> B是一种语法糖,A -> B /\ B -> A所以我写了两个定理来提取一个或另一个:
Theorem iff_forward : forall {P Q : Prop},
(P <-> Q) -> P -> Q.
Proof.
intros P Q H. apply H.
Qed.
Theorem iff_backward : forall {P Q : Prop},
(P <-> Q) -> Q -> P.
Proof.
intros P Q H. apply H.
Qed.
Theorem foo3: A -> B.
Proof.
intros H.
auto using (iff_forward A_iff_B).
Qed.
Theorem bar3: B -> A.
Proof.
intros H.
auto using (iff_backward A_iff_B).
Qed.
Run Code Online (Sandbox Code Playgroud)
为什么apply A_iff_B行得通,auto using A_iff_B行不通?我认为这auto n是apply使用给定数据库中的假设和所有定理对长度 <= n的所有可能序列进行详尽搜索。
是否有使用双条件的标准技巧,或者这两个投影函数是通常的解决方案吗?
标准库中有这样的投影函数吗?我找不到他们。
- 怎么来了
apply A_iff_B works又auto using A_iff_B没有呢?
auto通常使用simple apply代替,apply并且这个受限版本apply不处理双条件。
- 是否有使用双条件的标准技巧,或者这两个投影函数是通常的解决方案?
您可以使用Hint Resolve -> (<-)以下功能:
Hint Resolve -> A_iff_B.
Hint Resolve <- A_iff_B. (* if you remove this one, then `auto` won't be able to prove the `bar3` theorem *)
Theorem foo3: A -> B.
Proof. info_auto. Qed. (* look at the output *)
Run Code Online (Sandbox Code Playgroud)
- 标准库中是否存在此类投影函数?
是的,它们被称为:proj1和proj2。您可以通过以下方式找到它们:
Search (?A /\ ?B -> ?A).
Run Code Online (Sandbox Code Playgroud)
或者更容易输入,但会发现比我们需要的更多的东西:
Search (_ /\ _ -> _).
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
113 次 |
| 最近记录: |