Documentation

Auto.Translation.Monomorphization

inductive Auto.MonoMode :
Instances For
    Equations
    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.
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Remark: This function assigns level mvars if necessary

        Equations
        Instances For

          If a constant c is of type ∀ (xs : αs), t, then its valid instance will be c with all of its universe levels, dependent arguments and instance arguments instantiated. So, we record the instantiation of universe levels and dependent arguments.

          As to monomorphization, we will not record instances of constants with instance attribute or whose type is a class.

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

            Remark: This function assigns metavariables if necessary, but its only usage in this file is under Meta.withNewMCtxDepth Note that since ci₁, ci₂ are both ConstInst, they does not contain loose bound variables

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

              Remark: · This function assigns metavariables if necessary · Runs in MetaM, so e should not have loose bound variables

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

                Given an hypothesis t, we will traverse the hypothesis and call ConstInst.ofExpr? to find instances of polymorphic constants

                · Binders of the hypothesis are introduced as fvars, these fvars are recorded in bvars

                · param records universe level parameters of the hypothesis

                So, the criterion that an expression e is a valid instance is that · All dependent arguments and instance arguments are present

                · The head does not contain expressions in bvars

                · Dependent arguments does not contains expressions in bvars

                · The expression does not contain level parameters in params

                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

                      Precondition : .some ci == ← ConstInst.ofExpr? e Returns the list of non-dependent arguments in e.getAppArgs

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

                        Array of instances of a polymorphic constant

                        Equations
                        Instances For

                          Given an array cis and a potentially new instance ci · If ci is new, add it to ConstInsts and return true · If ci is not new, return an element of the original ConstInsts which is definitionally equal to ci

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

                            Given a LemmaInst li and a ConstInst ci, try to match all subexpressions of li against ci

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

                              Test whether a lemma is type monomorphic && universe monomorphic By universe monomorphic we mean lem.params = #[] If all dependent arguments are instantiated, but some instance arguments are not instantiated, we will try to synthesize the instance arguments

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

                                Monomorphization works as follows:

                                (1) Turning Lemmas into LemmaInsts, which constitutes the value of lisArr in the beginning

                                (2) Scan through all assumptions to find subterms that are valid instances of constants (dependent arguments fully instantiated). They form the initial elements of ciMap and activeCi

                                (3) Repeat:

                                · Dequeue an element active

                                · If it is a ConstInst, match against all existing LemmaInst; If it is a LemmaInst, match against all existing ConstInst

                                · For all the new LemmaInsts generated and all the ConstInsts occurring in them to active

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

                                            Process a potentially new ConstInst. If it's new, return its index in the corresponding ConstInsts array. If it's not new, return .none.

                                            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

                                                          Monomorphization works as follows:

                                                          (1) Turning Lemmas into LemmaInsts, which constitutes the value of lisArr in the beginning

                                                          (2) Scan through all assumptions to find subterms that are valid instances of constants (dependent arguments fully instantiated). They form the initial elements of ciMap and activeCi

                                                          (3) Repeat:

                                                          · Dequeue an element active

                                                          · If it is a ConstInst, match against all existing LemmaInst; If it is a LemmaInst, match against all existing ConstInst

                                                          · For all the new LemmaInsts generated and all the ConstInsts occurring in them to active

                                                          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

                                                                    Remove non-monomorphic lemma instances

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

                                                                      Collect inductive types

                                                                      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

                                                                                      Similar to Monomorphization.processConstInst

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

                                                                                        Return : (reduce(e), whether reduce(e) contain bfvars)

                                                                                        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

                                                                                                  Attempt to abstract parts of a given expression to free variables so that the resulting expression is in the higher-order fragment of Lean.

                                                                                                  Note that it's not always possible to do this since it's possible that the given expression itself is polymorphic

                                                                                                  Since we're now dealing with monomorphized lemmas, there are no bound level parameters

                                                                                                  Return value:

                                                                                                  · If abstraction is successful, return the abstracted expression

                                                                                                  · If abstraction is not successful because the input is not a quasi higher-order

                                                                                                  term of type Prop, return a message indicating the violation of quasi higher-order-ness · Throw an error message if unexpected error happens

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

                                                                                                    Given mvarId : ty, create a fresh mvar m of type monofact₁ → monofact₂ → ⋯ → monofactₙ → ty and return (m proof₁ proof₂ ⋯ proofₙ, m)

                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For
                                                                                                      def Auto.Monomorphization.monomorphize {α : Type} (lemmas inhFacts : Array Lemma) (k : Reif.StateLean.MetaM α) :
                                                                                                      Equations
                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                      Instances For

                                                                                                        Instantiating quantifiers, collecting inductive types and filtering out non-quasi-monomorphic expressions

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

                                                                                                          Process lemmas and inductive types, collect inhabited types

                                                                                                          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