Coq 证明加法不等式

Coq proving addition inequality

我是初学者,正在尝试证明这个引理:

Lemma test:  forall n m p q : nat,
    n <= p \/ m <= q -> n + m <= p + q.

我试过了

From Coq Require Export Lia.

Lemma test:  forall n m p q : nat,
        n <= p \/ m <= q -> n + m <= p + q
Proof.
    intros; omega.

Lia,但它不起作用。我该如何继续?

你的意思可能是

Lemma test:  forall n m p q : nat,
    n <= p /\ m <= q -> n + m <= p + q.

with /\ (逻辑与)而不是 \/ (逻辑或)因为你的定理不成立。作为反例,选择 n = p = q = 0 和 m = 1.

以这种方式修复后,lia 会自动找到证据。

此外,请注意,在 Coq 中更习惯于柯化类型,即将箭头左侧的连词替换为箭头。这将是

Lemma test:  forall n m p q : nat,
    n <= p -> m <= q -> n + m <= p + q.

这是等价的。

谢谢你的回答。然而,

Proof.
  intros. lia.

给出:

Error: Tactic failure:  Cannot find witness.

有办法继续吗?