48 lines
1.0 KiB
Python
48 lines
1.0 KiB
Python
from pyDatalog import pyDatalog
|
|
|
|
pyDatalog.create_terms('X,Y,trash')
|
|
pyDatalog.create_terms('plasticContainer,paperContainer,glassContainer')
|
|
pyDatalog.create_terms('plastic,glass,paper')
|
|
pyDatalog.create_terms('color,elastic,fragile,white')
|
|
|
|
# example trash:
|
|
# glass
|
|
trash['glass_trash1'] = 1
|
|
color['glass_trash1'] = 0
|
|
fragile['glass_trash1'] = 8
|
|
|
|
# plastic
|
|
trash['plastic_trash1'] = 1
|
|
color['plastic_trash1'] = 1
|
|
elastic['plastic_trash1'] = 1
|
|
|
|
# paper
|
|
trash['paper_trash1']=1
|
|
white['paper_trash1']=8
|
|
|
|
#glass
|
|
trash['glass_trash2'] = 1
|
|
color['glass_trash2'] = 0
|
|
fragile['glass_trash2'] = 9
|
|
|
|
|
|
#glass
|
|
trash['glass_trash3'] = 1
|
|
color['glass_trash3'] = 0
|
|
fragile['glass_trash3'] = 9
|
|
|
|
glass(X) <= (trash[X]==1) & (color[X]==0) & (fragile[X]>5)
|
|
plastic(X) <= (trash[X]==1) & (color[X]==1) & (elastic[X]>8)
|
|
paper(X) <= (trash[X]==1) & (white[X]>5)
|
|
|
|
|
|
glassContainer(X) <= glass(X)
|
|
plasticContainer(X) <= plastic(X)
|
|
paperContainer(X) <= paper(X)
|
|
|
|
print(glass(X))
|
|
|
|
print(glassContainer(X))
|
|
|
|
print (glassContainer(X) & (fragile[X]==9))
|