|
| 1 | +InferAgda |
| 2 | +========= |
| 3 | +Agdaによる'正当性が保証された'型推論器です。 |
| 4 | +型推論のアルゴリズムとしてW-アルゴリズムを採用しています。 |
| 5 | + |
| 6 | +Agdaのインストール・セットアップ方法 |
| 7 | +------ |
| 8 | + |
| 9 | +##1. cabal から Agda をインストール ## |
| 10 | + |
| 11 | +``` |
| 12 | +$ cabal install agda |
| 13 | +$ agda-mode setup |
| 14 | +``` |
| 15 | +##2. agda-wiki から standard library をダウンロードする## |
| 16 | + |
| 17 | +http://wiki.portal.chalmers.se/agda/pmwiki.php |
| 18 | + |
| 19 | +##3. ダウンロードした standard library を aquamacsにセット## |
| 20 | + |
| 21 | ++ open emacs |
| 22 | ++ `M-x load-library agda2-mode` |
| 23 | ++ `M-x customize-group agda2` |
| 24 | ++ specify "Agda include dirs" e.g. `/users/kyoko/agda-stdlib/src` |
| 25 | ++ select `Save for Future Sessions` |
| 26 | + |
| 27 | +you can compile and load agda file with `C-c C-l`. |
| 28 | + |
| 29 | + |
| 30 | +このソースコードの構造 |
| 31 | +----- |
| 32 | + |
| 33 | +このソースコードは、`infer.agda`、`term.agda`、`mgu.agda`の三つから構成されています。 |
| 34 | +それぞれの役割は以下のとおりです。 |
| 35 | + |
| 36 | +## infer.agda |
| 37 | + |
| 38 | +## term.agda |
| 39 | + |
| 40 | +このモジュールでは、型推論を行う well-scoped な term と well-typed な term を定義しています。 |
| 41 | + |
| 42 | +### well-scoped term |
| 43 | + |
| 44 | +the word 'well-scoped' implies all terms have a parameter `n` that counts |
| 45 | +free variables with type level.(a simple example of dependant types) |
| 46 | + |
| 47 | +#### definition |
| 48 | + |
| 49 | +WellScopedTerm n := |
| 50 | + Var : Fin n → WellScopedTerm n |
| 51 | + Lam : (s : WellScopedTerm (suc n)) WellScopedTerm n |
| 52 | + App : (s1 : WellScopedTerm n) (s2 : WellScopedTerm n) WellScopedTerm n |
| 53 | + Fst : WellScopedTerm n WellScopedTerm n |
| 54 | + Snd : WellScopedTerm n WellScopedTerm n |
| 55 | + Cons : WellScopedTerm n WellScopedTerm n WellScopedTerm nm (suc n)) → WellScopedTerm n |
| 56 | + App : (s1 : WellScopedTerm n) → (s2 : WellScopedTerm n) → WellScopedTerm n |
| 57 | + Fst : WellScopedTerm n → WellScopedTerm n |
| 58 | + Snd : WellScopedTerm n → WellScopedTerm n |
| 59 | + Cons : WellScopedTerm n → WellScopedTerm n → WellScopedTerm n |
| 60 | + |
| 61 | +note: the type `Fin n` explains 'finite set', has a finite set of 0 ~ n-1. |
| 62 | + |
| 63 | + |
| 64 | +### well-typed term |
| 65 | + |
| 66 | +this term has two parameters with type level, type context and type. |
| 67 | +so, this term is certified that has correct type `t` with the context `Γ `. |
| 68 | + |
| 69 | +#### definition |
| 70 | + |
| 71 | +WellTypedTerm (Γ : Cxt n) (t : Type m) := |
| 72 | + Var : (x : Fin n) → WellTypedTerm Γ (lookup x Γ) |
| 73 | + Lam : (t : Type m) → {t' : Type m} → WellTypedTerm (t ∷ Γ) t' → |
| 74 | + WellTypedTerm Γ (t ⇒ t') |
| 75 | + App : {t t' : Type m} → WellTypedTerm Γ (t ⇒ t') → WellTypedTerm Γ t → |
| 76 | + WellTypedTerm Γ t' |
| 77 | + Fst : {t1 t2 : Type m} → WellTypedTerm Γ (t1 ∏ t2) → WellTypedTerm Γ t1 |
| 78 | + Snd : {t1 t2 : Type m} → WellTypedTerm Γ (t1 ∏ t2) → WellTypedTerm Γ t2 |
| 79 | + Cons : {t1 t2 : Type m} → WellTypedTerm Γ t1 → WellTypedTerm Γ t2 → WellTypedTerm Γ (t1 ∏ t2) |
| 80 | + |
| 81 | +the type `Type` is discribed in the module mgu. |
| 82 | + |
| 83 | +## mgu.agda |
| 84 | + |
| 85 | + |
| 86 | +型推論とその定式化の仕組み |
| 87 | +----- |
| 88 | + |
| 89 | + |
| 90 | +License |
| 91 | +----- |
| 92 | +MIT |
0 commit comments