From 5684a512562eeb4de8ca02643335408b91bf9546 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Fri, 19 Aug 2016 18:32:27 +0200 Subject: English translation for sister/2 and brother/2 added. --- prolog/problems/family_relations/sister_2/en.py | 75 +++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 6 deletions(-) (limited to 'prolog/problems/family_relations/sister_2/en.py') diff --git a/prolog/problems/family_relations/sister_2/en.py b/prolog/problems/family_relations/sister_2/en.py index 9b78c95..cbd975b 100644 --- a/prolog/problems/family_relations/sister_2/en.py +++ b/prolog/problems/family_relations/sister_2/en.py @@ -2,18 +2,81 @@ name = 'sister/2' slug = 'the sister relation' description = '''\ -

sister(X, Y): X is a sister of Y.

+

sister(X, Y): X is a (half)sister of Y.

 ?- sister(vanessa, X).
   X = patricia.
-
''' + +

Family trees are +described with predicates parent/2, male/1, and +female/1.

+''' + +plan = [ + '''\ +

A sister is female and has a common parent with Y.

''', + '''\ +

If X is female and if X and Y share a common parent +then X is a sister of Y.

''', + '''\ +

Sister X is female and has
+at least one parent in common with Y.

''', +] hint = { - 'x_y_must_be_different': '''\ -

What if X and Y are the same person? Try the -following query:

+ 'x_y_must_be_different': [{'message': '''\ +

+

What if X and Y are the same person? Try the following query:

 ?- sister(sally, Y).
-
+''', 'linkText': 'How can I check that X and Y are different?'}, +'''\ +

Using the operator \== I can check that X and Y are different. +For example: X \== Y

+'''], + + 'x_must_be_female': '''\ +

+

A sister is usually female.

+''', + + 'y_can_be_of_any_gender': '''\ +

Y can actually be of any gender.

+''', + + 'neq+_instead_of_neq': '''\ +

Use the operator \== instead of operators \= or =\=. It succeeds when the two operands are not the same, +while \= succeeds if the operands cannot be made the same (cannot be unified), and =\= checks for +arithmetic inequality and in this case both operands should be immediately arithmetically computable.

+''', + + 'common_parent_needed': '''\ +

+

It would make sense if X and Y have at least one parent in common.

+''', + + 'neq_used_too_early': '''\ +

Did you use the operator \== too early?

+

Try moving it more towards the end of the rule. The problem is probably that the variables +you are comparing don't yet have values assigned to them and are therefore different by default. +Prolog doesn't check whether they become equal later, it only checks whether they're +equal or not at the moment of comparison.

+

Or maybe you're simply comparing the wrong two variables?

+''', + + 'predicate_always_false': '''\ +

It seems your predicate is always "false". Did you give it the correct name, +or is it perhaps misspelled?

+

If the name is correct, check whether something else is misspelled, perhaps there is a full stop instead of +a comma or vice versa, or maybe you typed a variable name in lowercase?

+

It is, of course, also possible that your conditions are too restrictive, or even impossible to satisfy +(as would be, for example, the condition that X is both a parent and a sister of Y, or +something similarly impossible).

+''', + + 'final_hint': '''\ +

In this exercise you used the \== operator. It succeeds if its two operands are not the same +at the moment of comparison. If you put this goal at the start of your rule, it will +not work as expected. (Go ahead, try and see what happens!)

''', } -- cgit v1.2.1