【问题标题】:How to prove non-equality of terms produced by two different constructors of the same inductive in coq?如何证明coq中相同归纳的两个不同构造函数产生的项不相等?
【发布时间】:2020-03-10 11:31:55
【问题描述】:

假设我有一个归纳:

Inductive DirectSum{L R: Type}: Type := 
| Left: L -> DirectSum L R
| Right: R -> DirectSum L R
.

如何证明

forall L R: Type, forall l: L, forall r: R, Left L <> Right R. 

【问题讨论】:

    标签: coq


    【解决方案1】:

    easy 策略足以解决这个问题:

    Inductive DirectSum (L R: Type): Type :=
    | Left: L -> DirectSum L R
    | Right: R -> DirectSum L R
    .
    Arguments Left {_ _}.
    Arguments Right {_ _}.
    
    Goal forall L R: Type, forall l: L, forall r: R, Left l <> Right r.
    easy.
    Qed.
    

    这在内部起作用的原因是模式匹配。我们可以编写一个函数,在Left 上返回True,在Right 上返回False。如果条件相等,我们会得到True = False,这会产生矛盾。

    【讨论】:

      猜你喜欢
      • 2017-03-27
      • 1970-01-01
      • 2018-01-11
      • 1970-01-01
      • 1970-01-01
      • 2020-02-17
      • 2022-05-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多