Package parser-stream: Basic theory of parse streams

Information

nameparser-stream
version1.5
descriptionBasic theory of parse streams
authorJoe Hurd <joe@gilith.com>
licenseMIT
show Data.Bool
Data.List
Data.Option
Data.Pair
Parser.Stream
Relation

Files

Defined Type Operator

Defined Constants

Theorems

wellFounded isProperSuffix

x. isSuffix x x

x. ¬isProperSuffix x x

l. fromList l = append l eof

l. length (fromList l) = length l

l. toList (fromList l) = some l

x y. isProperSuffix x y isSuffix x y

s. case T (λl. length l = length s) (toList s)

x y. isProperSuffix x y Number.Natural.< (length x) (length y)

x y. isSuffix x y Number.Natural.≤ (length x) (length y)

l s. length (append l s) = Number.Natural.+ (length l) (length s)

s s'. isSuffix s s' s = s' isProperSuffix s s'

x y z. append (x @ y) z = append x (append y z)

x y z. isProperSuffix x y isProperSuffix y z isProperSuffix x z

x y z. isSuffix x y isSuffix y z isSuffix x z

l s. toList (append l s) = case none (λls. some (l @ ls)) (toList s)

x. x = error x = eof a0 a1. x = stream a0 a1

p. (x. (y. isProperSuffix y x p y) p x) x. p x

a0 a1 a0' a1'. stream a0 a1 = stream a0' a1' a0 = a0' a1 = a1'

length error = Number.Numeral.zero length eof = Number.Numeral.zero
  a s. length (stream a s) = Number.Natural.suc (length s)

P. P error P eof (a0 a1. P a1 P (stream a0 a1)) x. P x

(s. append [] s = s) h t s. append (h :: t) s = stream h (append t s)

¬(error = eof) (a0' a1'. ¬(error = stream a0' a1'))
  a0' a1'. ¬(eof = stream a0' a1')

toList error = none toList eof = some []
  a s. toList (stream a s) = case none (λl. some (a :: l)) (toList s)

f0 f1 f2.
    fn.
      fn error = f0 fn eof = f1
      a0 a1. fn (stream a0 a1) = f2 a0 a1 (fn a1)

(s. isProperSuffix s error F) (s. isProperSuffix s eof F)
  s a s'. isProperSuffix s (stream a s') s = s' isProperSuffix s s'

h.
    (f g s. (s'. isProperSuffix s' s f s' = g s') h f s = h g s)
    f. s. f s = h f s

(e b f. case e b f error = e) (e b f. case e b f eof = b)
  e b f a s. case e b f (stream a s) = f a s

Input Type Operators

Input Constants

Assumptions

T

n. Number.Natural.≤ Number.Numeral.zero n

n. Number.Natural.≤ n n

m. wellFounded (measure m)

F p. p

(¬) = λp. p F

() = λP. P ((select) P)

a. ∃!x. x = a

t. (x. t) t

t. (x. t) t

t. (λx. t x) = t

() = λP. P = λx. T

x. x = x T

n. ¬(Number.Natural.suc n = Number.Numeral.zero)

m. Number.Natural.+ m Number.Numeral.zero = m

n.
    Number.Natural.even
      (Number.Natural.*
         (Number.Numeral.bit0 (Number.Numeral.bit1 Number.Numeral.zero)) n)

n. Number.Numeral.bit0 n = Number.Natural.+ n n

x. case none some x = x

() = λp q. p q p

t. (t T) (t F)

n. Number.Numeral.bit1 n = Number.Natural.suc (Number.Natural.+ n n)

(¬T F) (¬F T)

t1 t2. t1 t2 t2 t1

m n. Number.Natural.< m n Number.Natural.≤ m n

<< x. wellFounded << ¬<< x x

n.
    Number.Natural.*
      (Number.Numeral.bit0 (Number.Numeral.bit1 Number.Numeral.zero)) n =
    Number.Natural.+ n n

m. measure m = λx y. Number.Natural.< (m x) (m y)

m n. ¬(Number.Natural.< m n Number.Natural.≤ n m)

m n. ¬(Number.Natural.≤ m n Number.Natural.< n m)

m n. Number.Natural.< m (Number.Natural.suc n) Number.Natural.≤ m n

m n. Number.Natural.≤ (Number.Natural.suc m) n Number.Natural.< m n

x. x = none a. x = some a

() = λp q. (λf. f p q) = λf. f T T

() = λP. q. (x. P x q) q

m n. Number.Natural.suc m = Number.Natural.suc n m = n

m n.
    Number.Natural.even (Number.Natural.* m n)
    Number.Natural.even m Number.Natural.even n

m n.
    Number.Natural.even (Number.Natural.+ m n) Number.Natural.even m
    Number.Natural.even n

f g. f = g x. f x = g x

P a. (x. a = x P x) P a

() = λp q. r. (p r) (q r) r

(Number.Natural.even Number.Numeral.zero T)
  n. Number.Natural.even (Number.Natural.suc n) ¬Number.Natural.even n

m n. Number.Natural.≤ m n Number.Natural.< m n m = n

m n. Number.Natural.≤ m n Number.Natural.≤ n m m = n

P Q. (x. P Q x) P x. Q x

t1 t2 t3. t1 t2 t3 (t1 t2) t3

t1 t2 t3. t1 t2 t3 (t1 t2) t3

m n p.
    Number.Natural.* m (Number.Natural.* n p) =
    Number.Natural.* (Number.Natural.* m n) p

m n p. Number.Natural.+ m p = Number.Natural.+ n p m = n

P x. (y. P y y = x) (select) P = x

P. (x. y. P x y) y. x. P x (y x)

t1 t2. (if T then t1 else t2) = t1 (if F then t1 else t2) = t2

m n.
    Number.Natural.* m n = Number.Numeral.zero
    m = Number.Numeral.zero n = Number.Numeral.zero

length [] = Number.Numeral.zero
  h t. length (h :: t) = Number.Natural.suc (length t)

P.
    P Number.Numeral.zero (n. P n P (Number.Natural.suc n)) n. P n

(t. ¬¬t t) (¬T F) (¬F T)

m n.
    Number.Natural.exp m n = Number.Numeral.zero
    m = Number.Numeral.zero ¬(n = Number.Numeral.zero)

P Q. (x. P x Q x) (x. P x) x. Q x

P Q. (x. P x Q x) (x. P x) x. Q x

P Q. (x. P x Q x) (x. P x) x. Q x

P Q. (x. P x) (x. Q x) x. P x Q x

e f.
    fn.
      fn Number.Numeral.zero = e
      n. fn (Number.Natural.suc n) = f (fn n) n

P. P [] (a0 a1. P a1 P (a0 :: a1)) x. P x

<< <<<. (x y. << x y <<< x y) wellFounded <<< wellFounded <<

m n p.
    Number.Natural.* m n = Number.Natural.* m p
    m = Number.Numeral.zero n = p

m n p.
    Number.Natural.≤ (Number.Natural.* m n) (Number.Natural.* m p)
    m = Number.Numeral.zero Number.Natural.≤ n p

m n p.
    Number.Natural.< (Number.Natural.* m n) (Number.Natural.* m p)
    ¬(m = Number.Numeral.zero) Number.Natural.< n p

x y a b. (x, y) = (a, b) x = a y = b

A B C D. (A B) (C D) A C B D

A B C D. (A B) (C D) A C B D

P. (x. ∃!y. P x y) f. x y. P x y f x = y

(m.
     Number.Natural.exp m Number.Numeral.zero =
     Number.Numeral.bit1 Number.Numeral.zero)
  m n.
    Number.Natural.exp m (Number.Natural.suc n) =
    Number.Natural.* m (Number.Natural.exp m n)

P c x y. P (if c then x else y) (c P x) (¬c P y)

NIL' CONS'.
    fn. fn [] = NIL' a0 a1. fn (a0 :: a1) = CONS' a0 a1 (fn a1)

P. (∃!x. P x) (x. P x) x x'. P x P x' x = x'

<<. wellFounded << P. (x. (y. << y x P y) P x) x. P x

(b f. case b f none = b) b f a. case b f (some a) = f a

(l. [] @ l = l) h t l. (h :: t) @ l = h :: t @ l

(m. Number.Natural.≤ m Number.Numeral.zero m = Number.Numeral.zero)
  m n.
    Number.Natural.≤ m (Number.Natural.suc n)
    m = Number.Natural.suc n Number.Natural.≤ m n

t. ((T t) t) ((t T) t) ((F t) ¬t) ((t F) ¬t)

t. (T t t) (t T t) (F t F) (t F F) (t t t)

t. (T t T) (t T T) (F t t) (t F t) (t t t)

t. (T t t) (t T T) (F t T) (t t T) (t F ¬t)

<<.
    wellFounded <<
    H.
      (f g x. (z. << z x f z = g z) H f x = H g x)
      f. x. f x = H f x

(n. Number.Natural.+ Number.Numeral.zero n = n)
  (m. Number.Natural.+ m Number.Numeral.zero = m)
  (m n.
     Number.Natural.+ (Number.Natural.suc m) n =
     Number.Natural.suc (Number.Natural.+ m n))
  m n.
    Number.Natural.+ m (Number.Natural.suc n) =
    Number.Natural.suc (Number.Natural.+ m n)

p q r.
    (p q q p) ((p q) r p q r) (p q r q p r)
    (p p p) (p p q p q)