Documentation

MeTTaILProofs.ACMatch

Internal result of AC matching: bindings plus the AC representative matched syntactically.

Instances For

    Internal list result of AC matching.

    Instances For
      def MeTTaIL.AC.acRestPattern (l : Label) (fixed : AST) (restVar : String) :

      Pattern for one fixed AC leaf and one rest variable.

      Equations
      Instances For
        def MeTTaIL.AC.bindBase (v : String) (t : AST) (bnds : List (String × AST)) :

        Bind a base variable consistently with the ordinary matcher.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem MeTTaIL.AC.bindBase_eq_matchPat (v : String) (t : AST) (bnds : List (String × AST)) :
          bindBase v t bnds = (AST.var (DottedPath.base v)).matchPat t bnds

          bindBase is the ordinary matcher on a base variable.

          def MeTTaIL.AC.matchACRestLoop (l : Label) (fixed : AST) (restVar : String) (bnds : List (String × AST)) (preRev : List AST) :

          Search loop for one AC collection. preRev stores leaves already skipped, in reverse order.

          Equations
          Instances For
            def MeTTaIL.AC.matchACRest (l : Label) (fixed : AST) (restVar : String) (subject : AST) (bnds : List (String × AST)) :

            Search one AC collection for a fixed leaf and bind the rest variable to the rebuilt remainder.

            Equations
            Instances For
              theorem MeTTaIL.AC.matchACRestLoop_witness (l : Label) (fixed : AST) (restVar : String) (bnds : List (String × AST)) {preRev leaves : List AST} {r : ACMatch} :
              matchACRestLoop l fixed restVar bnds preRev leaves = some r(acRestPattern l fixed restVar).matchPat r.witness bnds = some r.bnds

              A successful AC-rest search returns a syntactic representative that the ordinary matcher accepts.

              theorem MeTTaIL.AC.matchACRest_witness {l : Label} {fixed : AST} {restVar : String} {subject : AST} {bnds : List (String × AST)} {r : ACMatch} (hm : matchACRest l fixed restVar subject bnds = some r) :
              (acRestPattern l fixed restVar).matchPat r.witness bnds = some r.bnds

              A successful AC-rest match returns a syntactic representative accepted by the ordinary matcher.

              theorem MeTTaIL.AC.matchACRestLoop_complete_of_split (l : Label) (fixed : AST) (restVar : String) (bnds : List (String × AST)) {preRev leaves : List AST} :
              (∃ (pre : List AST) (leaf : AST) (tail : List AST) (bnds₁ : List (String × AST)) (bnds₂ : List (String × AST)), leaves = pre ++ leaf :: tail fixed.matchPat leaf bnds = some bnds₁ bindBase restVar (rebuild l (preRev.reverse ++ pre ++ tail)) bnds₁ = some bnds₂)∃ (r : ACMatch), matchACRestLoop l fixed restVar bnds preRev leaves = some r

              If a chosen split of the flattened leaves has a matching fixed leaf and a bindable rebuilt rest, the AC-rest search succeeds. This is completeness for the linear search shape, not uniqueness of the returned bindings.

              def MeTTaIL.AC.ACRestFlatSplit (l : Label) (fixed a b : AST) (restVar : String) (bnds : List (String × AST)) :

              A flattened binary AC subject has a split that the linear AC-rest matcher can use.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                theorem MeTTaIL.AC.matchACRest_complete_of_flat_split {l : Label} {fixed a b : AST} {restVar : String} {bnds : List (String × AST)} (h : ACRestFlatSplit l fixed a b restVar bnds) :
                ∃ (r : ACMatch), matchACRest l fixed restVar (AST.sexp l [a, b]) bnds = some r

                Completeness for one binary AC subject, stated over a split of its flattened leaves.

                theorem MeTTaIL.AC.rebuild_middle_ac (acOp : LabelBool) {l : Label} (hac : acOp l = true) (leaf : AST) (pre tail : List AST) (hrest : pre ++ tail []) :
                ACEq acOp (rebuild l (pre ++ leaf :: tail)) (AST.sexp l [leaf, rebuild l (pre ++ tail)])

                Moving the selected AC leaf to the head preserves the rebuilt collection modulo AC.

                theorem MeTTaIL.AC.matchACRestLoop_acEq (acOp : LabelBool) {l : Label} (hac : acOp l = true) (fixed : AST) (restVar : String) (bnds : List (String × AST)) {preRev leaves : List AST} {r : ACMatch} :
                2 (preRev.reverse ++ leaves).lengthmatchACRestLoop l fixed restVar bnds preRev leaves = some rACEq acOp (rebuild l (preRev.reverse ++ leaves)) r.witness

                The AC-rest search witness is AC-equivalent to the rebuilt leaves being searched, provided the collection still has at least two leaves. That invariant is true for binary AC subjects.

                A binary AC subject has at least two flattened leaves.

                theorem MeTTaIL.AC.matchACRest_acEq {acOp : LabelBool} {l : Label} (hac : acOp l = true) {fixed : AST} {restVar : String} {subject : AST} {bnds : List (String × AST)} {r : ACMatch} (hm : matchACRest l fixed restVar subject bnds = some r) :
                ACEq acOp subject r.witness

                A successful AC-rest match returns a representative AC-equivalent to the subject.

                AC-aware first-order matching. The AC-specific case is linear: one fixed subpattern and one rest variable under an AC binary collection.

                Equations
                Instances For

                  Pointwise AC-aware matching for argument lists.

                  Equations
                  Instances For
                    def MeTTaIL.AC.matchPatAC (acOp : LabelBool) (pat t : AST) (bnds : List (String × AST)) :

                    Public AC-aware matcher.

                    Equations
                    Instances For
                      theorem MeTTaIL.AC.matchPatACRaw_acRest_sound {acOp : LabelBool} {l : Label} {fixed subject : AST} {restVar : String} {bnds : List (String × AST)} {r : ACMatch} (hac : acOp l = true) (hm : matchPatACRaw acOp (acRestPattern l fixed restVar) subject bnds = some r) :
                      ACEq acOp subject r.witness (acRestPattern l fixed restVar).matchPat r.witness bnds = some r.bnds

                      A successful linear AC-rest match has an AC-equivalent syntactic representative accepted by the ordinary matcher.

                      theorem MeTTaIL.AC.matchPatACRaw_acRest_witness {acOp : LabelBool} {l : Label} {fixed subject : AST} {restVar : String} {bnds : List (String × AST)} {r : ACMatch} (hac : acOp l = true) (hm : matchPatACRaw acOp (acRestPattern l fixed restVar) subject bnds = some r) :
                      (acRestPattern l fixed restVar).matchPat r.witness bnds = some r.bnds

                      A successful linear AC-rest match has a syntactic representative accepted by the ordinary matcher.

                      theorem MeTTaIL.AC.matchPatAC_acRest_raw {acOp : LabelBool} {l : Label} {fixed subject : AST} {restVar : String} {bnds bnds' : List (String × AST)} (hm : matchPatAC acOp (acRestPattern l fixed restVar) subject bnds = some bnds') :
                      ∃ (r : ACMatch), matchPatACRaw acOp (acRestPattern l fixed restVar) subject bnds = some r r.bnds = bnds'

                      Lift a public AC-rest match back to the raw matcher result it erased.

                      theorem MeTTaIL.AC.matchPatAC_acRest_sound {acOp : LabelBool} {l : Label} {fixed subject : AST} {restVar : String} {bnds bnds' : List (String × AST)} (hac : acOp l = true) (hm : matchPatAC acOp (acRestPattern l fixed restVar) subject bnds = some bnds') :
                      ∃ (witness : AST), ACEq acOp subject witness (acRestPattern l fixed restVar).matchPat witness bnds = some bnds'

                      Public soundness bridge for the linear AC-rest fragment used by Cordial Miners.

                      theorem MeTTaIL.AC.matchPatAC_acRest_witness {acOp : LabelBool} {l : Label} {fixed subject : AST} {restVar : String} {bnds bnds' : List (String × AST)} (hac : acOp l = true) (hm : matchPatAC acOp (acRestPattern l fixed restVar) subject bnds = some bnds') :
                      ∃ (witness : AST), (acRestPattern l fixed restVar).matchPat witness bnds = some bnds'

                      Public witness theorem for the linear AC-rest fragment used by Cordial Miners.

                      theorem MeTTaIL.AC.matchPatAC_acRest_complete_of_flat_split {acOp : LabelBool} {l : Label} {fixed a b : AST} {restVar : String} {bnds : List (String × AST)} (hac : acOp l = true) (h : ACRestFlatSplit l fixed a b restVar bnds) :
                      ∃ (bnds' : List (String × AST)), matchPatAC acOp (acRestPattern l fixed restVar) (AST.sexp l [a, b]) bnds = some bnds'

                      Public completeness theorem for the linear AC-rest fragment. If the flattened binary AC subject has a split whose selected leaf matches the fixed subpattern and whose remaining leaves bind to the rest variable, the AC-aware matcher returns some bindings.

                      theorem MeTTaIL.AC.matchPatAC_acRest_complete_of_fresh_split {acOp : LabelBool} {l : Label} {fixed a b : AST} {restVar : String} {bnds : List (String × AST)} {pre tail : List AST} {leaf : AST} {bnds₁ : List (String × AST)} (hac : acOp l = true) (hflat : flat l (AST.sexp l [a, b]) = pre ++ leaf :: tail) (hfixed : fixed.matchPat leaf bnds = some bnds₁) (hfresh : List.find? (fun (b : String × AST) => b.1 == restVar) bnds₁ = none) :
                      ∃ (bnds' : List (String × AST)), matchPatAC acOp (acRestPattern l fixed restVar) (AST.sexp l [a, b]) bnds = some bnds'

                      Public completeness theorem for the common linear AC-rest case. If a selected flattened leaf matches the fixed subpattern and the rest variable is fresh after that match, the AC-aware matcher succeeds. This is the Cordial Miners rule shape: one observed fact or event, and one variable for the rest of the collection.

                      theorem MeTTaIL.AC.matchPatACRaw_sound (acOp : LabelBool) (pat t : AST) (bnds : List (String × AST)) (r : ACMatch) :
                      matchPatACRaw acOp pat t bnds = some rACEq acOp t r.witness pat.matchPat r.witness bnds = some r.bnds

                      Raw AC-aware matcher soundness. A successful match returns an AC-equivalent witness accepted by the ordinary matcher.

                      theorem MeTTaIL.AC.matchPatAC_sound {acOp : LabelBool} {pat subject : AST} {bnds bnds' : List (String × AST)} (hm : matchPatAC acOp pat subject bnds = some bnds') :
                      ∃ (witness : AST), ACEq acOp subject witness pat.matchPat witness bnds = some bnds'

                      Public AC-aware matcher soundness.

                      Apply one premise-free rewrite using AC-aware matching.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Every top-level AC-aware base reduct of a term.

                        Equations
                        Instances For
                          theorem MeTTaIL.AC.reduces_of_applyBaseRewriteAC {acOp : LabelBool} {p : Presentation} {rd : RewriteDecl} {t t' : AST} (hmem : rd p.rewrites) (h : applyBaseRewriteAC acOp rd t = some t') :
                          ∃ (witness : AST), ACEq acOp t witness Reduces p witness t'

                          Every AC-aware base rewrite has an AC-equivalent ordinary-rewrite witness.

                          theorem MeTTaIL.AC.reduces_of_mem_baseReductsAC {acOp : LabelBool} {p : Presentation} {t t' : AST} (h : t' baseReductsAC acOp p t) :
                          ∃ (witness : AST), ACEq acOp t witness Reduces p witness t'

                          Every member of baseReductsAC has an AC-equivalent ordinary-rewrite witness.

                          theorem MeTTaIL.AC.rewStepModAC_of_mem_baseReductsAC {acOp : LabelBool} {p : Presentation} {t t' : AST} (h : t' baseReductsAC acOp p t) :
                          RewStepModAC acOp p t t'

                          A top-level executable AC-aware reduct is a genuine rewrite modulo AC.

                          theorem MeTTaIL.AC.rewStepModAC_arg {acOp : LabelBool} {p : Presentation} {l : Label} {pre post : List AST} {a a' : AST} (h : RewStepModAC acOp p a a') :
                          RewStepModAC acOp p (AST.sexp l (pre ++ a :: post)) (AST.sexp l (pre ++ a' :: post))

                          Lift a rewrite modulo AC through one sexp argument context.

                          theorem MeTTaIL.AC.rewStepModAC_substB {acOp : LabelBool} {p : Presentation} {b b' r : AST} {v : DottedPath} (h : RewStepModAC acOp p b b') :
                          RewStepModAC acOp p (b.subst r v) (b'.subst r v)

                          Lift a rewrite modulo AC through the body of a subst node.

                          theorem MeTTaIL.AC.rewStepModAC_substR {acOp : LabelBool} {p : Presentation} {b r r' : AST} {v : DottedPath} (h : RewStepModAC acOp p r r') :
                          RewStepModAC acOp p (b.subst r v) (b.subst r' v)

                          Lift a rewrite modulo AC through the replacement of a subst node.

                          One leftmost-outermost step using AC-aware matching at every visited node.

                          Equations
                          Instances For

                            One AC-aware step inside the first reducible list element.

                            Equations
                            Instances For
                              def MeTTaIL.AC.evalAC' (acOp : LabelBool) (p : Presentation) :
                              ASTAST

                              Fuel-bounded evaluation using the AC-aware stepper.

                              Equations
                              Instances For
                                theorem MeTTaIL.AC.oneStepAC'_sound (acOp : LabelBool) (p : Presentation) (t : AST) {t' : AST} :
                                oneStepAC' acOp p t = some t'RewStepModAC acOp p t t'

                                Soundness: every executable AC-aware one-step reduct is a genuine rewrite modulo AC.

                                theorem MeTTaIL.AC.oneStepACList'_sound (acOp : LabelBool) (p : Presentation) (args : List AST) {args' : List AST} :
                                oneStepACList' acOp p args = some args'∃ (pre : List AST) (a : AST) (a' : AST) (post : List AST), args = pre ++ a :: post args' = pre ++ a' :: post RewStepModAC acOp p a a'

                                Soundness for the AC-aware list stepper.

                                theorem MeTTaIL.AC.evalAC'_sound (acOp : LabelBool) (p : Presentation) (fuel : ) (t : AST) :
                                Relation.ReflTransGen (RewStepModAC acOp p) t (evalAC' acOp p fuel t)

                                Soundness of fuel-bounded AC-aware evaluation.