Documentation

PrimParser.Properties

PrimParser Lawfulness Proofs #

Lawful instances for Success, Outcome, and Parser: LawfulFunctor, LawfulGradedFunctor, LawfulGradedApplicative, LawfulGradedMonad.

theorem Parser.ext {α ε : Type} {g : Grade} {p q : Parser ε g α} (h : ∀ {m : } (t : Text m), p.run t = q.run t) :
p = q
theorem Parser.ext_iff {α ε : Type} {g : Grade} {p q : Parser ε g α} :
p = q ∀ {m : } (t : Text m), p.run t = q.run t
theorem Parser.heq {α ε : Type} {g1 g2 : Grade} {p : Parser ε g1 α} {q : Parser ε g2 α} (hg : g1 = g2) (h : ∀ {m : } (t : Text m), p.run t q.run t) :
p q
@[simp]
theorem Parser.Failure.trans_self {ε : Type} {n : } (e : Failure n ε) (h : n n) :
e.trans h = e
theorem Parser.Success.heq {α : Type} {n : } {c1 c2 : Necessity} {s1 : Success n c1 α} {s2 : Success n c2 α} (hc : c1 = c2) (hr : s1.result = s2.result := by rfl) (hrs : s1.restSize = s2.restSize := by rfl) :
s1 s2
theorem Parser.Success.seq_assoc {α β γ : Type} {n : } {gc gc' gc'' : Necessity} {a : Success n gc α} {b : Success a.restSize gc' β} {c : Success b.restSize gc'' γ} :
(a.seq b).seq c a.seq (b.seq c)
@[simp]
theorem Parser.Success.seq_result {α β : Type} {n : } {gc gc' : Necessity} (a : Success n gc α) (b : Success a.restSize gc' β) :
(a.seq b).result = b.result
@[simp]
theorem Parser.Success.seq_restSize {α β : Type} {n : } {gc gc' : Necessity} (a : Success n gc α) (b : Success a.restSize gc' β) :
theorem Parser.Outcome.failure_congr {α ε : Type} {n : } {c1 c2 : Necessity} {f : Failure n ε} (hc : c1 = c2) :
theorem Parser.Outcome.success_congr {α ε : Type} {n : } {c1 c2 : Necessity} {s1 : Success n c1 α} {s2 : Success n c2 α} (hc : c1 = c2) (hs : s1 s2) :
theorem Parser.bind_run {α β ε : Type} {n : } {g g' : Grade} (m : Parser ε g α) (f : αParser ε g' β) (t : Text n) :
(m.bind f).run t = match m.run t with | failure e => failure e | success x => match (f x.result).run (t.dropTo x.restSize ) with | failure e => failure (e.trans ) | success y => success (x.seq y)
theorem Parser.gpure_gbind {α β ε : Type} {j : Grade} (a : α) (f : αParser ε j β) :
gpure a >>=ᵍ f f a
theorem Parser.gbind_gpure {α ε : Type} {i : Grade} (p : Parser ε i α) :
theorem Parser.gbind_assoc {α β γ ε : Type} {i j k : Grade} (x : Parser ε i α) (f : αParser ε j β) (g : βParser ε k γ) :
x >>=ᵍ f >>=ᵍ g x >>=ᵍ fun (a : α) => f a >>=ᵍ g
theorem Parser.gmap_gpure {α β ε : Type} (G : αβ) (x : α) :
G <$>ᵍ gpure x = gpure (G x)
theorem Parser.gpure_gseq {α β ε : Type} {i : Grade} (G : αβ) (x : Parser ε i α) :
(gpure G <*>ᵍ fun (x_1 : Unit) => x) G <$>ᵍ x
theorem Parser.gseq_gpure {α β ε : Type} {i : Grade} (u : Parser ε i (αβ)) (x : α) :
(u <*>ᵍ fun (x_1 : Unit) => gpure x) (fun (x_1 : αβ) => x_1 x) <$>ᵍ u
theorem Parser.gseq_assoc {α β γ ε : Type} {i j k : Grade} (u : Parser ε i (βγ)) (v : Parser ε j (αβ)) (w : Parser ε k α) :
((Function.comp <$>ᵍ u <*>ᵍ fun (x : Unit) => v) <*>ᵍ fun (x : Unit) => w) u <*>ᵍ fun (x : Unit) => v <*>ᵍ fun (x : Unit) => w