Question: Problem 4 : Odd and even integers # Return the following 6 laws. Be sure your formulas are exactly in the order specified. # 0
Problem : Odd and even integers
# Return the following laws. Be sure your formulas are exactly in the order specified.
# Each number $$ has exactly one successor, which is not equal to $$
# Each number is either even or odd, but not both.
# The successor number of an even number is odd.
# The successor number of an odd number is even.
# For every number $$ the successor of $$ is larger than $$
# Larger is a transitive property: if $$ is larger than $$ and $$ is
# larger than $$ then $$ is larger than $$
# Query: For each number, there exists an even number larger than it
def ints TupleListFormula Formula:
def Even : return AtomEven # whether is even
def Odd : return AtomOdd # whether is odd
def Successor: return AtomSuccessor # whether xs successor is
def Larger : return AtomLarger whether is larger than
# Note: all objects are numbers, so we don't need to define Number as an
# explicit predicate.
# Note: pay attention to the order of arguments of Successor and Larger.
# Populate formulas with the laws above and set query to be the
# query.
# Hint: You might want to use the Equals predicate, defined in
logic.py This
# predicate is used to assert that two objects are the same.
formulas
query None
# BEGINYOURCODE our solution is lines of code, but don't worry if you deviate from this
formulas.appendExists
# ENDYOURCODE
query Forall$x Exists$y AndEven$y Larger$y$x
return formulas query
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
