Process when an new equation is added to a congruence closure #
Update the acTodo
field of the state.
Equations
Instances For
Read the todo
field of the state.
Equations
Instances For
Read the acTodo
field of the state.
Equations
Instances For
Add a new entry to the end of the todo list.
See also pushEq
, pushHEq
and pushReflEq
.
Equations
Instances For
Record the instance e
and add it to the set of known defeq instances.
Equations
Instances For
Return the CongruencesKey
associated with an expression of the form f a
.
Equations
Instances For
Return the SymmCongruencesKey
associated with the equality lhs = rhs
.
Equations
Instances For
Auxiliary function for comparing lhs₁ ~ rhs₁
and lhs₂ ~ rhs₂
,
when ~
is symmetric/commutative.
It returns true
(equal) for a ~ b
b ~ a
.
Equations
Instances For
If the congruence table (congruences
field) has congruent expression to e
, add the
equality to the todo list. If not, add e
to the congruence table.
Equations
Instances For
If the symm congruence table (symmCongruences
field) has congruent expression to e
, add the
equality to the todo list. If not, add e
to the symm congruence table.
Equations
Instances For
Given subsingleton elements a
and b
which are not necessarily of the same type, if the
types of a
and b
are equivalent, add the (heterogeneous) equality proof between a
and b
to
the todo list.
Equations
Instances For
Given the equivalent expressions oldRoot
and newRoot
the root of oldRoot
is
newRoot
, if oldRoot
has root representative of subsingletons, try to push the equality proof
between their root representatives to the todo list, or update the root representative to
newRoot
.
Equations
Instances For
Remove fn
and expressions whose type isn't def-eq to fn
's type out from lambdas
,
return the remaining lambdas applied to the reversed arguments.
Equations
Instances For
Trace the state of AC module.
Equations
Instances For
Insert lhs
to the occurrences on an equality in acR
corresponding to the equality
lhs := rhs
.
Equations
Instances For
Erase lhs
to the occurrences on an equality in acR
corresponding to the equality
lhs := rhs
.
Equations
Instances For
Insert lhs
to the occurrences of arguments of e
on the right hand side of
an equality in acR
.
Equations
Instances For
Erase lhs
to the occurrences of arguments of e
on the right hand side of
an equality in acR
.
Equations
Instances For
Try to simplify the right hand sides of equalities in acR
by H : lhs = rhs
.
Equations
Instances For
Try to simplify the left hand sides of equalities in acR
by H : lhs = rhs
.
Equations
Instances For
Given ra := a*r
sb := b*s
ts := t*s
tr := t*r
tsEqa : t*s = a
trEqb : t*r = b
,
return a proof for ra = sb
.
We use a*b
to denote an AC application. That is, (a*b)*(c*a)
is the term a*a*b*c
.
Equations
Instances For
Given tsEqa : ts = a
, for each equality trEqb : tr = b
in acR
where
the intersection t
of ts
and tr
is nonempty, let ts = t*s
and tr := t*r
, add a new
equality r*a = s*b
.
Equations
Instances For
Process the tasks in the acTodo
field.
Equations
Instances For
Given AC variables e₁
and e₂
which are in the same equivalence class, add the proof of
e₁ = e₂
to the AC module.
Equations
Instances For
If the root expression of e
is AC variable, add equality to AC module. If not, register the
AC variable to the root entry.
Equations
Instances For
If e
isn't an AC variable, set e
as an new AC variable.
Equations
Instances For
Internalize e
so that the AC module can deal with the given expression.
If the expression does not contain an AC operator, or the parent expression
is already processed by internalizeAC
, this operation does nothing.
Equations
Instances For
The specialized internalizeCore
for applications or literals.
Propagate equality from a
and b
to a ↔ b
.
Equations
Instances For
Propagate equality from a
and b
to a ∧ b
.
Equations
Instances For
Propagate equality from a
and b
to a ∨ b
.
Equations
Instances For
Propagate equality from a
to ¬a
.
Equations
Instances For
Propagate equality from a
and b
to a → b
.
Propagate equality from p
, a
and b
to if p then a else b
.
Equations
Instances For
Propagate equality from a
and b
to disprove a = b
.
Equations
Instances For
Propagate equality from subexpressions of e
to e
.
This method is invoked during internalization and eagerly apply basic equivalences for term e
Examples:
In principle, we could mark theorems such as cast_eq
as simplification rules, but this created
problems with the builtin support for cast-introduction in the ematching module in Lean 3.
TODO: check if this is now possible in Lean 4.
Eagerly merging the equivalence classes is also more efficient.
If e
is a subsingleton element, push the equality proof between e
and its canonical form
to the todo list or register e
as the canonical form of itself.
Can we propagate equality from subexpressions of e
to e
?
Equations
Instances For
Remove parents of e
from the congruence table and the symm congruence table, and append
parents to propagate equality, to parentsToPropagate
.
Returns the new value of parentsToPropagate
.
Equations
Instances For
The fields target
and proof
in e
's entry are encoding a transitivity proof
Let e.rootTarget
and e.rootProof
denote these fields.
e = e.rootTarget := e.rootProof
_ = e.rootTarget.rootTarget := e.rootTarget.rootProof
...
_ = e.root := ...
The transitivity proof eventually reaches the root of the equivalence class.
This method "inverts" the proof. That is, the target
goes from e.root
to e after
we execute it.
Reinsert parents of e
to the congruence table and the symm congruence table.
Together with removeParents
, this allows modifying parents of an expression.
Equations
Instances For
Check for integrity of the CCStructure
.
Equations
Instances For
For each fnRoot
in fnRoots
traverse its parents, and look for a parent prefix that is
in the same equivalence class of the given lambdas.
remark All expressions in lambdas are in the same equivalence class
Equations
Instances For
Given c
a constructor application, if p
is a projection application (not .proj _ _ _
, but
.app (.const projName _) _
) such that major premise is
equal to c
, then propagate new equality.
Example: if p
is of the form b.fst
, c
is of the form (x, y)
, and b = c
, we add the
equality (x, y).fst = x
Equations
Instances For
Given a new equality e₁ = e₂
, where e₁
and e₂
are constructor applications.
Implement the following implications:
c a₁ ... aₙ = c b₁ ... bₙ => a₁ = b₁, ..., aₙ = bₙ
c₁ ... = c₂ ... => False
where c
, c₁
and c₂
are constructors
Equations
Instances For
Derive contradiction if we can get equality between different values.
Equations
Instances For
Propagate equality from ¬a
to a
.
Equations
Instances For
Propagate equality from ¬∃ x, p x
to ∀ x, ¬p x
.
Equations
Instances For
Propagate equality from e
to subexpressions of e
.
Equations
Instances For
The auxiliary definition for addEqvStep
to flip the input.
Equations
Instances For
Process the tasks in the todo
field.
Equations
Instances For
Internalize e
so that the congruence closure can deal with the given expression.
Equations
Instances For
Add proof : type
to the congruence closure.