From 40fb59cc361f927834580c543558b1414bb13490 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Thu, 18 Aug 2016 21:05:22 +0200 Subject: English translation for mother/2 and father/2 added. --- prolog/problems/family_relations/father_2/en.py | 55 +++++++++++++++++++++++- prolog/problems/family_relations/mother_2/en.py | 56 ++++++++++++++++++++++++- 2 files changed, 107 insertions(+), 4 deletions(-) (limited to 'prolog') diff --git a/prolog/problems/family_relations/father_2/en.py b/prolog/problems/family_relations/father_2/en.py index b37c666..f1a9040 100644 --- a/prolog/problems/family_relations/father_2/en.py +++ b/prolog/problems/family_relations/father_2/en.py @@ -9,6 +9,57 @@ description = '''\ ?- father(aleksander, X). X = luana ; X = daniela. -''' + +

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

+''' -hint = {} +plan = [ + '''\ +

A father is male and has a child.

''', + '''\ +

Father X is a parent of Y and is male.

''', + '''\ +

If X is male and X is parent to Y, +then X is a father of Y.

''' +] + +hint = { + 'or_instead_of_and': '''\ +

Did you perhaps use a semicolon (that represents logical OR) instead of a comma (logical AND)?

+''', + + 'or_instead_of_and_two_rules': '''\ +

Did you perhaps write two rules: one for gender and one for parenthood? +Be careful: this is understood as one or the other, not as one and the other!

+''', + + 'x_must_be_male': '''\ +

A father is usually male.

+

+''', + + 'x_must_be_parent': '''\ +

A father is supposed to have at least one child... so he's a parent of somebody.

+

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

Y can be of any gender.

+''', + + 'y_need_not_be_parent': '''\ +

Y doesn't need to have children...

+''', + + '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).

+''', +} diff --git a/prolog/problems/family_relations/mother_2/en.py b/prolog/problems/family_relations/mother_2/en.py index f8cda9a..7d9de60 100644 --- a/prolog/problems/family_relations/mother_2/en.py +++ b/prolog/problems/family_relations/mother_2/en.py @@ -9,6 +9,58 @@ description = '''\ ?- mother(nevia, X). X = luana ; X = daniela. -''' + +

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

+''' -hint = {} +plan = [ + '''\ +

A mother is female and has a child.

+''', + '''\ +

Mother X is a parent of Y and is female.

''', + '''\ +

If X is female and X is parent to Y, +then X is a mother of Y.

''' +] + +hint = { + 'or_instead_of_and': '''\ +

Did you perhaps use a semicolon (that represents logical OR) instead of a comma (logical AND)?

+''', + + 'or_instead_of_and_two_rules': '''\ +

Did you perhaps write two rules: one for gender and one for parenthood? +Be careful: this is understood as one or the other, not as one and the other!

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

A mother is usually female.

+

+''', + + 'x_must_be_parent': '''\ +

A mother is supposed to have at least one child... so she's a parent of somebody.

+

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

Y can be of any gender.

+''', + + 'y_need_not_be_parent': '''\ +

Y doesn't need to have children...

+''', + + '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).

+''', +} -- cgit v1.2.1 From 0a09672a992836c912be80a71b47eaf9bcce2d07 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Fri, 19 Aug 2016 02:05:11 +0200 Subject: English translation for aunt/2 added. --- prolog/problems/family_relations/aunt_2/en.py | 79 ++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-) (limited to 'prolog') diff --git a/prolog/problems/family_relations/aunt_2/en.py b/prolog/problems/family_relations/aunt_2/en.py index 4314a7a..f8bf35b 100644 --- a/prolog/problems/family_relations/aunt_2/en.py +++ b/prolog/problems/family_relations/aunt_2/en.py @@ -7,6 +7,81 @@ description = '''\ ?- aunt(sally, X). X = vanessa ; X = patricia. -''' + +

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

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

Perhaps you can make use of the solution to one of the previous exercises?

+

My sibling has a child...

+''', '''\ +

If X is a sister of the parent of Y, +then X is the aunt of Y.

+''', '''\ +

A sister of Y's parent is the aunt of Y.

+'''] + +hint = { + 'x_and_y_mixed_up': '''\ +

X should be the aunt of Y, not the other way around.

+''', + + 'precedence_fail': '''\ +

Did you mix up the precedence of operators or & and?

+

Operator and has higher precedence than operator or. +If you wish to change that you can use brackets (as usual in mathematics).

+''', + + 'x_must_have_sibling': '''\ +

An aunt usually has a sibling...

+

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

An aunt is usually female.

+

+''', # TODO: Loni should mark female gender on some aunt hints! + + 'y_must_have_parent': '''\ +

It would probably make sense if the nephew has a parent, right?

+

+''', + + 'aunt_vs_mother': '''\ +

How can an aunt also be the mother of Y? +Did you forget to specify that an aunt and the parent of Y cannot be the same person?

+

+''', + + 'x_need_not_be_parent': '''\ +

X doesn't need to have children to be somebody's aunt...

+''', + + 'y_need_not_be_parent': '''\ +

A nephew Y doesn't need to have children...

+''', + + 'nephews_parent_can_be_male': '''\ +

A parent of nephew Y can also be male +(which means that this parent cannot be a sister of X).

+''', + + '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).

+''', + + 'interesting_tidbit': '''\ +

Interesting tidbit. This exercise could also be solved using the solution to the sister/2 +relation. An aunt is a sister of some parent of Y.

+

+''', # TODO: only trigger if sister is not part of correct solution +} -hint = {} -- cgit v1.2.1 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/brother_2/en.py | 71 +++++++++++++++++++++- prolog/problems/family_relations/sister_2/en.py | 75 ++++++++++++++++++++++-- 2 files changed, 137 insertions(+), 9 deletions(-) (limited to 'prolog') diff --git a/prolog/problems/family_relations/brother_2/en.py b/prolog/problems/family_relations/brother_2/en.py index 1295450..e0db1f5 100644 --- a/prolog/problems/family_relations/brother_2/en.py +++ b/prolog/problems/family_relations/brother_2/en.py @@ -2,11 +2,76 @@ name = 'brother/2' slug = 'the brother relation' description = '''\ -

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

+

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

 ?- brother(jeffrey, X).
   X = william ;
   X = sally.
-
''' + +

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

+''' -hint = {} +plan = [ + '''\ +

A brother is male and has a common parent with Y.

''', + '''\ +

If X is male and if X and Y share a common parent +then X is a brother of Y.

''', + '''\ +

Brother X is male and has
+at least one parent in common with Y.

''', +] + +hint = { + 'x_y_must_be_different': [{'message': '''\ +

+

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

+
+?- brother(william, 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_male': '''\ +

+

A brother is usually male.

+''', + + '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).

+''', +} 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 From d4de1e190bd5e60a910622baaa170a4b7e0914b5 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Sat, 20 Aug 2016 01:26:58 +0200 Subject: English translation for cousin/2 added. --- prolog/problems/family_relations/cousin_2/en.py | 73 ++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 3 deletions(-) (limited to 'prolog') diff --git a/prolog/problems/family_relations/cousin_2/en.py b/prolog/problems/family_relations/cousin_2/en.py index 4ca9c87..a5627ee 100644 --- a/prolog/problems/family_relations/cousin_2/en.py +++ b/prolog/problems/family_relations/cousin_2/en.py @@ -2,11 +2,78 @@ name = 'cousin/2' slug = 'the cousin relation' description = '''\ -

cousin(X, Y): X is a cousin (male or female) of Y.

+

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

 ?- cousin(andrew, X).
   X = vanessa ;
   X = patricia.
-
''' + +

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

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

Perhaps you can make use of the solution to one of the previous exercises?

+

I have a child, my sibling also has a child...

+

But of course it's also possible to solve without any of the previous solutions...

+''', '''\ +

If PX is a parent of X and +PY is a parent of Y and if +PX and PY are siblings, +then X is a cousin to Y.

+''', '''\ +

I have a child, my sibling has a child, these two children
+are therefore...

+'''] + +hint = { + 'gender_is_irrelevant': '''\ +

Is gender really important?

+''', + + 'gender_is_irrelevant_markup': '''\ +

Is this necessary?

+''', + + 'precedence_fail': '''\ +

Did you mix up the precedence of operators or & and?

+

Operator and has higher precedence than operator or. +If you wish to change that you can always use the brackets.

+''', + + 'cousin_vs_sibling': '''\ +

How can a cousin X at the same time also be a sibling of Y? +Did you perhaps forget that the parents of X and Y should not be the same? +(Be careful: if both a mother and a father are listed in the database, then prolog could find them as two +different parents, which is logically absolutely correct.)

+

+''', + + 'cousin_to_oneself': '''\ +

How can someone be a cousin to him- or herself? +Perhaps X and Y have the same parent?

+

+

Try this query: ?- cousin(X, X).

+''', + + 'cousin_need_not_be_parent': '''\ +

A cousin doesn't need to have children...

+''', + + '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).

+''', + +# 'interesting_tidbit': '''\ +#

Zanimivost: nalogo bi lahko rešil tudi z uporabo rešitve za relacijo "sister". +# Teta je namreč sestra od starša od Y.

+# ''', +} -hint = {} -- cgit v1.2.1 From 9360424c9992b92efb4ab0c526eeebd722d54a6f Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Sun, 21 Aug 2016 01:46:25 +0200 Subject: English translation for grandparent/2 added. --- .../problems/family_relations/grandparent_2/en.py | 62 +++++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) (limited to 'prolog') diff --git a/prolog/problems/family_relations/grandparent_2/en.py b/prolog/problems/family_relations/grandparent_2/en.py index 3aa9bfe..b8fca7c 100644 --- a/prolog/problems/family_relations/grandparent_2/en.py +++ b/prolog/problems/family_relations/grandparent_2/en.py @@ -9,6 +9,64 @@ description = '''\ X = patricia. ?- grandparent(tina, vanessa). true. -''' + +

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

+''' -hint = {} +plan = ['''\ +

A grandparent has a child that has a child.

+''', '''\ +

If X is a parent of a parent of Y, +then X is a grandparent of Y.

+''', '''\ +

A grandparent has a child that has a child of
+his or her own.

+'''] + +hint = { + 'no_common_z': '''\ +

Did you connect X and Y through some common person?

+''', + + 'gender_is_irrelevant': '''\ +

We're looking for a grandparent and a grandchild, the gender is not important.

+''', + + 'gender_is_irrelevant_markup': '''\ +

Is this necessary?

+''', + + 'or_instead_of_and': '''\ +

Did you perhaps use a semicolon (that represents logical OR) instead of a comma (logical AND)?

+''', + + 'x_must_be_parent': '''\ +

A grandparent surely has a child, right? So he or she is a parent of someone...

+

+''', + + 'x_need_not_have_parent': '''\ +

A parent of X is not really important if we're looking for a grandchild...

+''', + + 'y_must_have_parent': '''\ +

A grandchild Y must have a parent, right? And that parent is...

+

+''', + + 'y_need_not_be_parent': '''\ +

A grandchild Y doesn't really need to have children...

+''', + + '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).

+''', +} -- cgit v1.2.1