Beispiel #1
0
# See: http://creativecommons.org/licenses/by-nc-sa/4.0/deed.en_US.

from logicProblem import Clause, Askable, KB

plumbing = KB([
    Clause('on_t1'),
    Clause('on_t2'),
    Clause('on_t3'),
    Clause('flow_shower'),
    Clause('flow_faucet'),
    Clause('unplugged_bath'),
    Clause('unplugged_sink'),
    Clause('wet_sink'),
    Clause('wet_bath'),
    Clause('flow_d3', ['wet_sink', 'unplugged_sink']),
    Clause('flow_d2', ['wet_bath', 'unplugged_bath']),
    Clause('flow_d1', ['flow_d3']),
    Clause('flow_d1', ['flow_d2']),
    Clause('pressurized_p3', ['on_t3', 'flow_faucet']),
    Clause('pressurized_p2', ['on_t2', 'flow_shower']),
    Clause('pressurized_p1', ['on_t1', 'pressurized_p3']),
    Clause('pressurized_p1', ['on_t1', 'pressurized_p3'])
    ])

print(plumbing)
from logicBottomUp import fixed_point
fixed_point(plumbing)
from logicTopDown import prove
prove(plumbing, ['pressurized_p1'])
prove(plumbing, ['flow_d1'])
Beispiel #2
0
    Clause('flow_d1', ['flow_d2']),
    Clause('on_t1'),
    Clause('on_t2'),
    Clause('unplugged_bath'),

    Clause('unplugged_sink'),
    Clause('flow_faucet', ['on_t3', "pressurized_p3"]),
    Clause('flow_d1', ['flow_d3']),
    Clause('flow_d3', ['wet_sink', 'unplugged_sink']),
    Clause('wet_sink', ['flow_faucet']),
    Clause('on_t3'),
    Clause('pressurized_p3', ['on_t1', 'pressurized_p1']),

    Clause('on_t4'),
    Clause('on_t5'),
    Clause('on_t6'),
    Clause('pressurized_p4',['on_t1', 'pressurized_p1', 'on_t4']),
    Clause('pressurized_p5',['pressurized_p4']),
    Clause('pressurized_p6',['pressurized_p4']),
    Clause('flow_shower',['pressurized_p5', 'on_t5']),
    Clause('flow_hfaucet',['pressurized_p6', 'on_t6']),
    Clause('wet_sink',['flow_hfaucet'])
    ])

print(plumbing)
from logicBottomUp import fixed_point
fixed_point(plumbing)
from logicTopDown import prove
prove(plumbing, ['flow_hfaucet'])
prove(plumbing, ['pressurized_p5'])