Package parser-comb-thm: Properties of stream parser combinators
Information
name | parser-comb-thm |
version | 1.32 |
description | Properties of stream parser combinators |
author | Joe Hurd <joe@gilith.com> |
license | MIT |
provenance | HOL Light theory extracted on 2011-11-29 |
requires | bool pair option parser-stream parser-comb-def |
show | Data.Bool Data.List Data.Option Data.Pair Parser Parser.Stream |
Files
- Package tarball parser-comb-thm-1.32.tgz
- Theory file parser-comb-thm.thy (included in the package tarball)
Theorems
⊦ isParser parseAll.pa
⊦ isParser parseNone.pn
⊦ destParser parseNone = parseNone.pn
⊦ ∀p. isParser (destParser p)
⊦ inverse parseAll (λa. a :: [])
⊦ strongInverse parseAll (λa. a :: [])
⊦ ∀s. parse parseNone s = none
⊦ ∀pb pc. isParser (parsePair.pbc pb pc)
⊦ ∀f p. isParser (partialMap.pf f p)
⊦ ∀pb pc. destParser (parsePair pb pc) = parsePair.pbc pb pc
⊦ ∀f p. destParser (partialMap f p) = partialMap.pf f p
⊦ parse parseAll = case none none (λa s. some (a, s))
⊦ ∀p.
parse (parseSome p) =
case none none (λa s. if p a then some (a, s) else none)
⊦ ∀f.
parse (parseOption f) =
case none none (λa s. case f a of none → none | some b → some (b, s))
⊦ ∀p a s. destParser (parseSome p) a s = if p a then some (a, s) else none
⊦ ∀f a s.
destParser (parseOption f) a s =
case f a of none → none | some b → some (b, s)
⊦ ∀f e. (∀b. f (e b) = some b) ⇒ inverse (parseOption f) (λb. e b :: [])
⊦ ∀p a s b s'. destParser p a s = some (b, s') ⇒ isSuffix s' s
⊦ ∀p s.
parse p s = none ∨
∃b s'. parse p s = some (b, s') ∧ isProperSuffix s' s
⊦ ∀f p g e.
inverse p e ∧ (∀b. f (g b) = b) ⇒ inverse (map f p) (λc. e (g c))
⊦ ∀f p g e.
inverse p e ∧ (∀b. f (g b) = some b) ⇒
inverse (partialMap f p) (λc. e (g c))
⊦ ∀p a s.
destParser p a s = none ∨
∃b s'. destParser p a s = some (b, s') ∧ isSuffix s' s
⊦ ∀p a s.
isParser p ⇒ p a s = none ∨ ∃b s'. p a s = some (b, s') ∧ isSuffix s' s
⊦ ∀f p s.
parse (map f p) s =
case parse p s of none → none | some (b, s') → some (f b, s')
⊦ ∀pb pc eb ec.
inverse pb eb ∧ inverse pc ec ⇒
inverse (parsePair pb pc) (λ(b, c). eb b @ ec c)
⊦ ∀pb pc eb ec.
strongInverse pb eb ∧ strongInverse pc ec ⇒
strongInverse (parsePair pb pc) (λ(b, c). eb b @ ec c)
⊦ ∀f p a s.
destParser (map f p) a s =
case destParser p a s of none → none | some (b, s') → some (f b, s')
⊦ ∀f p s.
parse (partialMap f p) s =
case parse p s of
none → none
| some (b, s') → case f b of none → none | some c → some (c, s')
⊦ ∀f e.
(∀b. f (e b) = some b) ∧
(∀a1 a2 b. f a1 = some b ∧ f a2 = some b ⇒ a1 = a2) ⇒
strongInverse (parseOption f) (λb. e b :: [])
⊦ ∀f p g e.
strongInverse p e ∧ (∀b. f (g b) = b) ∧
(∀b1 b2 c. f b1 = c ∧ f b2 = c ⇒ b1 = b2) ⇒
strongInverse (map f p) (λc. e (g c))
⊦ ∀pb pc s.
parse (parsePair pb pc) s =
case parse pb s of
none → none
| some (b, s') →
case parse pc s' of
none → none
| some (c, s'') → some ((b, c), s'')
⊦ ∀f p g e.
strongInverse p e ∧ (∀b. f (g b) = some b) ∧
(∀b1 b2 c. f b1 = some c ∧ f b2 = some c ⇒ b1 = b2) ⇒
strongInverse (partialMap f p) (λc. e (g c))
Input Type Operators
- →
- bool
- Data
- List
- list
- Option
- option
- Pair
- ×
- List
- Parser
- parser
- Stream
- stream
Input Constants
- =
- select
- Data
- Bool
- ∀
- ∧
- ⇒
- ∃
- ∨
- ¬
- cond
- F
- T
- List
- ::
- @
- []
- Option
- case
- none
- some
- Pair
- ,
- Bool
- Parser
- destParser
- inverse
- isParser
- map
- mkParser
- parse
- parseAll
- parseAll.pa
- parseNone
- parseNone.pn
- parseOption
- parsePair
- parsePair.pbc
- parseSome
- partialMap
- partialMap.pf
- strongInverse
- Stream
- append
- case
- eof
- error
- isProperSuffix
- isSuffix
- stream
Assumptions
⊦ T
⊦ parseAll = mkParser parseAll.pa
⊦ parseNone = mkParser parseNone.pn
⊦ ¬F ⇔ T
⊦ ¬T ⇔ F
⊦ ∀t. t ⇒ t
⊦ ∀x. isSuffix x x
⊦ F ⇔ ∀p. p
⊦ (¬) = λp. p ⇒ F
⊦ ∀t. (∀x. t) ⇔ t
⊦ ∀t. (λx. t x) = t
⊦ (∀) = λp. p = λx. T
⊦ ∀a'. ¬(none = some a')
⊦ ∀t. ¬¬t ⇔ t
⊦ ∀t. (T ⇔ t) ⇔ t
⊦ ∀t. F ∧ t ⇔ F
⊦ ∀t. T ∧ t ⇔ t
⊦ ∀t. t ∧ T ⇔ t
⊦ ∀t. F ⇒ t ⇔ T
⊦ ∀t. T ⇒ t ⇔ t
⊦ ∀t. t ⇒ T ⇔ T
⊦ ∀t. F ∨ t ⇔ t
⊦ ∀t. T ∨ t ⇔ T
⊦ ∀t. t ∨ T ⇔ T
⊦ ∀s. append [] s = s
⊦ ∀a. mkParser (destParser a) = a
⊦ ∀p. parse p eof = none
⊦ ∀p. parse p error = none
⊦ ∀t. (F ⇔ t) ⇔ ¬t
⊦ ∀t. t ⇒ F ⇔ ¬t
⊦ ∀f. parseOption f = partialMap f parseAll
⊦ ∀a s. parseNone.pn a s = none
⊦ (⇒) = λp q. p ∧ q ⇔ p
⊦ ∀t. (t ⇔ T) ∨ (t ⇔ F)
⊦ ∀t1 t2. (if F then t1 else t2) = t2
⊦ ∀t1 t2. (if T then t1 else t2) = t1
⊦ ∀b f. case b f none = b
⊦ ∀p x. p x ⇒ p ((select) p)
⊦ ∀p. ∃x y. p = (x, y)
⊦ ∀r. isParser r ⇔ destParser (mkParser r) = r
⊦ ∀x y. x = y ⇔ y = x
⊦ ∀t1 t2. t1 ∨ t2 ⇔ t2 ∨ t1
⊦ ∀x y. isProperSuffix x y ⇒ isSuffix x y
⊦ ∀a s. parseAll.pa a s = some (a, s)
⊦ ∀x. x = none ∨ ∃a. x = some a
⊦ ∀pb pc. parsePair pb pc = mkParser (parsePair.pbc pb pc)
⊦ ∀f p. partialMap f p = mkParser (partialMap.pf f p)
⊦ (∧) = λp q. (λf. f p q) = λf. f T T
⊦ ∀e b f. case e b f eof = b
⊦ ∀e b f. case e b f error = e
⊦ (∃) = λP. ∀q. (∀x. P x ⇒ q) ⇒ q
⊦ ∀a a'. some a = some a' ⇔ a = a'
⊦ ∀p. parseSome p = parseOption (λa. if p a then some a else none)
⊦ ∀b f a. case b f (some a) = f a
⊦ ∀f p. map f p = partialMap (λb. some (f b)) p
⊦ ∀f g. (∀x. f x = g x) ⇔ f = g
⊦ (∨) = λp q. ∀r. (p ⇒ r) ⇒ (q ⇒ r) ⇒ r
⊦ ∀s s'. isSuffix s s' ⇔ s = s' ∨ isProperSuffix s s'
⊦ ∀PAIR'. ∃fn. ∀a0 a1. fn (a0, a1) = PAIR' a0 a1
⊦ ∀p a s. parse p (stream a s) = destParser p a s
⊦ ∀h t s. append (h :: t) s = stream h (append t s)
⊦ ∀t1 t2 t3. (t1 ∨ t2) ∨ t3 ⇔ t1 ∨ t2 ∨ t3
⊦ ∀x y z. append (x @ y) z = append x (append y z)
⊦ ∀x y z. isSuffix x y ∧ isSuffix y z ⇒ isSuffix x z
⊦ ∀s a s'. isProperSuffix s (stream a s') ⇔ s = s' ∨ isProperSuffix s s'
⊦ ∀x. x = error ∨ x = eof ∨ ∃a0 a1. x = stream a0 a1
⊦ ∀e b f a s. case e b f (stream a s) = f a s
⊦ ∀P Q. (∀x. P x ∧ Q x) ⇔ (∀x. P x) ∧ ∀x. Q x
⊦ ∀x y a b. (x, y) = (a, b) ⇔ x = a ∧ y = b
⊦ ∀a0 a1 a0' a1'. stream a0 a1 = stream a0' a1' ⇔ a0 = a0' ∧ a1 = a1'
⊦ ∀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'')