473,396 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

New to python

Working on some python scrips with a friend. Got these exercisees;

Expand|Select|Wrap|Line Numbers
  1. ia1 = Interpretation([knows(bob,john),knows(john,bob),knows(mary,alice),knows(alice,mary)],[bob,john,mary,alice])
  2.  
This is supposed to be symmetric... but this is as far as I get.

Expand|Select|Wrap|Line Numbers
  1. f1a1 = forall(x, knows(x, bob)) > forall(y, knows(bob, y)) & forall(x, knows(x, mary)) > forall(y, knows(mary, y))
  2.  
  3. print 'This Is symmetric:', f1a1.val(ia1)
I shouldnt use the name bob, mary and so on, but if I use the variables a,b, for example I get the error that its not defined.
Expand|Select|Wrap|Line Numbers
  1. ia2 = Interpretation([knows(bob,john),knows(john,bob),knows(mary,alice),knows(alice,mary)],[bob,john,mary,alice])
  2.  
this part is supposed to be transitive. From what I can se (though Im kind of tired) it is not transitive. But I just cant seem to find the right answser.
Expand|Select|Wrap|Line Numbers
  1. f1a2 = forall(z, forall(y, forall(x, (knows(x, y) & forall(x, knows(y,z)) > forall(x, knows(x, z))))))
  2. print 'This Is Transitive:', f1a2.val(ia2)
and finally this, its going to be symmetric.
Expand|Select|Wrap|Line Numbers
  1. ia5 = 
  2. Interpretation([loves(bob,mary),loves(john,john),loves(mary,alice),loves(bob,alice)],[bob,john,mary,alice])
  3.  
and this is how far I came on this one
Expand|Select|Wrap|Line Numbers
  1. f1a5 = forall(x, forall(y, forall(z, loves(x, y) & loves(y, z) > loves(x, z))))
  2. print 'This is symmetric', f1a5.val(ia4)
  3.  
cant find whats wrong with this one.

Would really appreciate any help on these exercises.

// Sweden
Jan 9 '08 #1
0 937

Sign in to post your reply or Sign up for a free account.

Similar topics

0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.