Package parser-comb-def: Definition of stream parser combinators
Information
name | parser-comb-def |
version | 1.34 |
description | Definition of stream parser combinators |
author | Joe Hurd <joe@gilith.com> |
license | MIT |
provenance | HOL Light theory extracted on 2012-01-29 |
requires | bool option parser-stream |
show | Data.Bool Data.List Data.Option Data.Pair Parser Parser.Stream |
Files
- Package tarball parser-comb-def-1.34.tgz
- Theory file parser-comb-def.thy (included in the package tarball)
Defined Type Operator
- Parser
- parser
Defined Constants
- Parser
- destParser
- inverse
- isParser
- map
- mkParser
- parse
- parseAll
- parseAll.pa
- parseNone
- parseNone.pn
- parseOption
- parsePair
- parsePair.pbc
- parseSome
- partialMap
- partialMap.pf
- strongInverse
Theorems
⊦ parseAll = mkParser parseAll.pa
⊦ parseNone = mkParser parseNone.pn
⊦ ∀a. mkParser (destParser a) = a
⊦ ∀p. parse p eof = none
⊦ ∀p. parse p error = none
⊦ ∀f. parseOption f = partialMap f parseAll
⊦ ∀a s. parseNone.pn a s = none
⊦ ∀r. isParser r ⇔ destParser (mkParser r) = r
⊦ ∀a s. parseAll.pa a s = some (a, s)
⊦ ∀pb pc. parsePair pb pc = mkParser (parsePair.pbc pb pc)
⊦ ∀f p. partialMap f p = mkParser (partialMap.pf f p)
⊦ ∀p. parseSome p = parseOption (λa. if p a then some a else none)
⊦ ∀f p. map f p = partialMap (λb. some (f b)) p
⊦ ∀p a s. parse p (stream a s) = destParser p a s
⊦ ∀p e. inverse p e ⇔ ∀x s. parse p (append (e x) s) = some (x, s)
⊦ ∀p.
isParser p ⇔
∀x xs. case p x xs of none → T | some (y, xs') → isSuffix xs' xs
⊦ ∀p e.
strongInverse p e ⇔
inverse p e ∧ ∀s x s'. parse p s = some (x, s') ⇒ s = append (e x) s'
⊦ ∀f p a s.
partialMap.pf f p a s =
case destParser p a s of
none → none
| some (b, s') → case f b of none → none | some c → some (c, s')
⊦ ∀pb pc a s.
parsePair.pbc pb pc a s =
case destParser pb a s of
none → none
| some (b, s') →
case parse pc s' of
none → none
| some (c, s'') → some ((b, c), s'')
Input Type Operators
- →
- bool
- Data
- List
- list
- Option
- option
- Pair
- ×
- List
- Parser
- Stream
- stream
- Stream
Input Constants
- =
- select
- Data
- Bool
- ∀
- ∧
- ⇒
- ∃
- cond
- T
- Option
- case
- none
- some
- Pair
- ,
- Bool
- Parser
- Stream
- append
- eof
- error
- isSuffix
- stream
- Stream
Assumptions
⊦ T
⊦ (∃) = λp. p ((select) p)
⊦ ∀t. (∀x. t) ⇔ t
⊦ (∀) = λp. p = λx. T
⊦ (⇒) = λp q. p ∧ q ⇔ p
⊦ ∀b f. case b f none = b
⊦ (∧) = λp q. (λf. f p q) = λf. f T T
⊦ (∃) = λp. ∀q. (∀x. p x ⇒ q) ⇒ q
⊦ ∀p. (∀x. ∃y. p x y) ⇔ ∃y. ∀x. p x (y x)
⊦ ∀f0 f1 f2.
∃fn.
fn error = f0 ∧ fn eof = f1 ∧
∀a0 a1. fn (stream a0 a1) = f2 a0 a1 (fn a1)