Documentation

Duper.Expr

@[reducible, inline]

Positions in an expression: Counting argument numbers from the right e.g. a is at #[1] and b is at #[0] in f a b. If the head is an implication (an expression of the form ∀ _ : p, q where p and q have type Prop) then we treat p and q as arguments passed to a hypothetical implication symbol.

Equations
Instances For
    @[inline]

    Return true iff e contains an mvar which satisfies p. This is adapted from Lean.Expr.hasAnyFVar

    Equations
    Instances For

      This should be used in place of Lean.Expr.isMVar so that mvars surrounded by mdata are not missed.

      Equations
      Instances For

        Same as Lean.Expr.getAppRevArgs but if the head is an implication (an expression of the form ∀ _ : p, q where p and q have type Prop), then it pretends the head has the form .app (.app impSymbol p) q

        Equations
        Instances For

          Same as Lean.Expr.getAppArgs but if the head is an implication (an expression of the form ∀ _ : p, q where p and q have type Prop), then it pretends the head has the form .app (.app impSymbol p) q

          Equations
          Instances For

            Note: This function assumes that if the head is a forallE expression and the index given indicates either the type or body of the forallE expression, then the head is actually an implication (in other words, this function does not check whether the head a valid implication as opposed to an arbitrary forallE expression)

            Equations
            Instances For
              partial def Lean.Expr.foldGreenM {m : TypeType u_1} {β : Type} [Monad m] [MonadLiftT MetaM m] (f : βExprDuper.ExprPosm β) (init : β) (e : Expr) (pos : Duper.ExprPos := Duper.ExprPos.empty) :
              optParam (Inhabited β) { default := init }m β
              def Lean.Expr.getAtPos! {m : TypeType u_1} [Monad m] [MonadLiftT MetaM m] (e : Expr) (pos : Duper.ExprPos) :
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def Lean.Expr.getAtPos? {m : TypeType u_1} [Monad m] [MonadLiftT MetaM m] (e : Expr) (pos : Duper.ExprPos) :

                Returns the expression in e indiced by pos if it exists, and returns none if pos does not point to a valid subexpression in e

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  def Lean.Expr.getAtUntypedPos {m : TypeType u_1} [Monad m] [MonadLiftT MetaM m] (e : Expr) (pos : Duper.ExprPos) :

                  "Untyped" positions are positions on potentially ill-typed expressions produced by the ⌊e⌋ function described in https://matryoshka-project.github.io/pubs/hounif_article.pdf and implemented in Fingerprint.lean's transformToUntypedFirstOrderTerm. Untyped positions are not intended to be consistent with ordinary expression positions, both because of the transformations performed by the ⌊e⌋ function, and because we cannot distinguish implications from arbitrary forallE expressions in potentially ill-typed expressions. Consequently, this function should only be used internally by Fingerprint.lean.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    partial def Lean.Expr.canInstantiateToGetAtPos {m : TypeType u_1} [Monad m] [MonadLiftT MetaM m] (e : Expr) (pos : Duper.ExprPos) (startIndex : Nat := 0) :

                    Returns true if either the subexpression indiced by pos exists in e, or if it may be possible to instantiate metavariables in e in such a way that the subexpression indiced by pos would exist.

                    For example, if e = "f 2 ?m.0", then canInstantiateToGetAtPos would return true for pos #[0, 1] (becuase "?m.0" could be instantiated as an application) but would return false for pos #[1, 1] (because 2 does not and can not have any arguments)

                    partial def Lean.Expr.canInstantiateToGetAtUntypedPos (e : Expr) (pos : Duper.ExprPos) (startIndex : Nat := 0) :
                    def Lean.Expr.replaceAtPos? {m : TypeType u_1} [Monad m] [MonadLiftT MetaM m] (e : Expr) (pos : Duper.ExprPos) (replacement : Expr) :

                    Attempts to put replacement at pos in e. Returns some res if successful, and returns none otherwise

                    Equations
                    Instances For
                      def Lean.Expr.replaceAtPos! {m : TypeType} [Monad m] [MonadLiftT MetaM m] [MonadError m] (e : Expr) (pos : Duper.ExprPos) (replacement : Expr) :

                      Attempts to put replacement at pos in e. Returns the result if successful and throws and error otherwise

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        def Lean.Expr.replaceGreenWithPos {m : TypeType u_1} [Monad m] [MonadLiftT MetaM m] (t₁ t₂ e : Expr) :
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          partial def Lean.Expr.replaceWithPos (t₁ t₂ e : Expr) :

                          This function acts as Meta.kabstract except that it takes an ExprPos rather than Occurrences and expects the given expression to consist only of applications up to the given ExprPos. Additionally, since the exact ExprPos is given, we don't need to pass in Meta.kabstract's second argument p

                          Equations
                          Instances For
                            Equations
                            Instances For
                              Equations
                              Instances For

                                Returns true iff e1 and e2 are identical except potentially at position p. Returns false if p is not a valid position for either e1 or e2.

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

                                  Returns true iff e is a fully applied logical symbol. The set of symbols we consider to be logical symbols are: ∧, ∨, →, ↔, ¬, True, False, ∀, ∃, =, and ≠

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