Trees over a signature #
The textual presentation of interaction nets: a net is a set of equations between trees, and a name stands for a wire, occurring once at each of its two ends.
Signature— symbols with the number of their auxiliary ports.Term S ν— trees of cells whose leaves are names inν.Term.bind— plug a tree into every leaf;Term.subst— plug a tree into one name.
Contents, in the order of the file:
- Signatures and trees:
Signature,Term. - Names, and plugging a tree into every leaf:
Term.vars,Term.bind,Term.vars_bind. - Cells:
Term.cells,Term.cells_bind. - Plugging a tree into one name:
Term.subst,Term.subst_of_notMem,Term.count_vars_subst,Term.cells_subst.
Plug the tree f x into every leaf x.
Equations
- INet.Term.bind f (INet.Term.var x_1) = f x_1
- INet.Term.bind f (INet.Term.app α ts) = INet.Term.app α fun (i : Fin (S.arity α)) => INet.Term.bind f (ts i)
Instances For
theorem
Multiset.sum_bind'
{ι α β : Type}
(s : Finset ι)
(f : ι → Multiset α)
(g : α → Multiset β)
:
Multiset.bind distributes over a finite sum of multisets.
def
INet.Term.subst
{S : Signature}
{ν : Type}
[DecidableEq ν]
(r : Term S ν)
(x : ν)
(t : Term S ν)
:
Term S ν
Plug the tree t into the name x.
Equations
- r.subst x t = INet.Term.bind (fun (y : ν) => if y = x then t else INet.Term.var y) r
Instances For
theorem
INet.Term.subst_of_notMem
{S : Signature}
{ν : Type}
[DecidableEq ν]
{x : ν}
{t r : Term S ν}
(h : x ∉ r.vars)
:
Plugging into a name that does not occur in the tree changes nothing.
theorem
INet.Term.count_bind_ite
{S : Signature}
{ν : Type}
[DecidableEq ν]
(m : Multiset ν)
(x y : ν)
(t : Term S ν)
:
Multiset.count y (m.bind fun (z : ν) => (if z = x then t else var z).vars) = Multiset.count x m * Multiset.count y t.vars + if y = x then 0 else Multiset.count y m
The count of a name y in a multiset of names m after t is plugged into x: one copy of
the names of t for each occurrence of x, and the other names of m unchanged.
theorem
INet.Term.count_vars_subst
{S : Signature}
{ν : Type}
[DecidableEq ν]
(r : Term S ν)
(x y : ν)
(t : Term S ν)
:
Multiset.count y (r.subst x t).vars = Multiset.count x r.vars * Multiset.count y t.vars + if y = x then 0 else Multiset.count y r.vars
The leaves of r.subst x t: every x is replaced by the leaves of t.
theorem
INet.Term.bind_ite_cells
{S : Signature}
{ν : Type}
[DecidableEq ν]
(m : Multiset ν)
(x : ν)
(t : Term S ν)
:
The cells brought by plugging t into x in a multiset of names m: one copy of the cells
of t for each occurrence of x.