Documentation

LeanPool.InteractionCombinators.Core.Term

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.

Contents, in the order of the file:

  1. Signatures and trees: Signature, Term.
  2. Names, and plugging a tree into every leaf: Term.vars, Term.bind, Term.vars_bind.
  3. Cells: Term.cells, Term.cells_bind.
  4. Plugging a tree into one name: Term.subst, Term.subst_of_notMem, Term.count_vars_subst, Term.cells_subst.
structure INet.Signature :

Symbols, each with the number of its auxiliary ports. Every cell also has one principal port.

  • Sym : Type

    The symbols.

  • arity : self.Sym → ℕ

    The number of auxiliary ports of a symbol.

Instances For
    inductive INet.Term (S : Signature) (ν : Type) :

    A tree of cells with leaves named in ν. The root of app α ts is the principal port of an α cell whose i-th auxiliary port is plugged into the root of ts i.

    Instances For
      def INet.Term.vars {S : Signature} {ν : Type} :
      Term S ν → Multiset ν

      The leaves of a tree, with multiplicity.

      Equations
      Instances For
        def INet.Term.bind {S : Signature} {ν μ : Type} (f : ν → Term S μ) :
        Term S ν → Term S μ

        Plug the tree f x into every leaf x.

        Equations
        Instances For
          @[simp]
          theorem INet.Term.vars_var {S : Signature} {ν : Type} (x : ν) :
          (var x).vars = {x}

          The names of a leaf: the leaf itself.

          @[simp]
          theorem INet.Term.vars_app {S : Signature} {ν : Type} (α : S.Sym) (ts : Fin (S.arity α) → Term S ν) :
          (app α ts).vars = ∑ i : Fin (S.arity α), (ts i).vars

          The names of a cell: those of its subtrees.

          @[simp]
          theorem INet.Term.bind_var {S : Signature} {ν μ : Type} (f : ν → Term S μ) (x : ν) :
          bind f (var x) = f x

          Plugging into a leaf gives the tree chosen for its name.

          @[simp]
          theorem INet.Term.bind_app {S : Signature} {ν μ : Type} (f : ν → Term S μ) (α : S.Sym) (ts : Fin (S.arity α) → Term S ν) :
          bind f (app α ts) = app α fun (i : Fin (S.arity α)) => bind f (ts i)

          Plugging into a cell keeps the cell and plugs into its subtrees.

          theorem Multiset.sum_bind' {ι α β : Type} (s : Finset ι) (f : ι → Multiset α) (g : α → Multiset β) :
          (∑ i ∈ s, f i).bind g = ∑ i ∈ s, (f i).bind g

          Multiset.bind distributes over a finite sum of multisets.

          theorem INet.Term.vars_bind {S : Signature} {ν μ : Type} (f : ν → Term S μ) (t : Term S ν) :
          (bind f t).vars = t.vars.bind fun (x : ν) => (f x).vars

          The names of a tree after plugging: each leaf x is replaced by the names of f x.

          def INet.Term.cells {S : Signature} {ν : Type} :
          Term S ν → Multiset S.Sym

          The cells of a tree: the symbols occurring in it, with multiplicity.

          Equations
          Instances For
            @[simp]
            theorem INet.Term.cells_var {S : Signature} {ν : Type} (x : ν) :
            (var x).cells = 0

            A leaf has no cell.

            @[simp]
            theorem INet.Term.cells_app {S : Signature} {ν : Type} (α : S.Sym) (ts : Fin (S.arity α) → Term S ν) :
            (app α ts).cells = α ::ₘ ∑ i : Fin (S.arity α), (ts i).cells

            The cells of a tree with a cell at its root: that cell and the cells of the subtrees.

            theorem INet.Term.cells_bind {S : Signature} {ν μ : Type} (f : ν → Term S μ) (t : Term S ν) :
            (bind f t).cells = t.cells + t.vars.bind fun (x : ν) => (f x).cells

            The cells of a tree after plugging: its own cells, and for each leaf x the cells of f x.

            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
            Instances For
              theorem INet.Term.subst_of_notMem {S : Signature} {ν : Type} [DecidableEq ν] {x : ν} {t r : Term S ν} (h : x ∉ r.vars) :
              r.subst x t = r

              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 ν) :

              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 ν) :
              (m.bind fun (z : ν) => (if z = x then t else var z).cells) = Multiset.count x m • t.cells

              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.

              theorem INet.Term.cells_subst {S : Signature} {ν : Type} [DecidableEq ν] (r : Term S ν) (x : ν) (t : Term S ν) :

              Substitution adds one copy of the cells of t for each occurrence of x.