Package parser-comb-thm: Properties of stream parser combinators
Information
name | parser-comb-thm |
version | 1.83 |
description | Properties of stream parser combinators |
author | Joe Leslie-Hurd <joe@gilith.com> |
license | MIT |
provenance | HOL Light theory extracted on 2012-11-10 |
requires | bool option pair parser-comb-def parser-stream |
show | Data.Bool Data.List Data.Option Data.Pair Parser Parser.Stream |
Files
- Package tarball parser-comb-thm-1.83.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))
⊦ ∀x s. parse parseAll (cons x s) = some (x, 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
- ⊥
- ⊤
- 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
- cons
- eof
- error
- isProperSuffix
- isSuffix
Assumptions
⊦ ⊤
⊦ parseAll = mkParser parseAll.pa
⊦ parseNone = mkParser parseNone.pn
⊦ ¬⊥ ⇔ ⊤
⊦ ¬⊤ ⇔ ⊥
⊦ ∀t. t ⇒ t
⊦ ∀x. isSuffix x x
⊦ ⊥ ⇔ ∀p. p
⊦ (¬) = λp. p ⇒ ⊥
⊦ ∀t. (∀x. t) ⇔ t
⊦ ∀t. (λx. t x) = t
⊦ (∀) = λp. p = λx. ⊤
⊦ ∀a'. ¬(none = some a')
⊦ ∀t. ¬¬t ⇔ t
⊦ ∀t. (⊤ ⇔ t) ⇔ t
⊦ ∀t. ⊥ ∧ t ⇔ ⊥
⊦ ∀t. ⊤ ∧ t ⇔ t
⊦ ∀t. t ∧ ⊤ ⇔ t
⊦ ∀t. ⊥ ⇒ t ⇔ ⊤
⊦ ∀t. ⊤ ⇒ t ⇔ 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. (⊥ ⇔ t) ⇔ ¬t
⊦ ∀t. t ⇒ ⊥ ⇔ ¬t
⊦ ∀f. parseOption f = partialMap f parseAll
⊦ ∀a s. parseNone.pn a s = none
⊦ (⇒) = λp q. p ∧ q ⇔ p
⊦ ∀t. (t ⇔ ⊤) ∨ (t ⇔ ⊥)
⊦ ∀t1 t2. (if ⊥ then t1 else t2) = t2
⊦ ∀t1 t2. (if ⊤ then t1 else t2) = t1
⊦ ∀b f. case b f none = b
⊦ ∀p x. p x ⇒ p ((select) p)
⊦ ∀xy. ∃x y. xy = (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 ⊤ ⊤
⊦ ∀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'
⊦ ∀f. ∃fn. ∀x y. fn (x, y) = f x y
⊦ ∀p a s. parse p (cons a s) = destParser p a s
⊦ ∀h t s. append (h :: t) s = cons 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 (cons a s') ⇔ s = s' ∨ isProperSuffix s s'
⊦ ∀x. x = error ∨ x = eof ∨ ∃a0 a1. x = cons a0 a1
⊦ ∀e b f a s. case e b f (cons 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'. cons a0 a1 = cons 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 → ⊤ | 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'')