[英]How can I proove 0 <= a < b -> rem a b = a in Coq?
I'm trying to prove this lemma我试图证明这个引理
Require Import ZArith.
Require Import Lia.
Open Scope Z_scope.
Import Z.
Ltac Zify.zify_post_hook ::= Z.to_euclidean_division_equations.
Lemma rem_pos : forall {a b : Z},
0 <= a < b ->
rem a b = a.
intros. lia.
At this point I receive Tactic failure: Cannot find witness.
此时我收到
Tactic failure: Cannot find witness.
from lia
.来自
lia
。
Am I doing something wrong?难道我做错了什么?
Search is your friend:搜索是你的朋友:
Require Import ZArith.
Open Scope Z_scope.
Import Z.
Lemma rem_pos : forall {a b : Z},
0 <= a < b ->
rem a b = a.
Proof.
intros a b H.
Search (rem ?a ?b = ?a).
apply rem_small.
assumption.
Qed.
Afaik there is no dedicated proof automation for modulo arithmetic. Afaik 没有用于模运算的专用证明自动化。 Coq-hammer is able to solve it with e-prover and Z3 backends (coming soon in Coq Platform):
Coq-hammer 能够通过 e-prover 和 Z3 后端解决这个问题(即将在 Coq 平台中推出):
Require Import ZArith.
From Hammer Require Import Hammer.
Open Scope Z_scope.
Import Z.
Lemma rem_pos : forall {a b : Z},
0 <= a < b ->
rem a b = a.
Proof.
hammer.
Qed.
But this is trivial for an ATP, so not a reasonable test.但这对于 ATP 来说是微不足道的,因此不是一个合理的测试。 The problem is that one can't easily combine ATPs with the power of lia.
问题是不能轻易地将 ATP 与 lia 的力量结合起来。
In my experience your best bet is Search
an adequate lemma and solve the preconditions with lia.根据我的经验,你最好的选择是
Search
一个足够的引理并用 lia 解决先决条件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.