Sets
Simplification#
This module implements deep simplification through the generation and propagation of internal representations during recursion. It is an adaptation of the standard simplifier from [DolzmannSturm-1997] tailored to the specific requirements of Sets.
Internal Representations#
- class logic1.theories.Sets.simplify.InternalRepresentation[source]#
Bases:
InternalRepresentation[AtomicFormula,Variable,Variable,Never]Implements the abstract methods
add(),extract(), andnext_()of it super classabc.simplify.InternalRepresentation. Required bySets.simplify.Simplifyfor instantiating the type variableabc.simplify.ρofabc.simplify.Simplify.
Simplification and Validity#
- class logic1.theories.Sets.simplify.Simplify[source]#
Bases:
Simplify[AtomicFormula,Variable,Variable,Never,InternalRepresentation,Options]Deep simplification in the style of [DolzmannSturm-1997]. Implements the abstract methods
create_initial_representationandsimpl_atof its super classabc.simplify.Simplify.The simplifier should be called via
simplify(), as described below. In addition, this class inheritsabc.simplify.Simplify.is_valid(), which should be called viais_valid(), as described below.
User Interface#
- logic1.theories.Sets.simplify.simplify(f: Formula[AtomicFormula, Variable, Variable, Never], assume: Iterable[AtomicFormula] = []) Formula[AtomicFormula, Variable, Variable, Never][source]#
An example
>>> from logic1.firstorder import * >>> from logic1.theories.Sets import * >>> a, b, c, d = VV.get('a', 'b', 'c', 'd') >>> simplify(And(a == b, b == c, c == d, d == c), assume=[a == b]) And(a == c, a == d)
- logic1.theories.Sets.simplify.is_valid(f: Formula[AtomicFormula, Variable, Variable, Never], assume: Iterable[AtomicFormula] = []) bool | None[source]#
Some examples
>>> from logic1.firstorder import * >>> from logic1.theories.Sets import * >>> a, b, c, d = VV.get('a', 'b', 'c', 'd')
>>> is_valid(a == d, assume=[a == b, b == c, c == d]) True
>>> is_valid(a == d, assume=[a == b, b != c, c == d]) False
>>> is_valid(a == d, assume=[a != b, b != c, c != d]) # Returns None