Documentation

Blaster.Optimize.Rewriting.OptimizeEq

Return some true if op1 and op2 are constructors that are structurally equivalent modulo variable name/function equivalence Return some false if op1 and op2 are constructors that are NOT structurally equivalent. Return none otherwise. Assume that memoization is performed on expressions.

update the lattice for application arguments such that:

  • some true corresponds to the bottom element
  • some false corresponds to the top element (the identity element)
  • some none the middle element The join rules applied on update are the following:
  • some true, some false ==> some false
  • none, some false ==> some false
  • some false, some false ==> some false
  • some true, none ==> none
  • none, none ==> none
  • some true, some true ==> some true
Equations
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

                  Given op1 and op2 corresponding to the operands for Eq:

                  • return some False when op1 := N + e ∧ op2 := e ∧ N ≠ 0 ∧ Type(N) = Int
                  • return some False when op1 := a + b ∧ op2 := a ∧ Type(a) = Int ∧ nonZeroIntInHyps b
                  • return some False when op1 := b + a ∧ op2 := a ∧ Type(a) = Int ∧ nonZeroIntInHyps b Otherwise none.
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    Given op1 and op2 corresponding to the operands for Eq:

                    • return some False when op1 := N + e ∧ op2 := e ∧ N ≠ 0 ∧ Type(N) = Nat
                    • return some False when op1 := a + b ∧ op2 := a ∧ Type(a) = Nat ∧ nonZeroNatInHyps b
                    • return some False when op1 := b + a ∧ op2 := a ∧ Type(a) = Nat ∧ nonZeroNatInHyps b Otherwise none.
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      Given op1 and op2 corresponding to the operands for Eq:

                      • return some False when op1 := N1 ∧ op2 := N2 + a ∧ N1 < N2 ∧ Type(a) = Nat:
                      • return some N1 "-" N2 = a when op1 := N1 ∧ op2 := N2 + a ∧ N1 ≥ N2 ∧ Type(a) = Nat:
                      • return some N1 "-" min(N1, N2) + a = N2 "-" min(N1, N2) + b when op1 := N1 + a ∧ op2 := N2 + b ∧ Type(a) = Nat: Otherwise none.
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Given op1 and op2 corresponding to the operands for Eq:

                        • return some N1 "-" N2 = a when op1 := N1 ∧ op2 := N2 + a ∧ Type(a) = Int:
                        • return some N1 "-" min(N1, N2) + a = N2 "-" min(N1, N2) + b when op1 := N1 + a ∧ op2 := N2 + b ∧ Type(a) = Int: Otherwise none.
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          Apply the following simplification/normalization rules on Eq :

                          • N + e = e | e = N + e ==> False (if Type(e) ∈ [Nat, Int])
                          • a + b = a | a = a + b | b + a = a | a = b + a ==> False (if Type(a) ∈ [Nat, Int] ∧ nonZeroInHyps b)
                          • N2 = N1 + a ==> False (if Type(a) = Nat) ∧ N2 < N1)
                          • N2 = N1 + a ==> N2 "-" N1 = a (if Type(a) = Nat) if N2 ≥ N1) (restart)
                          • N2 = N1 + a ===> N2 "-" N1 = a (if Type(a) = Int) (restart)
                          • N1 + a = N2 + b ==> N1 "-" min(N1, N2) + a = N2 "-" min(N1, N2) + b (if Type(a) ∈ [Nat, Int]) with: nonZeroInHyps x := nonZeroNatInHyps x If Type(x) = Nat := nonZeroIntInHyps x Otherwise
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            Apply the following simplification/normalization rules on Eq :

                            • False = e ==> ¬ e
                            • True = e ==> e
                            • e = ¬ e ==> False
                            • e = not e ==> False
                            • e1 = e2 ==> True (if e1 =ₚₜᵣ e2)
                            • e1 = e2 ==> False (if structEq? e1 e2 = some false) (NOTE: some true case already handled by =ₚₜᵣ)
                            • true = not e ==> false = e
                            • false = not e ==> true = e
                            • ¬ e1 = ¬ e2 ==> e1 = e2 (require classical)
                            • not e1 = not e2 ==> e1 = e2
                            • 0 = (-e) ==> 0 = e (if Type(e) = Int)
                            • -e1 = -e2 ==> e1 = e2 (if Type(e1) = Int)
                            • 0 = x * y ==> False (if Type(x) ∈ [Nat, Int] ∧ nonZeroInHyps x ∧ nonZeroInHyps y)
                            • e1 = e2 ==> r (if some r ← arithEq? e1 e2)
                            • x + y = x + z | y + x = x + z | x + y = z + x | y + x = z + x ==> y = z (if Type(x) ∈ [Nat, Int]]
                            • x * y = x * z | y * x = x * z | x * y = z * x | y * x = z * x ==> y = z (if Type(x) ∈ [Nat, Int] ∧ nonZeroInHyps x]
                            • e1 = e2 ==> e2 = e1 (if e2 <ₒ e1) with: nonZeroInHyps x := nonZeroNatInHyps x If Type(x) = Nat := nonZeroIntInHyps x Otherwise Assume that f = Expr.const ``Eq. Do nothing if operator is partially applied (i.e., args.size < 3)

                            TODO: consider additional simplification rules TODO: seperate rewriting that require classical reasoning from others. TODO: add an option to activate/deactivate classical simplification (same for optimizeProp).

                            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

                                Apply the following simplification/normalization rules on BEq.beq :

                                • false == e ==> not e
                                • true == e ==> e
                                • e == not e ==> false
                                • e1 == e2 ==> true (if e1 =ₚₜᵣ e2)
                                • e1 = e2 ==> false (if structEq? e1 e2 = some false) (NOTE: some true case already handled by =ₚₜᵣ)
                                • not e1 == not e2 ==> e1 == e2
                                • e1 == e2 ==> e2 == e1 (if e2 <ₒ e1)

                                Assume that f = Expr.const ``BEq.beq. This function simply returns the function application when:

                                • `BEq.beq is partially applied (i.e., args.size < 4)
                                • isOpaqueRelational f.constName args is not satisfied.

                                NOTE: The above simplification rules are applied only on BEq.beq satisfiying isOpaqueRelational predicate. In fact, we can't assume that BEq.beq will properly be defined for user-defined types or parametric inductive types.

                                NOTE: BEq.beq is expected to be unfolded if isOpaqueRelational predicate is not satisfied. However, class constraint [BEq α] for which there is no defined instance the unfolding will not be performed (see getUnfoldFunDef?).

                                TODO: consider additional simplification rules

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

                                  Given op1 and op2 corresponding to the operands for BEq.beq, return some e1 == e2 when op1 := not e1 ∧ op2 := not e2. Otherwise 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