如何用Coq中的参数表示选择条件

如何用Coq中的参数表示选择条件,coq,Coq,我有以下代码: Definition trans := nat -> nat -> Prop. Definition ifelse (b : nat -> nat -> bool) (P Q : trans) : trans := fun s1 s2 => if b s1 s2 then P s1 s2 else Q s1 s2. ifelse表示如果布尔条件为真,则选择命题p s1 s2,否则建立命题Q s1 s2。布尔条件还取决于参数s1和s2 我想证明

我有以下代码:

Definition trans := nat -> nat -> Prop.

Definition ifelse (b : nat -> nat -> bool) (P Q : trans) : trans :=
  fun s1 s2 => if b s1 s2 then P s1 s2 else Q s1 s2.
ifelse表示如果布尔条件为真,则选择命题p s1 s2,否则建立命题Q s1 s2。布尔条件还取决于参数s1和s2

我想证明传统的定理

如果b那么p ELSE Q=如果不是b那么Q ELSE p


谁能给我一些介绍这个定理的方法吗?

事实上,
b
p
Q
在代码中取参数并不太重要。您可以使用以下结果:

Lemma if_swap T (b : bool) (x y : T) :
  (if b then x else y) = if negb b then y else x.
Proof. now destruct b. Qed.