什么时候会终止?

时间:2015-06-22 08:54:50

标签: agda

我实际上想要证明一个定理,但我认为如果我在另一方面证明那也没关系。

我已经定义了一系列正面理性:

one : ℤ
one = + 1

next : pair → pair
next q = if (n eq one) then (mkPair (+ m Data.Integer.+ one) 1)
         else (mkPair (n Data.Integer.- one) (m Nat.+ 1))
  where
     n = getX q
     m = getY q

-- eq is defined correctly for equivalence of two integer. 
rational : Stream pair
rational = iterate next (mkPair one 1) 

RQ : pair → Stream pair → Stream pair
RQ q (x ∷ xs) = (x add q) ∷ ♯ (RQ q (♭ xs))    

positiveRat : Stream pair
positiveRat = RQ (mkPair (+ 0) (1)) rational 

此处pair是包含ℤ和ℕ字段的记录:

 --records of rational number
record pair : Set where
  field
    x : ℤ
    y : ℕ

mkPair : ℤ → ℕ → pair
mkPair a b = record { x = a; y = b}

现在我要证明 positiveRat中的每一个理性都是正面的

open import Data.Stream
open import Data.Nat
open import Data.Rational
open import Data.Integer
open import Coinduction
open import Data.Unit

lemma : (x : pair) → (x ∈ positiveRat) → (+ 0 Data.Integer.≤ pair.x x)
lemma .(record { x = + 1 ; y = 1 }) here = +≤+ z≤n
lemma .(record { x = + 2 ; y = 1 }) (there here) = +≤+ z≤n
lemma .(record { x = + 1 ; y = 2 }) (there (there here)) = {!!}
lemma q (there (there (there pf))) = {!!}

我正在通过分割pf来编写证据。但这是不可阻挡的。

1 个答案:

答案 0 :(得分:1)

这个模拟示例很容易解决,因为stream是周期性的:

lemma : (x : ℚ) → (x ∈ stream) → (+ 0 Data.Integer.≤ ℚ.numerator x)
lemma .(record { numerator = + 1}) here = +≤+ z≤n
lemma .(record { numerator = + 2}) (there here) = +≤+ z≤n
lemma .(record { numerator = + 3}) (there (there here)) = +≤+ z≤n
lemma q (there (there (there pf))) = lemma q pf

但是,我想在你的真实例子中,stream不是周期性的。没有通用的答案; lemma的正确证明取决于您的真实stream的定义方式,因此您必须发布该@Html.TextBoxFor(x => x.zip, new { placeholder = "Enter your zip", @class = "gsTextBox", @Value = (Model.zip > 0 ? Model.zip.ToString() : string.Empty) })