How to prove Theorem euclid_gcd: forall a b z, euclid a b z -> gcd a b z. using Coq?

huangapple go评论57阅读模式
英文:

How to prove Theorem euclid_gcd : forall a b z, euclid a b z -> gcd a b z. using coq?

问题

我正在尝试证明欧几里德最大公约数定理,但我在归纳的第二种情况卡住了。大多数情况下,我遇到了无法统一的错误。
我会很高兴得到一些帮助,请看下面的代码:

Require Import Arith.Arith.
Import Nat.

Inductive gcd : nat -> nat -> nat -> Prop :=
  base   : forall z, gcd z z z
| step_a : forall a b z, gcd a b z -> gcd (a + b) b z
| step_b : forall a b z, gcd a b z -> gcd a (a + b) z.

Inductive euclid : nat -> nat -> nat -> Prop :=
  stop    : forall z, euclid z z z
| step_a' : forall a b z, a > b -> euclid (a - b) b z -> euclid a b z
| step_b' : forall a b z, a < b -> euclid a (b - a) z -> euclid a b z.

Search "+" "-".

Theorem euclid_gcd : forall a b z, euclid a b z -> gcd a b z.
Proof.
  intros a b z H.
  induction H.
   - apply base.
   - apply step_a' in H0.

希望这能帮助你解决问题。

英文:

I am trying to prove euclid_gcd Theorem but Im getting stuck at the second case of the induction. most of the time I'm getting unify errors.
I will be glad for some help please.

Require Import Arith.Arith.
Import Nat.


Inductive gcd : nat -&gt; nat -&gt; nat -&gt; Prop :=
  base   : forall z, gcd z z z
| step_a : forall a b z, gcd a b z -&gt; gcd (a + b) b z
| step_b : forall a b z, gcd a b z -&gt; gcd a (a + b) z.


Inductive euclid : nat -&gt; nat -&gt; nat -&gt; Prop :=
  stop    : forall z, euclid z z z
| step_a&#39; : forall a b z, a &gt; b -&gt; euclid (a - b) b z -&gt; euclid a b z
| step_b&#39; : forall a b z, a &lt; b -&gt; euclid a (b - a) z -&gt; euclid a b z.  


Search &quot;+&quot; &quot;-&quot;.


Theorem euclid_gcd : forall a b z, euclid a b z -&gt; gcd a b z.
Proof.
  intros a b z H.
  induction H.
   - apply base.
   - apply step_a&#39; in H0. 

答案1

得分: 2

你可以重新表述你的子目标 gcd a b z,以便应用 gcd 的某个构造函数。

英文:

You may rephrase your subgoal gcd a b z in order to apply some constructor of gcd.

Theorem euclid_gcd : forall a b z, euclid a b z -&gt; gcd a b z.
Proof.
  intros a b z H.
  induction H.
   - apply base.
   - replace a with ((a-b) + b). 
     (* ... *)
Qed.

huangapple
  • 本文由 发表于 2023年6月8日 23:19:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76433374.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定