【发布时间】:2015-05-08 07:57:50
【问题描述】:
我无法清楚地理解它。我试图学习“with”关键字,但我也有疑问。请帮忙 !!!
我想了解“with”的工作原理和这段代码的工作原理。
something-even : ∀ n → Even n ⊎ Even (suc n)
something-even zero = inj₁ zero
something-even (suc n) with something-even n
... | inj₁ x = inj₂ (suc-suc x)
... | inj₂ y = inj₁ y
(this states that either n is even or its successor is even). In fact, thm0 can be implemented without using recursion!
thm0 : ∀ x → ∃ λ y → Even y × x less-than y
thm0 n with something-even n
... | inj₁ x = suc (suc n) , suc-suc x , suc ref
... | inj₂ y = suc n , y , ref
【问题讨论】:
标签: agda