{"id":19155851,"url":"https://github.com/thedhruvrawat/ferryman","last_synced_at":"2026-02-02T22:41:47.737Z","repository":{"id":132574825,"uuid":"437241724","full_name":"thedhruvrawat/ferryman","owner":"thedhruvrawat","description":"Solving the classic Ferryman problem via model-checking using NuSMV Modeller","archived":false,"fork":false,"pushed_at":"2021-12-11T10:35:35.000Z","size":2118,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T21:41:35.777Z","etag":null,"topics":["logic-in-computer-science","model-checking","nusmv"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thedhruvrawat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-12-11T09:40:39.000Z","updated_at":"2024-05-08T09:37:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"f8242ecc-9da4-4ab6-9541-c4f85ae08bc5","html_url":"https://github.com/thedhruvrawat/ferryman","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thedhruvrawat/ferryman","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedhruvrawat%2Fferryman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedhruvrawat%2Fferryman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedhruvrawat%2Fferryman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedhruvrawat%2Fferryman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thedhruvrawat","download_url":"https://codeload.github.com/thedhruvrawat/ferryman/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedhruvrawat%2Fferryman/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263322786,"owners_count":23448712,"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":["logic-in-computer-science","model-checking","nusmv"],"created_at":"2024-11-09T08:32:14.916Z","updated_at":"2026-02-02T22:41:47.676Z","avatar_url":"https://github.com/thedhruvrawat.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ferryman Problem\n\n### Problem\nThere is a ferryman, goat, cabbage and a wolf on one side of a river. The ferryman can cross a river with at most one passenger in his boat. There is a behavioural conflict between\n1. the goat and the cabbage; and\n2. the goat and the wolf;\n\nif they are on the same side of the river bank but the ferryman crosses the river or stays on the other bank.\n\n**Can ferryman transport all goods to the other side, without any conflicts occuring?**\n\n### Solution\nThis is a *planning problem* but can be solved using **model checking**. \n\nWe describe a transition system in which the states represent which\ngoods are at which side of the river. Then we ask if the goal state is reachable\nfrom the initial state: *Is there a path from the initial state such that it\nhas a state along it at which all the goods are on the other side, and during\nthe transitions to that state the goods are never left in an unsafe, conflicting\nsituation?*\n\nWe model all possible behaviour (including that which results in conflicts)\nas a NuSMV program. The location of each agent is modelled\nas a boolean variable: `FALSE` denotes that the agent is on the initial bank, and\n`TRUE` the destination bank. Thus, `ferryman = FALSE` means that the ferryman is\non the initial bank, `ferryman = TRUE` that he is on the destination bank, and\nsimilarly for the variables `goat`, `cabbage` and `wolf`. \n\nThe variable carry takes a value indicating whether the goat, cabbage,\nwolf or nothing is carried by the ferryman. The definition of `next(carry)`\nworks as follows. It is non-deterministic, but the set from which a value is\nnon-deterministically chosen is determined by the values of ferryman, goat, etc., and always includes `FALSE`. If `ferryman = goat` (i.e., they are on the same\nside) then `g` is a member of the set from which `next(carry)` is chosen. The\nsituation for cabbage and wolf is similar. Thus, if `ferryman = goat = wolf !=\ncabbage` then that set is `{g, w, 0}`. The next value assigned to `ferryman` is\nnon-deterministic: he can choose to cross or not to cross the river. But the\nnext values of `goat`, `cabbage` and `wolf` are deterministic, since whether they\nare carried or not is determined by the ferryman’s choice, represented by the\nnon-deterministic assignment to `carry`; these values follow the same pattern.\n\n### Instructions to run\n\n```bash\n./nusmv.exe ferryman.smv\n```\n\n### Sample Solution Path\n```\n*** This is NuSMV 2.6.0 (compiled on Wed Oct 14 15:37:51 2015)\n*** Enabled addons are: compass\n*** For more information on NuSMV see \u003chttp://nusmv.fbk.eu\u003e\n*** or email to \u003cnusmv-users@list.fbk.eu\u003e.\n*** Please report bugs to \u003cPlease report bugs to \u003cnusmv-users@fbk.eu\u003e\u003e\n\n*** Copyright (c) 2010-2014, Fondazione Bruno Kessler\n\n*** This version of NuSMV is linked to the CUDD library version 2.4.1\n*** Copyright (c) 1995-2004, Regents of the University of Colorado\n\n*** This version of NuSMV is linked to the MiniSat SAT solver.\n*** See http://minisat.se/MiniSat.html\n*** Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson\n*** Copyright (c) 2007-2010, Niklas Sorensson\n\n-- specification !(((goat = cabbage | goat = wolf) -\u003e goat = ferryman) U (((cabbage \u0026 goat) \u0026 wolf) \u0026 ferryman))  is false\n-- as demonstrated by the following execution sequence\nTrace Description: LTL Counterexample\nTrace Type: Counterexample\n  -- Loop starts here\n  -\u003e State: 1.1 \u003c-\n    ferryman = FALSE\n    goat = FALSE\n    cabbage = FALSE\n    wolf = FALSE\n    carry = none\n  -\u003e State: 1.2 \u003c-\n    ferryman = TRUE\n    goat = TRUE\n    carry = g\n  -\u003e State: 1.3 \u003c-\n    ferryman = FALSE\n    carry = none\n  -\u003e State: 1.4 \u003c-\n    ferryman = TRUE\n    wolf = TRUE\n    carry = w\n  -\u003e State: 1.5 \u003c-\n    ferryman = FALSE\n    goat = FALSE\n    carry = g\n  -\u003e State: 1.6 \u003c-\n    ferryman = TRUE\n    cabbage = TRUE\n    carry = c\n  -\u003e State: 1.7 \u003c-\n    ferryman = FALSE\n    carry = none\n  -\u003e State: 1.8 \u003c-\n    ferryman = TRUE\n    goat = TRUE\n    carry = g\n  -\u003e State: 1.9 \u003c-\n    ferryman = FALSE\n    wolf = FALSE\n    carry = w\n  -\u003e State: 1.10 \u003c-\n    ferryman = TRUE\n    carry = none\n  -\u003e State: 1.11 \u003c-\n    ferryman = FALSE\n    cabbage = FALSE\n    carry = c\n  -\u003e State: 1.12 \u003c-\n    ferryman = TRUE\n    carry = none\n  -\u003e State: 1.13 \u003c-\n    ferryman = FALSE\n    goat = FALSE\n    carry = g\n  -\u003e State: 1.14 \u003c-\n    ferryman = TRUE\n    carry = none\n  -\u003e State: 1.15 \u003c-\n    ferryman = FALSE\n```\n\n\u003e Invoking **bounded model checking** will produce the shortest possible path\nto violate the property.\n\n### References\n*Michael Huth* and *Mark Ryan*. 2004. **Logic in Computer Science: Modelling and Reasoning about Systems**. \u003cbr\u003e\nCambridge University Press, USA.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedhruvrawat%2Fferryman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthedhruvrawat%2Fferryman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedhruvrawat%2Fferryman/lists"}