# HG changeset patch # User Yasutaka Higa # Date 1412645937 -32400 # Node ID a5aadebc084d05e7bd11b00610c57799a316ca5e # Parent ae41becf41db4c9b2e0ff6a9b695de694092ed59 Define List in Agda diff -r ae41becf41db -r a5aadebc084d agda/list.agda --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agda/list.agda Tue Oct 07 10:38:57 2014 +0900 @@ -0,0 +1,24 @@ +module list where + +open import Relation.Binary.PropositionalEquality +open ≡-Reasoning + +infixr 40 _::_ +data List (A : Set) : Set where + [] : List A + _::_ : A -> List A -> List A + + +infixl 30 _++_ +_++_ : {A : Set} -> List A -> List A -> List A +[] ++ ys = ys +(x :: xs) ++ ys = x :: (xs ++ ys) + + +empty-append : {A : Set} -> (xs : List A) -> xs ++ [] ≡ [] ++ xs +empty-append [] = refl +empty-append (x :: xs) = begin + x :: (xs ++ []) + ≡⟨ cong (_::_ x) (empty-append xs) ⟩ + x :: xs + ∎ \ No newline at end of file