Coq:如何在内部“ if”分支中应用假设

时间:2019-03-13 00:25:14

标签: coq

我需要应用FixL_Accumulate来证明目标,但是由于let语句和内部的“ if-then-else”,统一失败。问题是如何在这里匹配形状?

Require Import ZArith.

Inductive branch (A B C : Prop) : Prop :=
  | Then: A -> B -> branch A B C
  | Else: not A -> C -> branch A B C
.

Definition itep (A B C : Prop) := (A -> B) /\ (~A -> C).
Axiom ite_then : forall A B C : Prop, itep A B C -> A -> B.
Axiom ite_else : forall A B C : Prop, itep A B C -> ~A -> C.
Axiom ite_both : forall A B C : Prop, itep A B C -> (B \/ C).
Axiom contrap: forall P Q : Prop, (P -> Q) -> ~Q -> ~P.

Parameter L_Accumulate : Z -> Z -> Z.
Hypothesis FixL_Accumulate: forall (n c: Z),
  let x := ((L_Accumulate n c))%Z in
  let x_1 := (n - 1%Z)%Z in itep ((n <= 0)%Z) ((x = c)%Z)
  (((n + ((L_Accumulate x_1 c%Z))) = x)%Z).

Goal
  forall (i c : Z),
  (i > 0)%Z ->
  ((((L_Accumulate i%Z c%Z)) = ((i + ((L_Accumulate (i - 1%Z)%Z c%Z))))%Z)).
Proof.
intros.
(* something like: apply (@FixL_Accumulate i c). *)
Qed.

1 个答案:

答案 0 :(得分:1)

我找到了解决方案。问题是因为对称。因此,这个问题是不正确的。

Proof.
  intros.
  symmetry.
  apply (@FixL_Accumulate i c).
  intuition.
Qed.