Skip to content

Instantly share code, notes, and snippets.

@Fuuzetsu
Created July 12, 2013 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fuuzetsu/5986039 to your computer and use it in GitHub Desktop.
Save Fuuzetsu/5986039 to your computer and use it in GitHub Desktop.
equivalence proofs for header parser
module break2 where
open import Function using (id)
open import Data.Bool using (Bool; true; false)
open import Data.Char using (Char)
open import Data.List using (List; []; _∷_; span)
open import Data.Product as P using (_×_; _,_; map)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong)
open import Data.Char.Classifier
extract-leading-spaces : List Char → List Char × List Char
extract-leading-spaces [] = [] , []
extract-leading-spaces (c ∷ cs) with isSpace c
... | true = P.map (_∷_ c) id (extract-leading-spaces cs)
... | false = [] , c ∷ cs
els : List Char → List Char × List Char
els = span isSpace
proof : (xs : List Char) → els xs ≡ extract-leading-spaces xs
proof [] = refl
proof (c ∷ cs) with isSpace c
... | true = cong (P.map (_∷_ c) id) (proof cs)
... | false = refl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment