coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Alex Shkotin <alex.shkotin AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Puzzle: NYC Guys
- Date: Sat, 26 Nov 2016 14:01:16 +0300
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=alex.shkotin AT gmail.com; spf=Pass smtp.mailfrom=alex.shkotin AT gmail.com; spf=None smtp.helo=postmaster AT mail-io0-f176.google.com
- Ironport-phdr: 9a23:+ZHtFxVkbgs16txIeMSjE+5PwtnV8LGtZVwlr6E/grcLSJyIuqrYYxKHt8tkgFKBZ4jH8fUM07OQ6PG7HzdbqszY+Fk5M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aFRrwLxd6KfroEYDOkcu3y/qy+5rOaAlUmTaxe71/IRG4oAnLuMQbj4RuJrgsxhDUvnZGZuNayH9yK1mOhRj8/MCw/JBi8yRUpf0s8tNLXLv5caolU7FWFSwqPG8p6sLlsxnDVhaP6WAHUmoKiBpIAhPK4w/8U5zsryb1rOt92C2dPc3rUbA5XCmp4ql3RBP0jioMKjg0+3zVhMNtlqJWuBCupxJ/zYDaY4+bKeRwcb/GcNwAWWZMRNxcWzBdDo6+aYYEEuoPPfxfr4n4v1YDsR++ChejBejy1zFIhnz23aom0+QgFwHNwQstEMgKsHvKo9T5LrwSUeC2zKnP0TXDbvVW1Czy6IjNaB8hoPWMUahsfsrWzEkiDgXIhUiep4ziOjOazOUNs26D4utuVOKviG8nqxlvrTeyx8cjkJPFhoUPylDL8yhy3YU7JcWgRUJlfdKpFIFcuiKaOodsXM8uXW9ltDwnxrAEuJO2ejUBxo49yB7FcfOHdpCF4hL9W+aVJjd1nHdld6i+hxa26ESgy+r8WtWt3FZEsyZIkNjBumoC1xzU7ciHRf998Vm71TmT0ADT7/lIIUEylaXFN54s2qA8moYXvEjZHSL7mF/6gLGIekgq4OSk9ubqb7T+qp+ZLYB0iwX+Mqo0msy4BOQ1KhIBX2yF9uWzzrHj5k35QLZNjv0qk6nZtovXJcsepqGjAg9V1pwv5Aq4DzejyNgYh2UILEpZeBKbiIjkI03BIPfhDfumn1uslCpryOvdM736ApTNK2DDn637cbZ87U5c0gszwspF65JaELFSaM70D0T2rZnTCgIzGw2y2efuTttnha0EXmfaK6uUIOvpsVyP+uMpa72FYIIF/i39KP855vjGgnowmFtbdq6si8hEIEukF+hrdh3KKUHnhc0MRD8H
Hi Fred,
it looks like widely known in restrict groups https://en.wikipedia.org/wiki/Zebra_Puzzle
does it?
Alex
2016-09-24 13:53 GMT+03:00 Fred Smith <fsmith1024 AT gmail.com>:
Hi all,Below is a puzzle my son brought home from school. It came on a crumpled up piece of paper, photocopied out of some unknown puzzle book; irresistible. We raced to solve it. He beat me by a hair. To lengthen the fun, I thought to formalize and solve it using Coq; and have just finished the project.I thought some readers of the list might enjoy doing the same.Enjoy,Fred(*New York City Guysby Frank AlwardThe five-story Manning Building, located in the Wall Streat area ofManhattan, houses the home offices of Matt and four other prominentbusinessmen. Each man's business is located on a different floor ofthe building, and each also has a branch office located in a foreigncity. No two have a branch in the same city. The man who visits hisbranch in Cairo usually combines his trip with a short vacation. Eachof the five men resides in a different borough of New York City.From this information and the clues below, can you determine each man'shome borough, branch office location, and floor?1. Rick's office is one floor below the office of the man who lives inthe Bronx, which is not on the fourth floor.2. The office of the Staten Island resident is one floor belowRoland's, who doesn't live in Queens.3. Shaun's office is one floor below the one who visits his branch inRome.4. Cliff's branch isn't located in Athens.5. The man who lives in Manhattan has no branch in Rome.6. The Paris branch is not Shaun's.7. The office of the man who lives in Brooklyn is one floor below thatof the businessman who visits his branch in Geneva, which is not onthe fifth floor.8. The office of the one who lives in the Bronx is on some floor aboveRoland's.9. Rick, who has no branch in Geneva, doesn't live in Queens.10. Neither the Staten Island resident nor the Manhattan resident hasa branch in Athens.*)Require Import Arith.Require Import Nat.Require Import Psatz. (* Required for lia -- tactic for solving linear arithmetic. *)Inductive person := Cliff | Matt | Rick | Roland | Shaun.Inductive branch := Athens | Cairo | Geneva | Paris | Rome.Inductive home := Brooklyn | Bronx | Manhattan | Queens | StatenIsland.Section Puzzle.Parameter B : person -> branch.Parameter H : person -> home.Parameter F : person -> nat.Axiom B_unique : forall p1 p2 : person, B p1 = B p2 -> p1 = p2.Axiom H_unique : forall p1 p2 : person, H p1 = H p2 -> p1 = p2.Axiom F_unique : forall p1 p2 : person, F p1 = F p2 -> p1 = p2.Axiom F_range : forall p : person, F p > 0 /\ F p <= 5.Lemma F_cases : forall p : person, F p = 1 \/ F p = 2 \/ F p = 3 \/ F p = 4 \/ F p = 5.Proof.intro p.assert (H := F_range p).lia.Qed.Variables X1 X2 X3 X4 X5 X6 X7 X8 X9 : person.Axiom R1 : S (F Rick) = (F X1) /\ (H X1) = Bronx /\ (F X1) <> 4.Axiom R2: S (F X2) = (F Roland) /\ (H X2) = StatenIsland /\ (H Roland) <> Queens.Axiom R3: S (F Shaun) = (F X3) /\ (B X3) = Rome.Axiom R4: (B Cliff) <> Athens.Axiom R5: (H X4) = Manhattan /\ (B X4) <> Rome.Axiom R6: (B Shaun) <> Paris.Axiom R7: S (F X5) = (F X6) /\ (H X5) = Brooklyn /\ (B X6) = Geneva /\ (F X6) <> 5.Axiom R8: (F X7) > (F Roland) /\ (H X7) = Bronx.Axiom R9: (B Rick) <> Geneva /\ (H Rick) <> Queens.Axiom R10: (H X8) = StatenIsland /\ (B X8) <> Athens /\ (H X9) = Manhattan /\ (B X9) <> Athens.End Puzzle.
- Re: [Coq-Club] Puzzle: NYC Guys, Fred Smith, 11/05/2016
- <Possible follow-up(s)>
- Re: [Coq-Club] Puzzle: NYC Guys, Alex Shkotin, 11/26/2016
Archive powered by MHonArc 2.6.18.