mirror of
https://github.com/Brandon-Rozek/matmod.git
synced 2025-12-09 04:30:24 +00:00
Futile attempts at improving average runtime
This commit is contained in:
parent
872e54ec5e
commit
0a894388a0
1 changed files with 37 additions and 13 deletions
50
vsp.py
50
vsp.py
|
|
@ -44,35 +44,59 @@ def has_vsp(model: Model, impfunction: ModelFunction,
|
||||||
bottom = model.ordering.bottom()
|
bottom = model.ordering.bottom()
|
||||||
|
|
||||||
C: Dict[ModelValue, Set[ModelValue]] = {}
|
C: Dict[ModelValue, Set[ModelValue]] = {}
|
||||||
U: Dict[ModelValue, Set[ModelValue]] = {}
|
|
||||||
|
|
||||||
for d in model.designated_values:
|
|
||||||
C[d] = model_closure({d,}, model.logical_operations, None)
|
|
||||||
U[d] = {y for y in model.designated_values if impfunction(d, y) in model.designated_values}
|
|
||||||
|
|
||||||
for x in model.designated_values:
|
for x in model.designated_values:
|
||||||
|
|
||||||
|
# Discard ({⊥} ∪ A', B) subalgebras
|
||||||
|
if bottom is not None and x == bottom:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Discard ({⊤} ∪ A', B) subalgebras when negation is defined
|
||||||
|
if top is not None and negation_defined and x == top:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if x not in C:
|
||||||
|
C[x] = model_closure({x,}, model.logical_operations, None)
|
||||||
Xs = C[x]
|
Xs = C[x]
|
||||||
|
|
||||||
# Discard ({⊥} ∪ A', B) subalgebras
|
# Discard ({⊥} ∪ A', B) subalgebras
|
||||||
if bottom is not None and bottom in Xs:
|
if bottom is not None and bottom in Xs:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Discard ({⊤} ∪ A', B) subalgebras when negation is defined
|
# Discard ({⊤} ∪ A', B) subalgebras when negation is defined
|
||||||
if top is not None and negation_defined and top in Xs:
|
if top is not None and negation_defined and top in Xs:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
Ux = U[x]
|
for y in model.designated_values - Xs:
|
||||||
for y in model.designated_values - Xs - Ux:
|
|
||||||
|
# Discard (A, {⊤} ∪ B') subalgebras
|
||||||
|
if top is not None and y == top:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Discard (A, {⊥} ∪ B') subalgebras when negation is defined
|
||||||
|
if bottom is not None and negation_defined and y == bottom:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Discard ({a} ∪ A', {b} ∪ B') subalgebras when a <= b
|
||||||
|
if model.ordering.is_lt(x, y):
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Discard ({a} ∪ A', {b} ∪ B') subalgebras when b <= a and negation is defined
|
||||||
|
if negation_defined and model.ordering.is_lt(y, x):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if y not in C:
|
||||||
|
C[y] = model_closure({y,}, model.logical_operations, None)
|
||||||
Ys = C[y]
|
Ys = C[y]
|
||||||
|
|
||||||
# Discard (A, {⊤} ∪ B') subalgebras
|
# Discard (A, {⊤} ∪ B') subalgebras
|
||||||
if top is not None and top in Ys:
|
if top is not None and top in Ys:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Discard (A, {⊥} ∪ B') subalgebras when negation is defined
|
# Discard (A, {⊥} ∪ B') subalgebras when negation is defined
|
||||||
if bottom is not None and negation_defined and bottom in Ys:
|
if bottom is not None and negation_defined and bottom in Ys:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not Xs.isdisjoint(Ys):
|
if not Xs.isdisjoint(Ys):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -81,8 +105,8 @@ def has_vsp(model: Model, impfunction: ModelFunction,
|
||||||
if impfunction(xi, yi) in model.designated_values:
|
if impfunction(xi, yi) in model.designated_values:
|
||||||
falsified = False
|
falsified = False
|
||||||
break
|
break
|
||||||
|
|
||||||
if falsified:
|
if falsified:
|
||||||
return VSP_Result(True, model.name, Xs, Ys)
|
return VSP_Result(True, model.name, Xs, Ys)
|
||||||
|
|
||||||
return VSP_Result(False, model.name)
|
return VSP_Result(False, model.name)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue