{"id":24056186,"url":"https://github.com/arjun1237/prolog","last_synced_at":"2026-03-06T14:32:52.404Z","repository":{"id":110875884,"uuid":"95119649","full_name":"arjun1237/Prolog","owner":"arjun1237","description":"Prolog","archived":false,"fork":false,"pushed_at":"2017-06-22T13:44:12.000Z","size":358,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-09T05:00:38.829Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Prolog","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arjun1237.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-22T13:40:46.000Z","updated_at":"2017-06-22T13:43:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"fa8d9cfd-bfd3-4be0-a500-422404b7d69c","html_url":"https://github.com/arjun1237/Prolog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arjun1237%2FProlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arjun1237%2FProlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arjun1237%2FProlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arjun1237%2FProlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arjun1237","download_url":"https://codeload.github.com/arjun1237/Prolog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240849057,"owners_count":19867617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-09T04:59:49.131Z","updated_at":"2025-02-26T12:13:39.623Z","avatar_url":"https://github.com/arjun1237.png","language":"Prolog","readme":"# Prolog\nProlog Assessment\n\n\nCO884, Assessment 2, Prolog\nMarks: 20 marks per question.\n1. Define a predicate same_content/2 whose two arguments are two lists. It should\nsucceed if and only if all elements of the first list occur in the second, and vice versa. Note\nthat it is allowed if these list elements occur in a different order, or a different number of\ntimes, so ?-same_content([1,2,4,2],[4,2,1]) should succeed.\n2. Define a predicate totatives/2 whose first argument is a natural number (a positive\ninteger) N, and the second argument is the result, which should be the ordered list of all\nnumber between 1 and N (inclusive) which are “relative prime” to N, meaning the greatest\ncommon divisor (gcd) of N and that number is 1. For example, ?-totatives(9,X)\nshould succeed with X=[1,2,4,5,7,8].\nNote that gcd/2 is a function understood by the built-in evaluation routines, e.g. ?-X is\ngcd(9,6) succeeds with X=3. Note also that you will probably need an auxiliary predicate\nthat iterates from 1 to N to find the numbers that need to go into the result list.\n3. Define a predicate aNatural/1 which should succeed if its argument is a natural number.\nIf the argument is a variable then the predicate should generate all natural numbers on\nbacktracking. This means, ?-aNatural(X) should succeed in order with X=0, X=1, X=2,\netc.\nIf the argument is a natural number to begin with (e.g. 1000) then we want the queries to\nsucceed straight away (rather than to slowly count up to 1000 and succeed then). To achieve\nthis, use meta-predicates such as var/1, nonvar/1, integer/1, which enquire\nwhether their argument is or is not a variable or integer, without instantiating anything.\n4. Define a predicate anInteger/1 which does the corresponding thing, but with all\nintegers, including negative ones. For this you need to consider how to get from one integer\nto another in such a way that it will eventually find them all. Thus, also write a predicate\nnextInteger/2 whose first argument is an integer (the second is the result parameter).\nWhich integer you consider as “the next” integer is up to you.\n5. Write a predicate eval/2 whose first argument is an arithmetic expression on integers\nwhich may or may not contain variables. The second argument is the result parameter. If the\nexpression it encounters contains a variable the predicate should “guess” its value, using\nanInteger/1 from the previous question (or: aNatural/1 if you did not get this to\nwork). For example, ?-eval(X*3,6) should succeed with X=2.\nThe supported operators for the arithmetic should include ‘+’/2, ‘-‘/2, ‘*’/2, div/2 and\nmod/2.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farjun1237%2Fprolog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farjun1237%2Fprolog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farjun1237%2Fprolog/lists"}