Documentation

LeanPool.InteractionCombinators.Core.System

Interaction systems and reduction #

Contents, in the order of the file:

  1. Rules: Rule, Rule.inst, Rule.Linear, Rule.Reduced, Rule.swap, Rule.count_vars_inst.
  2. Systems and one interaction: System, Step, Rule.symm_of_equiv, System.WellFormed.
  3. One interaction and linearity: Step.linear, Step.add_right.
  4. Reduction: Steps, Steps.single, Steps.cast, Steps.linear.
  5. Reduction up to wires: StepE, StepsE, Step.stepE, Steps.stepsE, StepE.linear, StepsE.linear.
  6. The tactic ms, which reorders a sum of multisets.
structure INet.Rule (S : Signature) (a b : ℕ) :

The right-hand side of an interaction rule. Its names are the a auxiliary ports of the first cell, the b auxiliary ports of the second, and internal new wires.

Instances For
    def INet.Rule.inst {S : Signature} {a b : ℕ} (r : Rule S a b) (as : Fin a → Term S ℕ) (bs : Fin b → Term S ℕ) (f : Fin r.internal → ℕ) :

    The right-hand side of a rule, with trees plugged into the auxiliary ports and the internal wires named by f.

    Equations
    Instances For
      structure INet.Rule.Linear {S : Signature} {a b : ℕ} (r : Rule S a b) :

      In the right-hand side of a rule, every auxiliary port of the two cells occurs exactly once and every internal wire exactly twice.

      Instances For
        def INet.Rule.Reduced {S : Signature} {a b : ℕ} (r : Rule S a b) :

        The right-hand side is a reduced net, written as trees rooted at the auxiliary ports: every equation has an auxiliary port on one side. Together with linearity this excludes pairs of cells plugged by their principal ports, vicious circles and cyclic wires.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          def INet.Rule.swap {S : Signature} {a b : ℕ} (r : Rule S a b) :
          Rule S b a

          The same rule read from the other cell: the two groups of auxiliary ports are exchanged.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem Multiset.count_bind_fintype {P ν : Type} [Fintype P] [DecidableEq P] [DecidableEq ν] (m : Multiset P) (g : P → Multiset ν) (y : ν) :
            count y (m.bind g) = ∑ p : P, count p m * count y (g p)

            The count of an element in a Multiset.bind over a finite type, as a sum over the type.

            theorem INet.Rule.count_vars_inst {S : Signature} {a b : ℕ} (r : Rule S a b) (hr : r.Linear) (as : Fin a → Term S ℕ) (bs : Fin b → Term S ℕ) (f : Fin r.internal → ℕ) (y : ℕ) :
            Multiset.count y (r.inst as bs f).vars = ∑ i : Fin a, Multiset.count y (as i).vars + ∑ j : Fin b, Multiset.count y (bs j).vars + 2 * ∑ w : Fin r.internal, if y = f w then 1 else 0

            The names of an instance of a linear rule: those of the trees plugged into the ports, and both ends of each internal wire.

            structure INet.System (S : Signature) :

            An interaction system: at most one rule for each pair of symbols. An equation is unordered, so a rule given for α, β also applies to β, α.

            Instances For
              inductive INet.Step {S : Signature} (I : System S) :
              Net S ℕ → Net S ℕ → Prop

              One interaction: two cells plugged by their principal ports are replaced by the right-hand side of their rule. The wires the rule creates get names not used in the net.

              Instances For
                theorem INet.Rule.symm_of_equiv {S : Signature} {a : ℕ} {r : Rule S a a} (h : Equiv r.swap.net r.net) :
                ∃ (π : Equiv.Perm (Fin r.internal)), Equiv r.swap.net (Net.bind (fun (x : Fin a ⊕ Fin a ⊕ Fin r.internal) => Term.var (Sum.map id (Sum.map id ⇑π) x)) r.net)

                A rule that is the same net as its swap up to wires is symmetric in the sense of System.WellFormed.symm, with the identity permutation.

                structure INet.System.WellFormed {S : Signature} (I : System S) :

                An interaction system in the sense of Lafont: rules are linear and reduced, and can be applied without ambiguity.

                Instances For
                  theorem INet.Step.linear {S : Signature} {I : System S} (hI : ∀ (α β : S.Sym) (r : Rule S (S.arity α) (S.arity β)), I.rule α β = some r → r.Linear) {N N' : Net S ℕ} (h : Step I N N') (hN : N.Linear) :

                  An interaction of a linear rule keeps the net linear.

                  theorem INet.Step.add_right {S : Signature} {I : System S} (hI : ∀ (α β : S.Sym) (r : Rule S (S.arity α) (S.arity β)), I.rule α β = some r → r.Linear) {N M : Net S ℕ} (h : Step I N M) (Γ : Net S ℕ) (hlin : (M + Γ).Linear) :
                  Step I (N + Γ) (M + Γ)

                  An interaction can be done inside a larger net, as long as the result is linear: the names given to the wires created by the rule are then unused in the rest of the net.

                  @[reducible, inline]
                  abbrev INet.Steps {S : Signature} (I : System S) :
                  Net S ℕ → Net S ℕ → Prop

                  Reduction in any number of interactions.

                  Equations
                  Instances For
                    theorem INet.Steps.single {S : Signature} {I : System S} {N N' : Net S ℕ} (h : Step I N N') :
                    Steps I N N'

                    One interaction is a reduction.

                    theorem INet.Steps.cast {S : Signature} {I : System S} {N N' M M' : Net S ℕ} (h : Steps I N N') (hN : N = M) (hN' : N' = M') :
                    Steps I M M'

                    A reduction carried along equalities of nets.

                    theorem INet.Steps.linear {S : Signature} {I : System S} {N N' : Net S ℕ} (hI : ∀ (α β : S.Sym) (r : Rule S (S.arity α) (S.arity β)), I.rule α β = some r → r.Linear) (h : Steps I N N') (hN : N.Linear) :

                    Reduction by linear rules keeps the net linear.

                    def INet.StepE {S : Signature} (I : System S) (N M : Net S ℕ) :

                    One interaction up to wires: the net is first rewritten into an equivalent one, then two cells interact. This lets two cells interact when their principal ports are joined by a named wire, as in x = α(…), x = β(…), which is an active pair of the graph.

                    Equations
                    Instances For
                      @[reducible, inline]
                      abbrev INet.StepsE {S : Signature} (I : System S) :
                      Net S ℕ → Net S ℕ → Prop

                      Reduction up to wires, in any number of interactions.

                      Equations
                      Instances For
                        theorem INet.Step.stepE {S : Signature} {I : System S} {N M : Net S ℕ} (h : Step I N M) :
                        StepE I N M

                        One interaction is one interaction up to wires.

                        theorem INet.Steps.stepsE {S : Signature} {I : System S} {N M : Net S ℕ} (h : Steps I N M) :
                        StepsE I N M

                        A reduction is a reduction up to wires.

                        theorem INet.StepE.linear {S : Signature} {I : System S} (hI : ∀ (α β : S.Sym) (r : Rule S (S.arity α) (S.arity β)), I.rule α β = some r → r.Linear) {N M : Net S ℕ} (h : StepE I N M) (hN : N.Linear) :

                        An interaction up to wires, by a linear rule, keeps the net linear.

                        theorem INet.StepsE.linear {S : Signature} {I : System S} (hI : ∀ (α β : S.Sym) (r : Rule S (S.arity α) (S.arity β)), I.rule α β = some r → r.Linear) {N M : Net S ℕ} (h : StepsE I N M) (hN : N.Linear) :

                        Reduction up to wires, by linear rules, keeps the net linear.

                        Reorder a sum of multisets.

                        Equations
                        Instances For