Calculemus


Eqelim Module

Equality elimination: Brand transform etc.

Table of contents

Brand's S- and T-modifications

Functions and values

Function or value Description

modify_S cl

Full Usage: modify_S cl

Parameters:
Returns: formula<fol> list list The list of all the clauses that arise from all the possible combinations of forward and backward positive equations in the original clause. If \(n\) is the number of positive equation in the input clause, \(2^n\) clauses are returned.

Applies Brand's S-modification to a clause.

It allows to eliminate the symmetry axiom of equality.

cl : formula<fol> list

The input clause.

Returns: formula<fol> list list

The list of all the clauses that arise from all the possible combinations of forward and backward positive equations in the original clause. If \(n\) is the number of positive equation in the input clause, \(2^n\) clauses are returned.

Example

 !!>["s1 = t1"; "s2 = t2"; "s3 = t3"; "~s1 = t1"; "~s2 = t2"]
 |> modify_S
 |> List.map (List.map sprint_fol_formula)
Multiple items
module List from Microsoft.FSharp.Collections

--------------------
type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ...
val map: mapping: ('T -> 'U) -> list: 'T list -> 'U list
Evaluates to
 [["`s1 = t1`"; "`s2 = t2`"; "`s3 = t3`"; "`~s1 = t1`"; "`~s2 = t2`"];
  ["`s1 = t1`"; "`s2 = t2`"; "`t3 = s3`"; "`~s1 = t1`"; "`~s2 = t2`"];
  ["`s1 = t1`"; "`s3 = t3`"; "`t2 = s2`"; "`~s1 = t1`"; "`~s2 = t2`"];
  ["`s1 = t1`"; "`t2 = s2`"; "`t3 = s3`"; "`~s1 = t1`"; "`~s2 = t2`"];
  ["`s2 = t2`"; "`s3 = t3`"; "`t1 = s1`"; "`~s1 = t1`"; "`~s2 = t2`"];
  ["`s2 = t2`"; "`t1 = s1`"; "`t3 = s3`"; "`~s1 = t1`"; "`~s2 = t2`"];
  ["`s3 = t3`"; "`t1 = s1`"; "`t2 = s2`"; "`~s1 = t1`"; "`~s2 = t2`"];
  ["`t1 = s1`"; "`t2 = s2`"; "`t3 = s3`"; "`~s1 = t1`"; "`~s2 = t2`"]]

modify_T cl

Full Usage: modify_T cl

Parameters:
Returns: formula<fol> list A new clause with all the negative equation untouched and each positive equation s = t replaced by ~t = w1 \/ s = w1 creating fresh new variables wi for each of them.

Applies Brand's T-modification to a clause.

It allows to eliminate the transitivity axiom of equality.

cl : formula<fol> list

The input clause.

Returns: formula<fol> list

A new clause with all the negative equation untouched and each positive equation s = t replaced by ~t = w1 \/ s = w1 creating fresh new variables wi for each of them.

Example

 !!>["s1 = t1"; "s2 = t2"; "s3 = t3"; "~s1 = t1"; "~s2 = t2"]
 |> modify_T
Evaluates to [`~t1 = w''`; `s1 = w''`; `~t2 = w'`; `s2 = w'`; `~t3 = w`; `s3 = w`; `~s1 = t1`; `~s2 = t2`].

Brand's E-modification

Functions and values

Function or value Description

emodify fvs cls

Full Usage: emodify fvs cls

Parameters:
    fvs : string list - The list of variable names to avoid.
    cls : formula<fol> list - The input clause.

Returns: formula<fol> list The list of clauses that represents the e-modification of the input clause.

E-modifies a clause avoiding the variables names indicated in the input list.

E-modification allows to eliminate the congruence axioms of equality. The function repeatedly pulls out non-variable immediate subterms \(t\) of function and predicate symbols (other than equality) using the following formulas, which are equivalences in the presence of the congruence and reflexivity axioms: \begin{align*} f (\ldots , t, \ldots) = s \ &\Leftrightarrow \ \forall w.\ t = w \Rightarrow f (\ldots , w, \ldots) = s, \\ s = f (\ldots , t, \ldots) \ &\Leftrightarrow \ \forall w.\ t = w \Rightarrow s = f (\ldots , w, \ldots), \\ P (\ldots , t, \ldots) \ &\Leftrightarrow \ \forall w.\ t = w \Rightarrow P(\ldots , w, \ldots). \end{align*}
The input and overall result are in clausal form.

fvs : string list

The list of variable names to avoid.

cls : formula<fol> list

The input clause.

Returns: formula<fol> list

The list of clauses that represents the e-modification of the input clause.

Example

 !!>["(x * y) * z = x * (y * z)"]
 |> emodify ["x";"y";"z"]
Evaluates to [`~y * z = w'`; `~x * y = w`; `w * z = x * w'`].

find_nestnonvar tm

Full Usage: find_nestnonvar tm

Parameters:
    tm : term - The input term.

Returns: term The first non-variable subterm of the input, if it exists.

Tries to find a nested non-variable subterm inside a term.

tm : term

The input term.

Returns: term

The first non-variable subterm of the input, if it exists.

Exception Thrown with message findnvsubt when the input term is just a variable.
KeyNotFoundException Thrown with message An index satisfying the predicate was not found in the collection. when the input is not a simple variable but there isn't any non-variable subterm.
Example

 !!!"f(0,1)"
 |> find_nestnonvar
Evaluates to ``0``.

Example

 !!!"x"
 |> find_nestnonvar
Throws System.Exception: findnvsubt.

Example

 !!!"f(x,y)"
 |> find_nestnonvar
Throws System.Collections.Generic.KeyNotFoundException: An index satisfying the predicate was not found in the collection.

find_nvsubterm fm

Full Usage: find_nvsubterm fm

Parameters:
Returns: term the first non-variable subterm, if it exists and the input formula is a literal. In case of equality the result must be a nested subterm, while for other predicate symbols it is any non-variable subterm.

Tries to find a non-variable term inside a formula.

fm : formula<fol>

The input formula.

Returns: term

the first non-variable subterm, if it exists and the input formula is a literal. In case of equality the result must be a nested subterm, while for other predicate symbols it is any non-variable subterm.

ArgumentException Thrown with message find_nvsubterm: not a literal (Parameter 'fm') when the input formula is not a literal.
Exception Thrown with message tryfind when there isn't any non-variable subterm in the formula.
Example

 !!"R(0,1)"
 |> find_nvsubterm
Evaluates to ``0``.

Example

 !!"~x = f(0)"
 |> find_nvsubterm
Evaluates to ``0``.

Example

 !!"~x = f(0) /\ P(x)"
 |> find_nvsubterm
Throws System.ArgumentException: find_nvsubterm: not a literal (Parameter 'fm')

Example

 !!"~x = f(y)"
 |> find_nvsubterm
Throws System.Exception: tryfind.

is_nonvar tm

Full Usage: is_nonvar tm

Parameters:
    tm : term - The input term.

Returns: bool true, if the input is a non-variable term; otherwise, false.

Checks if the input is a non-variable term.

tm : term

The input term.

Returns: bool

true, if the input is a non-variable term; otherwise, false.

Example

 !!!"f(x)"
 |> is_nonvar
Evaluates to true.

Example

 !!!"x"
 |> is_nonvar
Evaluates to false.

modify_E cls

Full Usage: modify_E cls

Parameters:
Returns: formula<fol> list The list of clauses that represents the e-modification of the input clause.

Brand's E-modification

E-modification allows to eliminate the congruence axioms of equality. The function repeatedly pulls out non-variable immediate subterms \(t\) of function and predicate symbols (other than equality) using the following formulas, which are equivalences in the presence of the congruence and reflexivity axioms: \begin{align*} f (\ldots , t, \ldots) = s \ &\Leftrightarrow \ \forall w.\ t = w \Rightarrow f (\ldots , w, \ldots) = s, \\ s = f (\ldots , t, \ldots) \ &\Leftrightarrow \ \forall w.\ t = w \Rightarrow s = f (\ldots , w, \ldots), \\ P (\ldots , t, \ldots) \ &\Leftrightarrow \ \forall w.\ t = w \Rightarrow P(\ldots , w, \ldots). \end{align*}
The input and overall result are in clausal form.

cls : formula<fol> list

The input clause.

Returns: formula<fol> list

The list of clauses that represents the e-modification of the input clause.

Example

 !!>["(x * y) * z = x * (y * z)"]
 |> modify_E
Evaluates to [`~y * z = w'`; `~x * y = w`; `w * z = x * w'`].

replace rfn fm

Full Usage: replace rfn fm

Parameters:
Returns: formula<fol> The formula with terms replaced based on the given substitution function.

Replaces terms in a formula based on the given substitution.

rfn : func<term, term>

The input substitution fpf.

fm : formula<fol>

The input formula.

Returns: formula<fol>

The formula with terms replaced based on the given substitution function.

Example

 !!"f(0,1) = 0"
 |> replace ((!!!"0" |-> !!!"1")undefined)
Evaluates to ``f(1,1) = 1``.

replacet rfn tm

Full Usage: replacet rfn tm

Parameters:
    rfn : func<term, term> - The input substitution fpf.
    tm : term - The input term.

Returns: term The term with subterms replaced based on the given substitution function.

Replaces subterms in a term based on the given substitution.

rfn : func<term, term>

The input substitution fpf.

tm : term

The input term.

Returns: term

The term with subterms replaced based on the given substitution function.

Example

 !!!"f(0,1)"
 |> replacet ((!!!"0" |-> !!!"1")undefined)
Evaluates to ``f(1,1)``.

Overall Brand transformation

Functions and values

Function or value Description

bmeson fm

Full Usage: bmeson fm

Parameters:
Returns: int list the list of depth limits reached trying to refute the subproblems, if the formula is valid after applying Brand's transformation on equations.

Tests the validity of a formula by negating it and splitting in subproblems to be refuted by the MESON procedure with Brand's transformations incorporated.

fm : formula<fol>

The input formula.

Returns: int list

the list of depth limits reached trying to refute the subproblems, if the formula is valid after applying Brand's transformation on equations.

Note

Prints the depth limits tried to the stdout. Crashes if the input formula is not unsatisfiable.

Example

 !! @"(forall x y z. x * (y * z) = (x * y) * z) /\
 (forall x. e * x = x) /\
 (forall x. i(x) * x = e)
 ==> forall x. x * i(x) = e"
 |> bmeson
Evaluates to [19] and prints to the stdout:
 Searching with depth limit 0
 Searching with depth limit 1
 Searching with depth limit 2
 ...
 Searching with depth limit 15
 Searching with depth limit 16
 Searching with depth limit 17
 Searching with depth limit 18
 Searching with depth limit 19

bpuremeson fm

Full Usage: bpuremeson fm

Parameters:
Returns: int the number of depth limit reached trying refuting the formula with MESON, if the input formula is unsatisfiable after applying Brand's transformation on equations and a refutation could be found.

Tests the unsatisfiability of a formula using the MESON procedure with Brand's transformations incorporated.

fm : formula<fol>

The input formula.

Returns: int

the number of depth limit reached trying refuting the formula with MESON, if the input formula is unsatisfiable after applying Brand's transformation on equations and a refutation could be found.

Note

Prints the depth limits tried to the stdout. Crashes if the input formula is not unsatisfiable.

Example

 !!"~ x = x"
 |> bpuremeson
Evaluates to 1 and prints to the stdout:
 Searching with depth limit 0
 Searching with depth limit 1

brand cls

Full Usage: brand cls

Parameters:
    cls : formula<fol> list list - The input set of clauses.

Returns: formula<fol> list list The input clauses E- S- and T-modified plus the reflexive clause x = x.

Applies E-modification, then S-modification and T-modification; finally it includes the reflexive clause x = x.

cls : formula<fol> list list

The input set of clauses.

Returns: formula<fol> list list

The input clauses E- S- and T-modified plus the reflexive clause x = x.

Example

 !!>>[["x = f(0)"]]
 |> brand
Evaluates to [[`x = x`]; [`~f(w) = w'`; `x = w'`; `~0 = w`]; [`~x = w'`; `f(w) = w'`; `~0 = w`]].

emeson fm

Full Usage: emeson fm

Parameters:
Returns: int list the list of depth limits reached trying to refute the subproblems, if the formula is valid in presence of the equality axioms.

MESON procedure with equality axioms (see Equal) incorporated.

fm : formula<fol>

The input formula.

Returns: int list

the list of depth limits reached trying to refute the subproblems, if the formula is valid in presence of the equality axioms.

Note

Prints the depth limits tried to the stdout. Crashes if the input formula is not unsatisfiable.

Example

 !! @"(forall x. f(x) ==> g(x)) /\
 (exists x. f(x)) /\
 (forall x y. g(x) /\ g(y) ==> x = y)
 ==> forall y. g(y) ==> f(y)"
 |> emeson
Evaluates to [6] and prints to the stdout:
 Searching with depth limit 0
 Searching with depth limit 1
 Searching with depth limit 2
 Searching with depth limit 3
 Searching with depth limit 4
 Searching with depth limit 5
 Searching with depth limit 6