data ⊢_ : Expr → Set where A1 : ∀ A → ⊢ ((A ∨ A) -→ A) A2 : ∀ A B → ⊢ (A -→ (A ∨ B)) A3 : ∀ A B → ⊢ ((A ∨ B) -→ (B ∨ A)) A4 : ∀ A B C → ⊢ ((B -→ C) -→ ((A ∨ B) -→ (A ∨ C))) MP : ∀ {A B} → ⊢ A → ⊢ (A -→ B) → ⊢ B
诸定理的形式化验证
这里验证了三段论,自反律,排中律和结合律。
首先一开始我们并没有对格式做过多的思考,只是直接一行流。
1 2 3 4 5 6 7 8 9 10 11
Syl : ∀ (A B C : Expr) → ⊢ ((B -→ C) -→ ((A -→ B) -→ (A -→ C))) Syl A B C = A4 (¬ A) B C
Refl : ∀ (A : Expr) → ⊢ (A -→ A) Refl A = MP (A2 A A) (MP (A1 A) ((Syl A (A ∨ A) A)))
EM : ∀ (A : Expr) → ⊢ (A ∨ (¬ A)) EM A = MP (Refl A) (A3 (¬ A) A)
Assoc : ∀ (A B C : Expr) → ⊢ ((A ∨ (B ∨ C)) -→ ((A ∨ B) ∨ C)) Assoc A B C = MP (MP (MP (MP (MP (A3 B C) (MP (MP (MP (MP (A2 B A) (MP (A3 B A) (Syl B (B ∨ A) (A ∨ B)))) (A4 C B (A ∨ B))) (MP (A3 (C) (A ∨ B)) (Syl (C ∨ B) (C ∨ (A ∨ B)) ((A ∨ B) ∨ C)))) (Syl (B ∨ C) (C ∨ B) ((A ∨ B) ∨ C)))) (A4 A (B ∨ C) ((A ∨ B) ∨ C))) (MP (A3 A ((A ∨ B) ∨ C)) (Syl (A ∨ (B ∨ C)) (A ∨ ((A ∨ B) ∨ C)) (((A ∨ B) ∨ C) ∨ A)))) (MP (MP (MP (A2 A B) (MP (A2 (A ∨ B) C) (Syl A (A ∨ B) ((A ∨ B) ∨ C)))) (A4 ((A ∨ B) ∨ C) A ((A ∨ B) ∨ C))) (Syl (A ∨ (B ∨ C)) (((A ∨ B) ∨ C) ∨ A) (((A ∨ B) ∨ C) ∨ ((A ∨ B) ∨ C))))) (MP (A1 ((A ∨ B) ∨ C)) (Syl (A ∨ (B ∨ C)) (((A ∨ B) ∨ C) ∨ ((A ∨ B) ∨ C)) ((A ∨ B) ∨ C)))
Syl : ∀ (A B C : Expr) → ⊢ ((B -→ C) -→ ((A -→ B) -→ (A -→ C))) Syl A B C = T1 A B C where T1 : ∀ (A B C : Expr) → ⊢ ((B -→ C) -→ ((A -→ B) -→ (A -→ C))) T1 A B C = A4 (¬ A) B C
Refl : ∀ (A : Expr) → ⊢ (A -→ A) Refl A = T5 A where T1 : ∀ (A : Expr) → ⊢ (A -→ (A ∨ A)) T1 A = A2 A A
T2 : ∀ (A : Expr) → ⊢ ((A ∨ A) -→ A) T2 A = A1 A
T3 : ∀ (A : Expr) → ⊢ (((A ∨ A) -→ A) -→ ((A -→ (A ∨ A)) -→ (A -→ A))) T3 A = Syl A (A ∨ A) A
T4 : ∀ (A : Expr) → ⊢ ((A -→ (A ∨ A)) -→ (A -→ A)) T4 A = MP (T2 A) (T3 A)
T5 : ∀ (A : Expr) → ⊢ ((A -→ A)) T5 A = MP (T1 A) (T4 A)