Documentation

RoleFlow.Front

The argument-swapping front end #

A swappable operation (Swap) has two arguments of one sort and a semi-inverse that solves the first; in the flow signature, add. A program that adds a + b where b is to be consumed is not typed as written; swapArgs rewrites it to add(b, a).

The choice is made by forward inference. Every line contributes its forward form, its solved form if it has a semi-inverse, and, for a swappable o(a, b), the swapped solved form b ← (c, a). Starting from the weights and the returned variables, an equation fires when its reads are known and its results unknown, until nothing fires (fwdKnown). The pass swaps exactly the lines whose swapped form fired. The swap preserves the meaning for a model where the swappable operations commute (FrontSem), and if any swap of the program is typed, the one chosen here is (FrontComplete).

class RoleFlow.Swap {S : Type} (Sg : Sig S) :

The swappable operations of a signature: two arguments of one sort, and a semi-inverse that solves the first.

Instances
    def RoleFlow.kOf {S : Type} {Sg : Sig S} (l : Line Sg) :

    How many leading arguments the semi-inverse of l solves, if there is one.

    Equations
    Instances For
      def RoleFlow.solvedEqns {S : Type} {Sg : Sig S} (i n : ℕ) (l : Line Sg) :

      The solved form of the line l, numbered i, at scope n.

      Equations
      Instances For
        def RoleFlow.swappedEqns {S : Type} {Sg : Sig S} [Swap Sg] (i n : ℕ) (l : Line Sg) :

        The swapped solved form: a swappable o(a, b) solved for b.

        Equations
        Instances For
          def RoleFlow.lineEqns {S : Type} {Sg : Sig S} [Swap Sg] (i n : ℕ) (l : Line Sg) :

          The equations of the line l: forward, solved, and swapped solved.

          Equations
          Instances For
            def RoleFlow.eqns {S : Type} {Sg : Sig S} [Swap Sg] :
            ℕ → ℕ → List (Line Sg) → List Search.Eqn

            The equations of the lines at scope n, numbered from i.

            Equations
            Instances For
              def RoleFlow.swapIf {S : Type} {Sg : Sig S} [Swap Sg] (s : Bool) (l : Line Sg) :
              Line Sg

              Swap the arguments of l if it is swappable and s holds.

              Equations
              Instances For
                def RoleFlow.swapLines {S : Type} {Sg : Sig S} [Swap Sg] (sw : ℕ → Bool) :
                ℕ → List (Line Sg) → List (Line Sg)

                Swap the lines whose number (from i) satisfies sw.

                Equations
                Instances For
                  def RoleFlow.swapSet {S : Type} {Sg : Sig S} [Swap Sg] (P : Prog Sg) :

                  The lines whose swapped form fired.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def RoleFlow.swapArgs {S : Type} {Sg : Sig S} [Swap Sg] (P : Prog Sg) :
                    Prog Sg

                    The front end: swap the arguments of the lines whose swapped solved form fired.

                    Equations
                    Instances For