Documentation

Aesop.Forward.State

inductive Aesop.RawHyp :

A hypothesis that has not yet been matched against a premise, or a rule pattern substitution.

  • fvarId (fvarId : Lean.FVarId) : RawHyp

    The hypothesis.

  • patSubst (subst : Substitution) : RawHyp

    The rule pattern substitution.

Instances For
    @[implicit_reducible]
    Equations
    @[implicit_reducible]
    instance Aesop.instToMessageDataRawHyp :
    Lean.ToMessageData RawHyp
    Equations
    • One or more equations did not get rendered due to their size.
    structure Aesop.Hyp :

    A hypothesis that was matched against a premise, or a rule pattern substitution.

    • fvarId? : Option Lean.FVarId

      The hypothesis, or none if this is a rule pattern substitution.

    • subst : Substitution

      The substitution that results from matching the hypothesis against a premise or that was derived from the pattern.

    Instances For
      Equations
      Instances For
        @[implicit_reducible]
        instance Aesop.instInhabitedHyp :
        Inhabited Hyp
        Equations
        @[implicit_reducible]
        instance Aesop.Hyp.instBEq :
        BEq Hyp
        Equations
        • One or more equations did not get rendered due to their size.
        @[implicit_reducible]
        instance Aesop.Hyp.instHashable :
        Hashable Hyp
        Equations
        def Aesop.Hyp.containsHyp (fvarId : Lean.FVarId) (h : Hyp) :
        Bool

        Returns true if h is the hyp fvarId or is a pattern substitution containing fvarId.

        Equations
        Instances For
          def Aesop.Hyp.isPatSubst (h : Hyp) :
          Bool

          Does this Hyp represent a pattern substitution?

          Equations
          Instances For
            structure Aesop.InstMap :

            Partial matches associated with a particular slot instantiation. An entry s โ†ฆ e โ†ฆ (ms, hs) indicates that for the instantiation e of slot s, we have partial matches ms and hypotheses hs.

            Instances For
              @[implicit_reducible]
              instance Aesop.InstMap.instEmptyCollection :
              EmptyCollection InstMap
              Equations
              @[implicit_reducible]
              instance Aesop.InstMap.instToMessageData :
              Lean.ToMessageData InstMap
              Equations
              @[inline]
              def Aesop.InstMap.find? (imap : InstMap) (slot : SlotIndex) (inst : Lean.Expr) :
              Lean.MetaM (Option (Lean.PHashSet Match ร— Lean.PHashSet Hyp))

              Returns the set of matches and hypotheses associated with a slot slot with instantiation inst.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[inline]
                def Aesop.InstMap.findD (imap : InstMap) (slot : SlotIndex) (inst : Lean.Expr) :
                Lean.MetaM (Lean.PHashSet Match ร— Lean.PHashSet Hyp)

                Returns the set of matches and hypotheses associated with a slot slot with instantiation inst, or (โˆ…, โˆ…) if slot and inst do not have any associated matches.

                Equations
                • imap.findD slot inst = do let __do_lift โ† imap.find? slot inst pure (__do_lift.getD (โˆ…, โˆ…))
                Instances For
                  def Aesop.InstMap.modify {ฮฑ : Type} (imap : InstMap) (slot : SlotIndex) (inst : Lean.Expr) (f : Lean.PHashSet Match โ†’ Lean.PHashSet Hyp โ†’ Lean.PHashSet Match ร— Lean.PHashSet Hyp ร— ฮฑ) :
                  Lean.MetaM (InstMap ร— ฮฑ)

                  Applies a transformation to the data associated with slot and inst. If there is no such data, the transformation is applied to (โˆ…, โˆ…). Returns the new instantiation map and the result of f.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def Aesop.InstMap.insertHyp (imap : InstMap) (slot : SlotIndex) (inst : Lean.Expr) (hyp : Hyp) :
                    Lean.MetaM (InstMap ร— Bool)

                    Inserts a hyp associated with slot slot and instantiation inst. The hyp must be a valid assignment for the slot's premise. Returns true if the hyp was not previously associated with slot and inst.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def Aesop.InstMap.insertMatchCore (imap : InstMap) (slot : SlotIndex) (inst : Lean.Expr) (m : Match) :
                      Lean.MetaM (InstMap ร— Bool)

                      Inserts a match associated with slot slot and instantiation inst. The match's level must be slot. Returns true if the match was not previously associated with slot and inst.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        def Aesop.InstMap.insertMatch (imap : InstMap) (var : PremiseIndex) (m : Match) :
                        BaseM (InstMap ร— Bool)

                        Inserts a match. The match m is associated with the slot given by its level (i.e., the maximal slot for which m contains a hypothesis) and the instantiation of var given by the map's substitution. Returns true if the match was not previously associated with this slot and instantiation.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          def Aesop.InstMap.modifyMapsForSlotsFrom (imap : InstMap) (slot : SlotIndex) (f : Lean.PHashSet Match โ†’ Lean.PHashSet Hyp โ†’ Lean.PHashSet Match ร— Lean.PHashSet Hyp) :

                          Modify the maps for slot slot and all later slots.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def Aesop.InstMap.eraseHyp (imap : InstMap) (hyp : Lean.FVarId) (slot : SlotIndex) :

                            Remove hyp from slot and all later slots. For each mapping s โ†ฆ e โ†ฆ (ms, hs) in imap, if s โ‰ฅ slot, then hyp is removed from hs and any matches containing hyp are removed from ms.

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

                              Remove the pattern substitution subst from slot and all later slots. For each mapping s โ†ฆ e โ†ฆ (ms, hs) in imap, if s โ‰ฅ slot, then subst is removed from hs and any matches containing subst are removed from ms.

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

                                Extract stats from an InstMap.

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

                                  Map from variables to the matches and hypotheses of slots whose types contain the variables.

                                  Instances For
                                    @[implicit_reducible]
                                    Equations

                                    Get the InstMap associated with a variable.

                                    Equations
                                    • vmap.find? var = Lean.PersistentHashMap.find? vmap.map var
                                    Instances For

                                      Get the InstMap associated with a variable, or an empty InstMap.

                                      Equations
                                      • vmap.find var = (vmap.find? var).getD โˆ…
                                      Instances For
                                        def Aesop.VariableMap.modifyM {m : Type u_1 โ†’ Type u_2} {ฮฑ : Type u_1} [Monad m] (vmap : VariableMap) (var : PremiseIndex) (f : InstMap โ†’ m (InstMap ร— ฮฑ)) :
                                        m (VariableMap ร— ฮฑ)

                                        Modify the InstMap associated to variable var. If no such InstMap exists, the function f is applied to the empty InstMap and the result is associated with var. Returns the new variable map and the result of f.

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          def Aesop.VariableMap.modify {ฮฑ : Type u_1} (vmap : VariableMap) (var : PremiseIndex) (f : InstMap โ†’ InstMap ร— ฮฑ) :
                                          VariableMap ร— ฮฑ

                                          Modify the InstMap associated to variable var. If no such InstMap exists, the function f is applied to the empty InstMap and the result is associated with var. Returns the new variable map and the result of f.

                                          Equations
                                          Instances For
                                            def Aesop.VariableMap.addHyp (vmap : VariableMap) (slot : Slot) (hyp : Hyp) :
                                            BaseM (VariableMap ร— Bool)

                                            Add a hypothesis hyp. Precondition: hyp matches the premise of slot slot with substitution hyp.subst (and hence hyp.subst contains a mapping for each variable in slot.common). Returns true if the variable map changed.

                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For
                                              def Aesop.VariableMap.addMatch (vmap : VariableMap) (nextSlot : Slot) (m : Match) :
                                              BaseM (VariableMap ร— Bool)

                                              Add a match m. Precondition: nextSlot is the slot with index m.level + 1. Returns true if the variable map changed.

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                def Aesop.VariableMap.eraseHyp (vmap : VariableMap) (hyp : Lean.FVarId) (slot : SlotIndex) :

                                                Remove a hyp from slot and all later slots.

                                                Equations
                                                Instances For

                                                  Remove the pattern substitution subst from slot and all later slots.

                                                  Equations
                                                  Instances For
                                                    def Aesop.VariableMap.findMatches (vmap : VariableMap) (slot : Slot) (subst : Substitution) :
                                                    BaseM (Std.HashSet Match)

                                                    Find matches in slot slot - 1 whose substitutions are compatible with subst. Preconditions: slot.index is nonzero, slot.common is nonempty and each variable contained in slot.common is also contained in subst.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      def Aesop.VariableMap.findHyps (vmap : VariableMap) (slot : Slot) (subst : Substitution) :
                                                      BaseM (Std.HashSet Hyp)

                                                      Find hyps in slot whose substitutions are compatible with subst. Precondition: slot.common is nonempty and each variable contained in it is also contained in subst.

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

                                                        Extract stats from a VariableMap.

                                                        Equations
                                                        Instances For

                                                          Structure representing the state of a slot cluster. Updates are performed lazily: the enqueueRawHyp method enqueues a hyp or patten subst to be added to the state, and the update method must be used to actually make the corresponding changes and potentially generate new complete matches.

                                                          • slots : Array Slot

                                                            The cluster's slots.

                                                          • conclusionDeps : Array PremiseIndex

                                                            The premises that appear in the rule's conclusion. These are the same for all cluster states of a rule, but are stored here for convenience.

                                                          • variableMap : VariableMap

                                                            The variable map for this cluster.

                                                          • completeMatches : Lean.PHashSet Match

                                                            Complete matches for this cluster.

                                                          • haveHypForEachSlot : Bool

                                                            This flag is true if all slotQueues are potentially nonempty. Before that point, we do not add any hyps to the variable maps since the rule cannot possibly produce a complete match.

                                                          • slotQueues : Array (Array RawHyp)

                                                            Hypotheses or pattern substitutions that have been added to the cluster state, but have not yet been added to the variableMap.

                                                          • slotQueues_size : self.slotQueues.size = self.slots.size

                                                            There is exactly one queue for each slot.

                                                          Instances For
                                                            @[implicit_reducible]
                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            @[implicit_reducible]
                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            @[always_inline]

                                                            Get the slot with the given index. Panic if the index is invalid.

                                                            Equations
                                                            Instances For

                                                              Get the slot with the given premise index.

                                                              Equations
                                                              Instances For
                                                                def Aesop.ClusterState.matchPremise? (premises : Array Lean.MVarId) (lmvarIds : Array Lean.LMVarId) (cs : ClusterState) (slot : SlotIndex) (hyp : Lean.FVarId) :

                                                                Match hypothesis hyp against the slot with index slot in cs (which must be a valid index).

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

                                                                  Context for the AddM monad.

                                                                  • premiseMVars : Array Lean.MVarId

                                                                    Metavariables for the premises of the rule for which a hyp or match is being added. When adding hyps, they are unified with these metavariables.

                                                                  • premiseLMVars : Array Lean.LMVarId

                                                                    Metavariables for level parameters appearing in the rule's premises.

                                                                  Instances For
                                                                    @[reducible, inline]
                                                                    abbrev Aesop.ClusterState.AddM (ฮฑ : Type) :

                                                                    A monad for operations that add hyps or matches to a cluster state. The monad's state is an array of complete matches discovered while adding hyps/matches.

                                                                    Equations
                                                                    Instances For
                                                                      def Aesop.ClusterState.AddM.run {ฮฑ : Type} (premiseMVars : Array Lean.MVarId) (premiseLMVars : Array Lean.LMVarId) (x : AddM ฮฑ) :
                                                                      BaseM (ฮฑ ร— Array Match)

                                                                      Run an AddM action.

                                                                      Equations
                                                                      • Aesop.ClusterState.AddM.run premiseMVars premiseLMVars x = (ReaderT.run x { premiseMVars := premiseMVars, premiseLMVars := premiseLMVars }).run #[]
                                                                      Instances For

                                                                        Add a match to the cluster state.

                                                                        partial def Aesop.ClusterState.addHyp (cs : ClusterState) (slot : Slot) (h : Hyp) :

                                                                        Add a hypothesis to the cluster state. hyp.subst must be the substitution that results from applying h to slot.

                                                                        Add a hypothesis or pattern substitution to the cluster state.

                                                                        Insert the raw hyps from slot's queue into the variable map.

                                                                        Add a hypothesis or pattern substitution to the queue for its slot.

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

                                                                          Erase a RawHyp from the slot queue of the given slot.

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

                                                                            Erase a hypothesis from the cluster state's variable map.

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

                                                                              Erase a pattern substitution from the cluster state.

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

                                                                                Update a cluster change, adding any enqueued hypotheses. This may result in new complete matches.

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

                                                                                  Extract stats from a ClusterState.

                                                                                  Equations
                                                                                  Instances For

                                                                                    The source of a pattern substitution. The same substitution can have multiple sources.

                                                                                    • hyp (fvarId : Lean.FVarId) : PatSubstSource

                                                                                      The pattern substitution came from the given hypothesis.

                                                                                    • target : PatSubstSource

                                                                                      The pattern substitution came from the goal's target.

                                                                                    Instances For

                                                                                      Forward state for one rule. Updates are lazy: when adding a hyp or pattern subst to the rule, it is initially only enqueued in the cluster states. The update method must be called to actually make the corresponding changes, which result in new complete matches for the rule.

                                                                                      • The rule to which this state belongs.

                                                                                      • clusterStates : Array ClusterState

                                                                                        States for each of the rule's slot clusters.

                                                                                      • patSubstSources : Lean.PHashMap Substitution (Lean.PHashSet PatSubstSource)

                                                                                        The sources of all pattern substitutions present in the clusterStates. Invariant: each pattern substitution in the cluster states is associated with a nonempty set.

                                                                                      Instances For
                                                                                        Equations
                                                                                        Instances For
                                                                                          @[implicit_reducible]
                                                                                          instance Aesop.instToMessageDataRuleState :
                                                                                          Lean.ToMessageData RuleState
                                                                                          Equations
                                                                                          • One or more equations did not get rendered due to their size.

                                                                                          The initial (empty) rule state for a given forward rule.

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

                                                                                            Add a hypothesis or pattern substitution to the rule state. The hypothesis's type does not necessarily need to match the given premise. If it does not, this is detected by update and the hyp is not added.

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

                                                                                              Erase a pattern substitution that was obtained from the given source.

                                                                                              Equations
                                                                                              • One or more equations did not get rendered due to their size.
                                                                                              Instances For
                                                                                                def Aesop.RuleState.eraseHyp (h : Lean.FVarId) (pi : PremiseIndex) (rs : RuleState) :

                                                                                                Erase a hypothesis from the rule state.

                                                                                                Equations
                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                Instances For
                                                                                                  def Aesop.RuleState.update (goal : Lean.MVarId) (rs : RuleState) :

                                                                                                  Add any enqueued hyps to the rule state, potentially generating new complete matches in the process.

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

                                                                                                    Extract stats from a RuleState.

                                                                                                    Equations
                                                                                                    Instances For

                                                                                                      State representing the non-complete matches of a given set of forward rules in a given local context.

                                                                                                      • ruleStates : Lean.PHashMap RuleName RuleState

                                                                                                        Map from each rule's name to its RuleState

                                                                                                      • hyps : Lean.PHashMap Lean.FVarId (Lean.PArray (RuleName ร— PremiseIndex))

                                                                                                        A map from hypotheses to the rules and premises that they matched against when they were initially added to the rule state. Invariant: the rule states in which a hypothesis h appear are exactly those identified by the rule names in hyps[h]. Furthermore, h only appears in slots with premise indices greater than or equal to those in hyps[h].

                                                                                                      • patSubsts : Lean.PHashMap PatSubstSource (Lean.PArray (RuleName ร— Substitution))

                                                                                                        The pattern substitutions present in the rule states. Invariant: patSubsts maps the source s to a rule name r and pattern substitution i iff the rule state of r contains i with source s.

                                                                                                      Instances For
                                                                                                        Equations
                                                                                                        Instances For
                                                                                                          @[implicit_reducible]
                                                                                                          Equations
                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                          @[implicit_reducible]
                                                                                                          Equations
                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                          def Aesop.ForwardState.enqueueHyp (h : Lean.FVarId) (ms : Array (ForwardRule ร— PremiseIndex)) (fs : ForwardState) :

                                                                                                          Add a hypothesis to the forward state. If fs represents a local context lctx, then fs.addHyp h ms represents lctx with h added. ms must overapproximate the rules for which h may unify with a maximal premise.

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

                                                                                                            Add a pattern substitution to the forward state.

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

                                                                                                              Add multiple pattern substitutions to the forward state.

                                                                                                              Equations
                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                              Instances For
                                                                                                                def Aesop.ForwardState.enqueueHypWithPatSubsts (h : Lean.FVarId) (ms : Array (ForwardRule ร— PremiseIndex)) (patSubsts : Array (ForwardRule ร— Substitution)) (fs : ForwardState) :

                                                                                                                Add a hypothesis and to the forward state, along with any rule pattern substitutions obtained from it.

                                                                                                                Equations
                                                                                                                Instances For

                                                                                                                  Erase pattern substitutions with the given source.

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

                                                                                                                    Remove a hypothesis from the forward state. If fs represents a local context lctx, then fs.eraseHyp h represents lctx with h removed.

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

                                                                                                                      Update the pattern substitutions after the goal's target changed. goal is the new goal. newPatSubsts are the new target's pattern substitutions.

                                                                                                                      Equations
                                                                                                                      Instances For
                                                                                                                        def Aesop.ForwardState.update (goal : Lean.MVarId) (fs : ForwardState) (phase? : Option PhaseName) :

                                                                                                                        Update the forward state. This applies any previously enqueued changes to all rule states, potentially generating new complete matches in the process. If a phase is given, only rules from that phase are updated.

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

                                                                                                                          Extract stats from a ForwardState.

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