代码之家  ›  专栏  ›  技术社区  ›  Greg Nisbet

COQ证明了涉及实数字面值的算术表达式是相等的

coq
  •  1
  • Greg Nisbet  · 技术社区  · 7 年前

    我有一个非常基本的表达式,涉及实数字面值和 + 也就是说, 4 = 1 + 1 + 1 + 1 .

    我正在设法用尽可能少的聪明来证明这个事实。

    Require Export RIneq. (* probably overkill, but it pulls in
                             enough real number stuff to be useful *)
    
    Open Scope R_scope.
    
    Lemma test_sum2 : 4 = 1 + 1 + 1 + 1.
    

    我试图通过使用战略选择的断言和垃圾邮件来证明这一点。 intuition 但是我似乎不能在上面建立积分实域 3 使用这种技术。

    Require Export RIneq.
    
    Open Scope R_scope.
    
    Lemma test_sum2 : 4 = 1 + 1 + 1 + 1.
    Proof.
    assert (1 + 1 = 2).
    intuition.
    rewrite H.
    assert (1 + 2 = 3).
    intuition.
    assert (1 + 2 = 2 + 1).
    intuition.
    rewrite H1 in H0.
    rewrite H0.
    assert (1 + 3 = 3 + 1).
    intuition.
    

    使我处于证明状态

    1 subgoal
    H : 1 + 1 = 2
    H0 : 2 + 1 = 3
    H1 : 1 + 2 = 2 + 1
    H2 : 1 + 3 = 3 + 1
    ______________________________________(1/1)
    4 = 3 + 1
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   SCappella    7 年前

    基于 this 答案,看起来像 field 战术会奏效的。我不确定那是否太聪明了。

    Require Export RIneq.
    
    Open Scope R_scope.
    
    Lemma test_sum2 : 4 = 1 + 1 + 1 + 1.
    Proof.
      field.
    Qed.
    

    (在coq 8.9+beta1中测试)