Documentation

Lean.Meta.Tactic.Simp.Simproc

Builtin simproc declaration extension state.

It contains:

  • The discrimination tree keys for each simproc (including symbolic evaluation procedures) name.
  • The actual procedure associated with a name.
Instances For

    This global reference is populated using the command builtin_simproc_pattern%.

    This reference is then used to process the attributes builtin_simproc and builtin_sevalproc. Both attributes need the keys and the actual procedure registered using the command builtin_simproc_pattern%.

    Instances For
      Instances For
        Instances For
          Instances For

            Given a declaration name declName, store the discrimination tree keys and the actual procedure.

            This method is invoked by the command builtin_simproc_pattern% elaborator.

            Instances For
              Instances For
                Instances For
                  Instances For

                    Builtin symbolic evaluation procedures.

                    @[reducible, inline]
                    Instances For
                      @[implemented_by Lean.Meta.Simp.getSimprocFromDeclImpl]
                      Instances For
                        Instances For

                          Implements attributes builtin_simproc and builtin_sevalproc.

                          Instances For
                            Instances For
                              Instances For
                                def Lean.Meta.Simp.Simprocs.add (s : Simprocs) (declName : Name) (post : Bool) :
                                Instances For

                                  Applies s to e after peeling off numExtraArgs trailing arguments, and re-applies them to the result. This is how a simproc keyed on f a b fires on the over-application f a b c.

                                  numExtraArgs must be the number getMatchWithExtra returned for e itself; a number obtained for a different expression may exceed the number of arguments e has.

                                  Instances For

                                    Similar to try, but only consider DSimproc case. That is, if s.proc is a Simproc, treat it as a .continue.

                                    Instances For
                                      def Lean.Meta.Simp.simprocCore (post : Bool) (s : SimprocTree) (erased : PHashSet Name) (e : Expr) :

                                      Runs the applicable simprocs in s on e, and returns as soon as one of them rewrites e.

                                      We must not keep going with the remaining candidates: they were selected for e, and the number of extra arguments recorded for each of them only makes sense for e. The simplifier looks up candidates afresh when it revisits the rewritten expression.

                                      Instances For

                                        Similar to simprocCore, but for DSimprocs.

                                        Instances For
                                          @[reducible, inline]
                                          Instances For
                                            Instances For
                                              Instances For
                                                def Lean.Meta.Simp.mkSimprocExt (name : Name := by exact decl_name%) (ref? : Option (IO.Ref Simprocs)) :
                                                Instances For
                                                  def Lean.Meta.Simp.addSimprocAttr (attrName : Name) (ext : SimprocExtension) (declName : Name) (stx : Syntax) (attrKind : AttributeKind) :
                                                  Instances For
                                                    def Lean.Meta.Simp.mkSimprocAttr (attrName : Name) (attrDescr : String) (ext : SimprocExtension) (name : Name) :
                                                    Instances For
                                                      @[reducible, inline]
                                                      Instances For
                                                        def Lean.Meta.Simp.registerSimprocAttr (attrName : Name) (attrDescr : String) (ref? : Option (IO.Ref Simprocs)) (name : Name := by exact decl_name%) :
                                                        Instances For
                                                          def Lean.Meta.Simp.getSimprocExtension? (simprocAttrNameOrsimpAttrName : Name) :

                                                          Try to retrieve the simproc set using the simp or simproc attribute names. Recall that when we declare a simp set using register_simp_attr, an associated simproc set is automatically created. We use the function simpAttrNameToSimprocAttrName to find the simproc associated with the simp attribute.

                                                          Instances For