XOO’s

Entries tagged as ‘Agda’

Congruence Rule with Heterogeneous Equality in Agda

六月 3, 2009 · Leave a Comment

Congruence rule plays an important role in reasoning in Agda, and things become mystery as working under heterogeneous equality. In the standard library of Agda2, the type of Relation.Binary.HeterogeneousEquality.cong is

∀{a b} (f : a → b) {i : a} {j : a} → i ≅ j → f i ≅ f j

Since i and j are the same type, the equality between i and j becomes propositional instead of heterogeneous. (更多…)

類別: 閒聊
Tagged: ,

View for (mod n)

四月 4, 2009 · Leave a Comment

延續上一個 Bound View, 稍微修改之後, 再配合 \mathbb{Z}_n 結構, 可以得到一個對 \mathbb{N} 的模數 n 的 view。首先修改 Bound 為

data Bound (k : ℕ) : ℕ → Set where
below : (n : ℕ) → (l : ℕ) → (l+n=k : l + (suc n) ≡ k)
    → Bound k n
above : (n : ℕ) → (l : ℕ) → (l+k=n : l + k ≡ n) → Bound k n

亦即將 below 的條件改為 n < k,而 above 則是 n \geq k。toBound 根據此稍作修改。接下來是 \mathbb{Z}_n 的結構定義,因為要作成 \mathbb{N} 的 view,index 上放入自然數。

data Z (k : ℕ) : ℕ → Set where
 cl : (m : ℕ){m<k : (suc m) ≤ k} (n : ℕ) → Z k (m + (n * k))

接下來就是將自然數轉成 \mathbb{Z}_n(更多…)

類別: Computer Science
Tagged: ,

Data.Vec.Equality …

二月 7, 2009 · Leave a Comment

後來還是把改過的東西丟上去了 …現在 Vec 也有 decidable equality 可以用, 加上最近 Agda 上把 DecSetoid 都補上去, 大部分內建的 data structure 都能夠拿來比較相等了?連整數也有大小比較 ..

最近試著從 commutative monoid 構造 abelian group, …

類別: 閒聊
Tagged:

快瘋了

二月 3, 2009 · Leave a Comment

想證明 pop 跟 push 對於 queue 的操作而言, 會保持等式, 也就是 qs_{1} =_{Q} qs_{2} (即 fs_{1} + rs_{1}^{r} = fs_{2} + rs_{2}^{r}), 而對於同樣的 queue, pop 跟 push 必須產生同樣的結果, 而不管用什麼樣的表示。

但光是把 case split 出來, 就一堆東西了, 到底要怎麼寫啊, 不是這樣的吧 囧

(更多…)

類別: Programming · 閒聊
Tagged:

Decidable setoid in Agda

一月 24, 2009 · Leave a Comment

If you have known setoid in Agda, the decidable setoid may be quite easy to understand. We first explain (I hope so …) what is decidable relation. A decidable relation is defined as follows in Agda, (更多…)

類別: Computer Science
Tagged:

Setoids in Agda

一月 18, 2009 · 3個回應

Setoid is a record type in Agda, and it appears everywhere from Relation.Binary.EqReasoning to Algebra. But, why do we need such a type ? After reading “setoids in type theory”, I thought that setoids are used for mathematical constructions like subset, quotients in the intensional type theory and the Calculus of Inductive Construction. Since some of functional data structure could be represented as such constructions, it also may be useful for functional programming, at least for understanding it. (更多…)

類別: Computer Science
Tagged: