<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 PyASP basics
In the following I try to explain the basics on how to use the PyASP library. I assume that pyasp is already installed on your system. This tutorial has been tested with Python 3 and pyasp 1.4.4. You can download the logic programs that are used in this example here -> queens.lp and facts.lp. 
First you need to download the logic programs for our running example.
Step1:  Import the pyasp library.
Step2:  Create a solver object.
Before creating a solver object you need to declare what options your solver should run with. There are two kind of options the options for the grounder (see gringo documentation) and the options for the solver (see clasp documentation). In this example our only solver option is '2' which means we are looking for atmost 2 solutions.
Step3:  Start the solver with some input.
Just like gringo the run method of the solver object accepts a list of input files. Here we use the encoding of the queens problems and solve it for a size of 10 as declared in facts.lp.
Step4:  The result is a list of the solutions as TermSets.
Step5:  Create your own set of facts.
You can also create your own facts from within python and feed it as input to the solver. So far we have solved the 10-queens problem. Now we create a new set of facts including 'd(11)' and 'd(12)' and solve the 12-queens problem.
Step6:  Now the result contains 2 solutions to the 12-queens problem.
Step7:  Parse and pretty print your solutions.
<ASSISTANT_TASK:>
Python Code:
from urllib.request import urlretrieve
urlretrieve('http://sthiele.github.io/data/queens.lp','queens.lp')
urlretrieve('http://sthiele.github.io/data/facts.lp','facts.lp')
Explanation: PyASP basics
In the following I try to explain the basics on how to use the PyASP library. I assume that pyasp is already installed on your system. This tutorial has been tested with Python 3 and pyasp 1.4.4. You can download the logic programs that are used in this example here -> queens.lp and facts.lp. 
First you need to download the logic programs for our running example.
End of explanation
from pyasp.asp import *
Explanation: Import the pyasp library.
End of explanation
goptions = ''
soptions = ' 2'
solver   = Gringo4Clasp(gringo_options=goptions, clasp_options=soptions)
Explanation: Create a solver object.
Before creating a solver object you need to declare what options your solver should run with. There are two kind of options the options for the grounder (see gringo documentation) and the options for the solver (see clasp documentation). In this example our only solver option is '2' which means we are looking for atmost 2 solutions.
End of explanation
result   = solver.run(['queens.lp', 'facts.lp'], collapseTerms=True, collapseAtoms=False)
Explanation: Start the solver with some input.
Just like gringo the run method of the solver object accepts a list of input files. Here we use the encoding of the queens problems and solve it for a size of 10 as declared in facts.lp.
End of explanation
print(result)
Explanation: The result is a list of the solutions as TermSets.
End of explanation
newfacts = TermSet()
newterm1 = Term('d', ["11"])
newfacts.add(newterm1)
newterm2 = Term('d', ["12"])
newfacts.add(newterm2)
result   = solver.run(['queens.lp', 'facts.lp', newfacts.to_file()], collapseTerms=True, collapseAtoms=False)
Explanation: Create your own set of facts.
You can also create your own facts from within python and feed it as input to the solver. So far we have solved the 10-queens problem. Now we create a new set of facts including 'd(11)' and 'd(12)' and solve the 12-queens problem.
End of explanation
print(result)
Explanation: Now the result contains 2 solutions to the 12-queens problem.
End of explanation
count=1
for s in result :
  print('Solution '+str(count)+':')
  print('   ', end=' ')
  for a in s :
    args= ",".join(a.args())
    print(a.pred(),'(',args,')',sep='',end=' ')
  print()
  count+=1
Explanation: Parse and pretty print your solutions.
End of explanation
<END_TASK>