Created
July 12, 2013 17:06
-
-
Save Fuuzetsu/5986039 to your computer and use it in GitHub Desktop.
equivalence proofs for header parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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