Coinductive interaction trees #
This module defines the coinductive interaction tree ITree as the final
coalgebra (PFunctor.M) of the interaction-tree polynomial functor, together
with its constructors (ret, tau, vis), the dependent matcher dMatchOn,
injectivity lemmas for the constructors, and the bisimulation equality IEq
that is proven to coincide with propositional equality (ieq_iff_eq).
The node shapes of an interaction tree: a returned value, a silent tau
step, or a visible effect vis. This is the A-component of the polynomial
functor whose M-type is ITree.
- ret {ε : Type u1 → Type v} {ρ : Type u2} (v : ρ) : shape ε ρ
- tau {ε : Type u1 → Type v} {ρ : Type u2} : shape ε ρ
- vis {ε : Type u1 → Type v} {ρ : Type u2} (α : Type u1) (e : ε α) : shape ε ρ
Instances For
The interaction-tree polynomial functor, packaging shape and children.
Equations
- Lean4Itree.ITree.P ε ρ = { A := Lean4Itree.ITree.shape ε ρ, B := Lean4Itree.ITree.children }
Instances For
Coinductive Interaction Tree defined with PFunctor.M.
Equivalent to the following definition:
coinductive ITree (ε : Type → Type) (ρ : Type)
| ret (v : ρ)
| tau (t : ITree ε ρ)
| vis {α : Type} (e : ε α) (k : α → ITree ε ρ)
Equations
- Lean4Itree.ITree ε ρ = (Lean4Itree.ITree.P ε ρ).M
Instances For
A continuation tree: a function from α into interaction trees, i.e. a
Kleisli arrow for the ITree monad.
Equations
- Lean4Itree.KTree ε α β = (α → Lean4Itree.ITree ε β)
Instances For
One layer of a tau node in the polynomial functor: a single silent child t.
Instances For
One layer of a vis node in the polynomial functor: an effect e with
continuation k indexed by the response type.
Equations
- Lean4Itree.ITree.vis' e k = ⟨Lean4Itree.ITree.shape.vis α e, fun (x : (Lean4Itree.ITree.P ε ρ).B (Lean4Itree.ITree.shape.vis α e)) => k x⟩
Instances For
The interaction tree that immediately returns the value v.
Equations
Instances For
The interaction tree that takes n silent tau steps into t.
Equations
- Lean4Itree.ITree.tauN 0 t = t
- Lean4Itree.ITree.tauN n_2.succ t = (Lean4Itree.ITree.tauN n_2 t).tau
Instances For
The interaction tree that performs the single effect e and returns its response.
Equations
- Lean4Itree.ITree.trigger e = Lean4Itree.ITree.vis e fun (x : α) => Lean4Itree.ITree.ret x
Instances For
Custom dependent match function for ITrees
Equations
- One or more equations did not get rendered due to their size.
Instances For
Infinite Taus
Equations
- Lean4Itree.ITree.infTau = PFunctor.M.corec' (fun {X : Type (max (max (max (?u.3 + 1) ?u.1) ?u.2) ?u.3)} (rec : Unit → X) (x : Unit) => Sum.inr (Lean4Itree.ITree.tau' (rec x))) ()
Instances For
A coinduction state for traversing interaction trees: either a whole tree
(ct) or a continuation tree (kt).
- ct {ε : Type u1 → Type v1} {ρ : Type u2} : ITree ε ρ → State ε ρ
- kt {ε : Type u1 → Type v1} {ρ : Type u2} {α : Type u1} : KTree ε α ρ → State ε ρ
Instances For
Notation C[ t ] for the tree state State.ct t.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Notation K[ t ] for the continuation-tree state State.kt t.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Simplify basic interaction-tree constructors and PFunctor.M.dest_mk.
Equations
- Lean4Itree.ITree.tacticSimpItreeBasic = Lean.ParserDescr.node `Lean4Itree.ITree.tacticSimpItreeBasic 1024 (Lean.ParserDescr.nonReservedSymbol "simpItreeBasic" false)
Instances For
Substitute the injectivity consequence of an equality h between
interaction-tree constructors.
Equations
- One or more equations did not get rendered due to their size.
Instances For
proveUnfoldLemma tries to finish a proof of an unfolding lemma defined by corec'
Note you have to first unfold corec' in the appropriate places,
possibly by some combination of conv and rw [PFunctor.M.unfold_corec'].
Equations
- Lean4Itree.ITree.tacticProveUnfoldLemma = Lean.ParserDescr.node `Lean4Itree.ITree.tacticProveUnfoldLemma 1024 (Lean.ParserDescr.nonReservedSymbol "proveUnfoldLemma" false)
Instances For
One unfolding of the bisimulation functor: two interaction trees agree at
the top constructor, with their immediate subtrees related by sim. The
bisimulation equality IEq is the fixed point of IEqF.
- ret {ε : Type u1 → Type v} {ρ : Type u2} {sim : ITree ε ρ → ITree ε ρ → Prop} (v : ρ) : IEqF sim (ITree.ret v) (ITree.ret v)
- vis {ε : Type u1 → Type v} {ρ : Type u2} {sim : ITree ε ρ → ITree ε ρ → Prop} {α : Type u1} (e : ε α) (k1 k2 : α → ITree ε ρ) (h : ∀ (a : α), sim (k1 a) (k2 a)) : IEqF sim (ITree.vis e k1) (ITree.vis e k2)
- tau {ε : Type u1 → Type v} {ρ : Type u2} {sim : ITree ε ρ → ITree ε ρ → Prop} (t1 t2 : ITree ε ρ) (h : sim t1 t2) : IEqF sim t1.tau t2.tau
Instances For
Custom equality predicate between ITrees
Equations
- t1.IEq t2 = Lean4Itree.ITree.IEqF Lean4Itree.ITree.IEq t1 t2