Documentation

Blaster.Optimize.Rewriting.OptimizeInt

Apply the following simplification/normalization rules on Int.neg :

    • (N) ==> "-" N
    • (- n) ==> n Assume that f = Expr.const ``Int.neg. An error is triggered if args.size ≠ 1 (i.e., only fully applied Int.neg expected at this stage) TODO: consider additional simplification rules
Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Apply the following simplification/normalization rules on Int.add :

    • 0 + n ==> n
    • N1 + N2 ==> N1 "+" N2
    • N1 + (N2 + n) ==> (N1 "+" N2) + n
    • N1 + -(N2 + n) ==> (N1 "-" N2) + -n
    • n1 + (-n2) ==> 0 if (if n1 =ₚₜᵣ n2)
    • n1 + n2 ==> n2 + n1 (if n2 <ₒ n1) Assume that f = Expr.const ``Int.add. An error is triggered when args.size ≠ 2 (i.e., only fully applied Int.add expected at this stage)
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[inline]
      Equations
      Instances For

        Apply the following simplification/normalization rules on Int.mul :

        • 0 * n ==> 0
        • 1 * n ==> n
        • -1 * n ==> -n
        • N1 * N2 ==> N1 "*" N2
        • N1 * (N2 * n) ==> (N1 "*" N2) * n
        • n1 * n2 ==> n2 * n1 (if n2 <ₒ n1) Assume that f = Expr.const ``Int.mul. An error is triggered when args.size ≠ 2 (i.e., only fully applied Int.mul expected at this stage)
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[inline]

          Given e1 and e2 corresponding to the operands for Int.ediv, Int.tdiv and Int.fdiv, return some 1 only when the following conditions are satisfied:

          • e1 =ₚₜᵣ e2 ∧
          • 0 < e1 := _ ∈ hypothesisContext.hypothesisMap ∨ e1 < 0 := _ ∈ hypothesisContext.hypothesisMap ∨ ¬ (0 = e1) := _ ∈ hypothesisContext.hypothesisMap Otherwise, return none.
          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            @[inline]

            Given e1 and e2 corresponding to the operands for Int.ediv, Int.tdiv and Int.fdiv, return some n only when one of the following conditions is satisfied:

            • e1 := m * n ∧ e2 = m ∧ ( 0 < m := _ ∈ hypothesisContext.hypothesisMap ∨ m < 0 := _ ∈ hypothesisContext.hypothesisMap ∨ ¬ (0 = m) := _ ∈ hypothesisContext.hypothesisMap ); or
            • e1 := n * m ∧ e2 = m ∧ ( 0 < m := _ ∈ hypothesisContext.hypothesisMap ∨ m < 0 := _ ∈ hypothesisContext.hypothesisMap ∨ ¬ (0 = m) := _ ∈ hypothesisContext.hypothesisMap ); Otherwise, return none.
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              @[inline]

              Given op1 and op2 corresponding to the operands for Int.ediv, Int.tdiv and Int.fdiv, try to apply the following simplification rules:

              • n / 0 ==> 0
              • n / 1 ==> n
              • 0 / n ==> 0
              • N1 / N2 ==> N1 "/" N2
              • n / n ==> 1 (if 0 < n := _ ∈ hypothesisContext.hypothesisMap ∨ ¬ (0 = n) := _ ∈ hypothesisContext.hypothesisMap ∨ n < 0 := _ ∈ hypothesisContext.hypothesisMap )
              • (m * n) / m | (n * m) / m ==> n (if 0 < m := _ ∈ hypothesisContext.hypothesisMap ∨ ¬ (0 = m) := _ ∈ hypothesisContext.hypothesisMap ∨ m < 0 := _ ∈ hypothesisContext.hypothesisMap)
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[inline]
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Apply the following simplification/normalization rules on Int.ediv:

                  • n / 0 ==> 0
                  • n / 1 ==> n
                  • 0 / n ==> 0
                  • N1 / N2 ==> N1 "/ₑ" N2
                  • n / n ==> 1 (if 0 < n := _ ∈ hypothesisContext.hypothesisMap ∨ ¬ (0 = n) := _ ∈ hypothesisContext.hypothesisMap ∨ n < 0 := _ ∈ hypothesisContext.hypothesisMap )
                  • (m * n) / m | (n * m) / m ==> n (if 0 < m := _ ∈ hypothesisContext.hypothesisMap ∨ ¬ (0 = m) := _ ∈ hypothesisContext.hypothesisMap ∨ m < 0 := _ ∈ hypothesisContext.hypothesisMap)
                  • (N1 * n) / N2 ===> ((N1 "/" Int.gcd N1 N2) * n) / (N2 "/ₑ" Int.gcd N1 N2) (if N2 ≠ 0 ∧ Int.gcd N1 N2 ≠ 1) Assume that f = Expr.const ``Int.ediv. An error is triggered when args.size ≠ 2 (i.e., only fully applied Int.ediv expected at this stage)
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    @[inline]

                    Given e1 and e2 corresponding to the operands for Int.emod, Int.fmod and Int.tmod, return some 0 only when one of the following conditions is satisfied:

                    • e1 =ₚₜᵣ e2; or
                    • e1 := m * n ∧ e2 = m; or
                    • e1 := n * m ∧ e2 = m; Otherwise, return none.
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      @[inline]

                      Given op1 and op2 corresponding to the operands for Int.emod, Int.fmod and Int.tmod, try to apply the following simplification rules:

                      • n % 0 ==> n
                      • n % 1 ==> 0
                      • 0 % n ==> 0
                      • N1 % N2 ==> N1 "%" N2
                      • (N1 * n) % N2 ==> 0 (if N1 % N2 = 0)
                      • n1 % n2 ==> 0 (if n1 =ₚₜᵣ n2)
                      • (m * n) % m | (n * m) % m ==> 0
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        @[inline]
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          Apply the following simplification/normalization rules on Int.emod :

                          • n % 0 ==> n
                          • n % 1 ==> 0
                          • 0 % n ==> 0
                          • N1 % N2 ==> N1 "%" N2
                          • (N1 * n) % N2 ==> 0 (if N1 % N2 = 0)
                          • n1 % n2 ==> 0 (if n1 =ₚₜᵣ n2)
                          • (m * n) % m | (n * m) % m ==> 0 Assume that f = Expr.const ``Int.emod. An error is triggered when args.size ≠ 2 (i.e., only fully applied Int.emod expected at this stage)
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            Apply the following simplification/normalization rules on Int.tdiv:

                            • n / 0 ==> 0
                            • n / 1 ==> n
                            • 0 / n ==> 0
                            • N1 / N2 ==> N1 "/" N2
                            • n / n ==> 1 (if 0 < n := _ ∈ hypothesisContext.hypothesisMap ∨ ¬ (0 = n) := _ ∈ hypothesisContext.hypothesisMap ∨ n < 0 := _ ∈ hypothesisContext.hypothesisMap )
                            • (m * n) / m | (n * m) / m ==> n (if 0 < m := _ ∈ hypothesisContext.hypothesisMap ∨ ¬ (0 = m) := _ ∈ hypothesisContext.hypothesisMap ∨ m < 0 := _ ∈ hypothesisContext.hypothesisMap)
                            • (n / N1) / N2 ==> n / (N1 "*" N2) (only valid for Int.tdiv)
                            • (N1 * n) / N2 ===> ((N1 "/" Int.gcd N1 N2) * n) / (N2 "/" Int.gcd N1 N2) (if N2 ≠ 0 ∧ Int.gcd N1 N2 ≠ 1) Assume that f = Expr.const ``Int.tdiv. An error is triggered when args.size ≠ 2 (i.e., only fully applied Int.tdiv expected at this stage)
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              @[inline]
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                Apply the following simplification/normalization rules on Int.tmod :

                                • n % 0 ==> n
                                • n % 1 ==> 0
                                • 0 % n ==> 0
                                • N1 % N2 ==> N1 "%" N2
                                • (N1 * n) % N2 ==> 0 (if N1 % N2 = 0)
                                • n1 % n2 ==> 0 (if n1 =ₚₜᵣ n2)
                                • (m * n) % m | (n * m) % m ==> 0 Assume that f = Expr.const ``Int.tmod. An error is triggered when args.size ≠ 2 (i.e., only fully applied Int.tmod expected at this stage)
                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  Apply the following simplification/normalization rules on Int.fdiv:

                                  • n / 0 ==> 0
                                  • n / 1 ==> n
                                  • 0 / n ==> 0
                                  • N1 / N2 ==> N1 "/" N2
                                  • n / n ==> 1 (if 0 < n := _ ∈ hypothesisContext.hypothesisMap ∨ ¬ (0 = n) := _ ∈ hypothesisContext.hypothesisMap ∨ n < 0 := _ ∈ hypothesisContext.hypothesisMap )
                                  • (m * n) / m | (n * m) / m ==> n (if 0 < m := _ ∈ hypothesisContext.hypothesisMap ∨ ¬ (0 = m) := _ ∈ hypothesisContext.hypothesisMap ∨ m < 0 := _ ∈ hypothesisContext.hypothesisMap)
                                  • (N1 * n) / N2 ===> ((N1 "/" Int.gcd N1 N2) * n) / (N2 "/" Int.gcd N1 N2) (if N2 ≠ 0 ∧ Int.gcd N1 N2 ≠ 1) Assume that f = Expr.const ``Int.fdiv. An error is triggered when args.size ≠ 2 (i.e., only fully applied Int.fdiv expected at this stage)
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For

                                    Apply the following simplification/normalization rules on Int.fmod :

                                    • n % 0 ==> n
                                    • n % 1 ==> 0
                                    • 0 % n ==> 0
                                    • N1 % N2 ==> N1 "%" N2
                                    • (N1 * n) % N2 ==> 0 (if N1 % N2 = 0)
                                    • n1 % n2 ==> 0 (if n1 =ₚₜᵣ n2)
                                    • (m * n) % m | (n * m) % m ==> 0 Assume that f = Expr.const ``Int.fmod. An error is triggered when args.size ≠ 2 (i.e., only fully applied Int.fmod expected at this stage)
                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      @[inline]

                                      Return some e if n := Int.neg (Int.ofNat e). Otherwise return none.

                                      Equations
                                      Instances For

                                        Apply the following simplification rules on Int.toNat :

                                        • Int.toNat N1 ===> "Int.toNat" N1
                                        • Int.toNat (Int.ofNat e) ===> e
                                        • Int.toNat (Int.neg (Int.ofNat e)) ===> 0 Assume that f = Expr.const ``Int.toNat. An error is triggered if args.size ≠ 1.
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For

                                          Normalize Int.negSucc n to Int.neg (Int.ofNat (1 + n)) only when n is not a constant value. An error is triggered if args.size ≠ 1. Assume that f = Expr.const ``Int.negSucc. NOTE: This rule is still required here to avoid normalizationg Int.negSucc when n is a constant value. #

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

                                            Apply simplification/normalization rules on Int operators.

                                            Equations
                                            Instances For