mirror of
https://github.com/Brandon-Rozek/matmod.git
synced 2025-12-09 04:30:24 +00:00
Added an initial model finder via Z3
This commit is contained in:
parent
2fbdf26274
commit
3610335c1c
3 changed files with 115 additions and 6 deletions
17
logic.py
17
logic.py
|
|
@ -100,17 +100,22 @@ def get_prop_var_from_term(t: Term) -> Set[PropositionalVariable]:
|
|||
|
||||
return result
|
||||
|
||||
def get_prop_vars_from_rule(r: Rule) -> Set[PropositionalVariable]:
|
||||
vars: Set[PropositionalVariable] = set()
|
||||
|
||||
for premise in r.premises:
|
||||
vars |= get_prop_var_from_term(premise)
|
||||
|
||||
vars |= get_prop_var_from_term(r.conclusion)
|
||||
|
||||
return vars
|
||||
|
||||
@lru_cache
|
||||
def get_propostional_variables(rules: Tuple[Rule]) -> Set[PropositionalVariable]:
|
||||
vars: Set[PropositionalVariable] = set()
|
||||
|
||||
for rule in rules:
|
||||
# Get all vars in premises
|
||||
for premise in rule.premises:
|
||||
vars |= get_prop_var_from_term(premise)
|
||||
|
||||
# Get vars in conclusion
|
||||
vars |= get_prop_var_from_term(rule.conclusion)
|
||||
vars |= get_prop_vars_from_rule(rule)
|
||||
|
||||
return vars
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue