Documentation

Lean.Meta.Sym.Arith.Functions

Cached function expressions for arithmetic operators #

Synthesizes and caches the canonical Lean expressions for arithmetic operators (+, *, -, ^, intCast, natCast, etc.). These cached expressions are used during reification to validate instances via pointer equality (isSameExpr).

Each getter checks the cache field first. On a miss, it synthesizes the instance, verifies it against the expected instance from the ring structure using isDefEqI, canonicalizes the result via canonExpr, and stores it.

The pairs of instances that checkInst found definitionally equal, when both are closed and built from imported constants only. Each grind goal initializes the operators of its structures again.

The state is a reference created with the environment of the imports, so every declaration of the file and all its environment branches share it, while other files, whose imports may differ, have their own.

The gain is small: about 1.4% of the elaboration instructions of a lia benchmark with the Sym.simp normalizer, and nothing measurable on grind's ring benchmarks. Reevaluate whether this cache pays for its complexity.

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

                                    The embedding OfSemiring.toQ of the semiring into its envelope ring.

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

                                      The AddRightCancel instance of the semiring, if any. The result of the search is cached.

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