{"action":"created","comment":{"url":"https://api.github.com/repos/CVC4/CVC4/pulls/comments/184667923","pull_request_review_id":115912885,"id":184667923,"diff_hunk":"@@ -0,0 +1,252 @@\n+/*********************                                                        */\n+/*! \\file cegis_unif.cpp\n+ ** \\verbatim\n+ ** Top contributors (to current version):\n+ **   Haniel Barbosa\n+ ** This file is part of the CVC4 project.\n+ ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS\n+ ** in the top-level source directory) and their institutional affiliations.\n+ ** All rights reserved.  See the file COPYING in the top-level source\n+ ** directory for licensing information.\\endverbatim\n+ **\n+ ** \\brief implementation of class for cegis with unification techniques\n+ **/\n+\n+#include \"theory/quantifiers/sygus/cegis_unif.h\"\n+\n+#include \"theory/quantifiers/sygus/ce_guided_conjecture.h\"\n+#include \"theory/quantifiers/sygus/sygus_unif_rl.h\"\n+#include \"theory/quantifiers/sygus/term_database_sygus.h\"\n+\n+using namespace CVC4::kind;\n+\n+namespace CVC4 {\n+namespace theory {\n+namespace quantifiers {\n+\n+CegisUnif::CegisUnif(QuantifiersEngine* qe, CegConjecture* p)\n+    : SygusModule(qe, p)\n+{\n+  d_tds = d_qe->getTermDatabaseSygus();\n+}\n+\n+CegisUnif::~CegisUnif() {}\n+bool CegisUnif::initialize(Node n,\n+                           const std::vector<Node>& candidates,\n+                           std::vector<Node>& lemmas)\n+{\n+  Trace(\"cegis-unif\") << \"Initialize CegisUnif : \" << n << std::endl;\n+  Assert(candidates.size() > 0);\n+  if (candidates.size() > 1)\n+  {\n+    return false;\n+  }\n+  d_candidate = candidates[0];\n+  Trace(\"cegis-unif\") << \"Initialize unif utility for \" << d_candidate\n+                      << \"...\\n\";\n+  d_sygus_unif.initialize(d_qe, d_candidate, d_enums, lemmas);\n+  Assert(!d_enums.empty());\n+  Trace(\"cegis-unif\") << \"Initialize \" << d_enums.size() << \" enumerators for \"\n+                      << d_candidate << \"...\\n\";\n+  /* initialize the enumerators */\n+  for (const Node& e : d_enums)\n+  {\n+    d_tds->registerEnumerator(e, d_candidate, d_parent, true);\n+    Node g = d_tds->getActiveGuardForEnumerator(e);\n+    d_enum_to_active_guard[e] = g;\n+  }\n+  return true;\n+}\n+\n+void CegisUnif::getTermList(const std::vector<Node>& candidates,\n+                            std::vector<Node>& terms)\n+{\n+  Assert(candidates.size() == 1);\n+  Valuation& valuation = d_qe->getValuation();\n+  for (const Node& e : d_enums)\n+  {\n+    Assert(d_enum_to_active_guard.find(e) != d_enum_to_active_guard.end());\n+    Node g = d_enum_to_active_guard[e];\n+    /* Get whether the active guard for this enumerator is if so, then there may\n+       exist more values for it, and hence we add it to terms. */\n+    Node gstatus = valuation.getSatValue(g);\n+    if (!gstatus.isNull() && gstatus.getConst<bool>())\n+    {\n+      terms.push_back(e);\n+    }\n+  }\n+}\n+\n+bool CegisUnif::constructCandidates(const std::vector<Node>& enums,\n+                                    const std::vector<Node>& enum_values,\n+                                    const std::vector<Node>& candidates,\n+                                    std::vector<Node>& candidate_values,\n+                                    std::vector<Node>& lems)\n+{\n+  Assert(enums.size() == enum_values.size());\n+  if (enums.empty())\n+  {\n+    return false;\n+  }\n+  unsigned min_term_size = 0;\n+  std::vector<unsigned> enum_consider;\n+  Trace(\"cegis-unif-enum\") << \"Register new enumerated values :\\n\";\n+  for (unsigned i = 0, size = enums.size(); i < size; ++i)\n+  {\n+    Trace(\"cegis-unif-enum\") << \"  \" << enums[i] << \" -> \" << enum_values[i]\n+                             << std::endl;\n+    unsigned sz = d_tds->getSygusTermSize(enum_values[i]);\n+    if (i == 0 || sz < min_term_size)\n+    {\n+      enum_consider.clear();\n+      min_term_size = sz;\n+      enum_consider.push_back(i);\n+    }\n+    else if (sz == min_term_size)\n+    {\n+      enum_consider.push_back(i);\n+    }\n+  }\n+  /* only consider the enumerators that are at minimum size (for fairness) */\n+  Trace(\"cegis-unif-enum\") << \"...register \" << enum_consider.size() << \" / \"\n+                           << enums.size() << std::endl;\n+  NodeManager* nm = NodeManager::currentNM();\n+  for (unsigned i = 0, ecsize = enum_consider.size(); i < ecsize; ++i)\n+  {\n+    unsigned j = enum_consider[i];\n+    Node e = enums[j];\n+    Node v = enum_values[j];\n+    std::vector<Node> enum_lems;\n+    d_sygus_unif.notifyEnumeration(e, v, enum_lems);\n+    /* the lemmas must be guarded by the active guard of the enumerator */\n+    Assert(d_enum_to_active_guard.find(e) != d_enum_to_active_guard.end());\n+    Node g = d_enum_to_active_guard[e];\n+    for (unsigned j = 0, size = enum_lems.size(); j < size; ++j)\n+    {\n+      enum_lems[j] = nm->mkNode(OR, g.negate(), enum_lems[j]);\n+    }\n+    lems.insert(lems.end(), enum_lems.begin(), enum_lems.end());\n+  }\n+  /* build candidate solution */\n+  Assert(candidates.size() == 1);\n+  Node vc = d_sygus_unif.constructSolution();\n+  if (vc.isNull())\n+  {\n+    return false;\n+  }\n+  candidate_values.push_back(vc);\n+  return true;\n+}\n+\n+Node CegisUnif::purifyLemma(Node n,\n+                            bool ensureConst,\n+                            std::vector<Node>& model_guards,\n+                            BoolNodePairMap& cache)\n+{\n+  unsigned i, size = n.getNumChildren();\n+  Kind k = n.getKind();\n+  bool fapp = k == APPLY_UF && size > 0 && n[0] == d_candidate;\n+  Trace(\"cegis-unif-purify\") << \"PurifyLemma : \" << n << \"\\n\";\n+  /* top level applications of function-to-synthsize should never be removed */\n+  if (ensureConst || !fapp)","path":"src/theory/quantifiers/sygus/cegis_unif.cpp","position":151,"original_position":151,"commit_id":"4e5bc1d198e95c5c2403912a64cb20fc7d0a96da","original_commit_id":"4e5bc1d198e95c5c2403912a64cb20fc7d0a96da","user":{"login":"ajreynol","id":2973467,"avatar_url":"https://avatars0.githubusercontent.com/u/2973467?v=4","gravatar_id":"","url":"https://api.github.com/users/ajreynol","html_url":"https://github.com/ajreynol","followers_url":"https://api.github.com/users/ajreynol/followers","following_url":"https://api.github.com/users/ajreynol/following{/other_user}","gists_url":"https://api.github.com/users/ajreynol/gists{/gist_id}","starred_url":"https://api.github.com/users/ajreynol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajreynol/subscriptions","organizations_url":"https://api.github.com/users/ajreynol/orgs","repos_url":"https://api.github.com/users/ajreynol/repos","events_url":"https://api.github.com/users/ajreynol/events{/privacy}","received_events_url":"https://api.github.com/users/ajreynol/received_events","type":"User","site_admin":false},"body":"I'm not sure why we are not caching if !ensureConst  && fapp.  I think this should be cached as well.","created_at":"2018-04-27T12:05:30Z","updated_at":"2018-04-27T12:09:57Z","html_url":"https://github.com/CVC4/CVC4/pull/1819#discussion_r184667923","pull_request_url":"https://api.github.com/repos/CVC4/CVC4/pulls/1819","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/CVC4/CVC4/pulls/comments/184667923"},"html":{"href":"https://github.com/CVC4/CVC4/pull/1819#discussion_r184667923"},"pull_request":{"href":"https://api.github.com/repos/CVC4/CVC4/pulls/1819"}}},"pull_request":{"url":"https://api.github.com/repos/CVC4/CVC4/pulls/1819","id":184494635,"html_url":"https://github.com/CVC4/CVC4/pull/1819","diff_url":"https://github.com/CVC4/CVC4/pull/1819.diff","patch_url":"https://github.com/CVC4/CVC4/pull/1819.patch","issue_url":"https://api.github.com/repos/CVC4/CVC4/issues/1819","number":1819,"state":"open","locked":false,"title":"New module for synthesizing functions in a data-driven SyGuS approach","user":{"login":"HanielB","id":2821688,"avatar_url":"https://avatars0.githubusercontent.com/u/2821688?v=4","gravatar_id":"","url":"https://api.github.com/users/HanielB","html_url":"https://github.com/HanielB","followers_url":"https://api.github.com/users/HanielB/followers","following_url":"https://api.github.com/users/HanielB/following{/other_user}","gists_url":"https://api.github.com/users/HanielB/gists{/gist_id}","starred_url":"https://api.github.com/users/HanielB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HanielB/subscriptions","organizations_url":"https://api.github.com/users/HanielB/orgs","repos_url":"https://api.github.com/users/HanielB/repos","events_url":"https://api.github.com/users/HanielB/events{/privacy}","received_events_url":"https://api.github.com/users/HanielB/received_events","type":"User","site_admin":false},"body":"This PR establishes the module's interface, initialization and communication channels with the core utility which will generate the actual solutions and is yet to be implemented.","created_at":"2018-04-27T00:09:27Z","updated_at":"2018-04-27T12:09:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"535e2ea2fcece77747c15ecbcac7c296a8d5dc73","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/CVC4/CVC4/pulls/1819/commits","review_comments_url":"https://api.github.com/repos/CVC4/CVC4/pulls/1819/comments","review_comment_url":"https://api.github.com/repos/CVC4/CVC4/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CVC4/CVC4/issues/1819/comments","statuses_url":"https://api.github.com/repos/CVC4/CVC4/statuses/4e5bc1d198e95c5c2403912a64cb20fc7d0a96da","head":{"label":"HanielB:invsynth","ref":"invsynth","sha":"4e5bc1d198e95c5c2403912a64cb20fc7d0a96da","user":{"login":"HanielB","id":2821688,"avatar_url":"https://avatars0.githubusercontent.com/u/2821688?v=4","gravatar_id":"","url":"https://api.github.com/users/HanielB","html_url":"https://github.com/HanielB","followers_url":"https://api.github.com/users/HanielB/followers","following_url":"https://api.github.com/users/HanielB/following{/other_user}","gists_url":"https://api.github.com/users/HanielB/gists{/gist_id}","starred_url":"https://api.github.com/users/HanielB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HanielB/subscriptions","organizations_url":"https://api.github.com/users/HanielB/orgs","repos_url":"https://api.github.com/users/HanielB/repos","events_url":"https://api.github.com/users/HanielB/events{/privacy}","received_events_url":"https://api.github.com/users/HanielB/received_events","type":"User","site_admin":false},"repo":{"id":109454532,"name":"CVC4","full_name":"HanielB/CVC4","owner":{"login":"HanielB","id":2821688,"avatar_url":"https://avatars0.githubusercontent.com/u/2821688?v=4","gravatar_id":"","url":"https://api.github.com/users/HanielB","html_url":"https://github.com/HanielB","followers_url":"https://api.github.com/users/HanielB/followers","following_url":"https://api.github.com/users/HanielB/following{/other_user}","gists_url":"https://api.github.com/users/HanielB/gists{/gist_id}","starred_url":"https://api.github.com/users/HanielB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HanielB/subscriptions","organizations_url":"https://api.github.com/users/HanielB/orgs","repos_url":"https://api.github.com/users/HanielB/repos","events_url":"https://api.github.com/users/HanielB/events{/privacy}","received_events_url":"https://api.github.com/users/HanielB/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/HanielB/CVC4","description":"CVC4 is an efficient open-source automatic theorem prover for satisfiability modulo theories (SMT) problems.","fork":true,"url":"https://api.github.com/repos/HanielB/CVC4","forks_url":"https://api.github.com/repos/HanielB/CVC4/forks","keys_url":"https://api.github.com/repos/HanielB/CVC4/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HanielB/CVC4/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HanielB/CVC4/teams","hooks_url":"https://api.github.com/repos/HanielB/CVC4/hooks","issue_events_url":"https://api.github.com/repos/HanielB/CVC4/issues/events{/number}","events_url":"https://api.github.com/repos/HanielB/CVC4/events","assignees_url":"https://api.github.com/repos/HanielB/CVC4/assignees{/user}","branches_url":"https://api.github.com/repos/HanielB/CVC4/branches{/branch}","tags_url":"https://api.github.com/repos/HanielB/CVC4/tags","blobs_url":"https://api.github.com/repos/HanielB/CVC4/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HanielB/CVC4/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HanielB/CVC4/git/refs{/sha}","trees_url":"https://api.github.com/repos/HanielB/CVC4/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HanielB/CVC4/statuses/{sha}","languages_url":"https://api.github.com/repos/HanielB/CVC4/languages","stargazers_url":"https://api.github.com/repos/HanielB/CVC4/stargazers","contributors_url":"https://api.github.com/repos/HanielB/CVC4/contributors","subscribers_url":"https://api.github.com/repos/HanielB/CVC4/subscribers","subscription_url":"https://api.github.com/repos/HanielB/CVC4/subscription","commits_url":"https://api.github.com/repos/HanielB/CVC4/commits{/sha}","git_commits_url":"https://api.github.com/repos/HanielB/CVC4/git/commits{/sha}","comments_url":"https://api.github.com/repos/HanielB/CVC4/comments{/number}","issue_comment_url":"https://api.github.com/repos/HanielB/CVC4/issues/comments{/number}","contents_url":"https://api.github.com/repos/HanielB/CVC4/contents/{+path}","compare_url":"https://api.github.com/repos/HanielB/CVC4/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HanielB/CVC4/merges","archive_url":"https://api.github.com/repos/HanielB/CVC4/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HanielB/CVC4/downloads","issues_url":"https://api.github.com/repos/HanielB/CVC4/issues{/number}","pulls_url":"https://api.github.com/repos/HanielB/CVC4/pulls{/number}","milestones_url":"https://api.github.com/repos/HanielB/CVC4/milestones{/number}","notifications_url":"https://api.github.com/repos/HanielB/CVC4/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HanielB/CVC4/labels{/name}","releases_url":"https://api.github.com/repos/HanielB/CVC4/releases{/id}","deployments_url":"https://api.github.com/repos/HanielB/CVC4/deployments","created_at":"2017-11-04T00:26:50Z","updated_at":"2018-04-27T03:21:44Z","pushed_at":"2018-04-27T04:37:08Z","git_url":"git://github.com/HanielB/CVC4.git","ssh_url":"git@github.com:HanielB/CVC4.git","clone_url":"https://github.com/HanielB/CVC4.git","svn_url":"https://github.com/HanielB/CVC4","homepage":null,"size":44501,"stargazers_count":0,"watchers_count":0,"language":"SMT","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"CVC4:master","ref":"master","sha":"68a994dbb7527b6f98975bbb776687413f23d451","user":{"login":"CVC4","id":2973223,"avatar_url":"https://avatars0.githubusercontent.com/u/2973223?v=4","gravatar_id":"","url":"https://api.github.com/users/CVC4","html_url":"https://github.com/CVC4","followers_url":"https://api.github.com/users/CVC4/followers","following_url":"https://api.github.com/users/CVC4/following{/other_user}","gists_url":"https://api.github.com/users/CVC4/gists{/gist_id}","starred_url":"https://api.github.com/users/CVC4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CVC4/subscriptions","organizations_url":"https://api.github.com/users/CVC4/orgs","repos_url":"https://api.github.com/users/CVC4/repos","events_url":"https://api.github.com/users/CVC4/events{/privacy}","received_events_url":"https://api.github.com/users/CVC4/received_events","type":"Organization","site_admin":false},"repo":{"id":7040894,"name":"CVC4","full_name":"CVC4/CVC4","owner":{"login":"CVC4","id":2973223,"avatar_url":"https://avatars0.githubusercontent.com/u/2973223?v=4","gravatar_id":"","url":"https://api.github.com/users/CVC4","html_url":"https://github.com/CVC4","followers_url":"https://api.github.com/users/CVC4/followers","following_url":"https://api.github.com/users/CVC4/following{/other_user}","gists_url":"https://api.github.com/users/CVC4/gists{/gist_id}","starred_url":"https://api.github.com/users/CVC4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CVC4/subscriptions","organizations_url":"https://api.github.com/users/CVC4/orgs","repos_url":"https://api.github.com/users/CVC4/repos","events_url":"https://api.github.com/users/CVC4/events{/privacy}","received_events_url":"https://api.github.com/users/CVC4/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CVC4/CVC4","description":"CVC4 is an efficient open-source automatic theorem prover for satisfiability modulo theories (SMT) problems.","fork":false,"url":"https://api.github.com/repos/CVC4/CVC4","forks_url":"https://api.github.com/repos/CVC4/CVC4/forks","keys_url":"https://api.github.com/repos/CVC4/CVC4/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CVC4/CVC4/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CVC4/CVC4/teams","hooks_url":"https://api.github.com/repos/CVC4/CVC4/hooks","issue_events_url":"https://api.github.com/repos/CVC4/CVC4/issues/events{/number}","events_url":"https://api.github.com/repos/CVC4/CVC4/events","assignees_url":"https://api.github.com/repos/CVC4/CVC4/assignees{/user}","branches_url":"https://api.github.com/repos/CVC4/CVC4/branches{/branch}","tags_url":"https://api.github.com/repos/CVC4/CVC4/tags","blobs_url":"https://api.github.com/repos/CVC4/CVC4/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CVC4/CVC4/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CVC4/CVC4/git/refs{/sha}","trees_url":"https://api.github.com/repos/CVC4/CVC4/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CVC4/CVC4/statuses/{sha}","languages_url":"https://api.github.com/repos/CVC4/CVC4/languages","stargazers_url":"https://api.github.com/repos/CVC4/CVC4/stargazers","contributors_url":"https://api.github.com/repos/CVC4/CVC4/contributors","subscribers_url":"https://api.github.com/repos/CVC4/CVC4/subscribers","subscription_url":"https://api.github.com/repos/CVC4/CVC4/subscription","commits_url":"https://api.github.com/repos/CVC4/CVC4/commits{/sha}","git_commits_url":"https://api.github.com/repos/CVC4/CVC4/git/commits{/sha}","comments_url":"https://api.github.com/repos/CVC4/CVC4/comments{/number}","issue_comment_url":"https://api.github.com/repos/CVC4/CVC4/issues/comments{/number}","contents_url":"https://api.github.com/repos/CVC4/CVC4/contents/{+path}","compare_url":"https://api.github.com/repos/CVC4/CVC4/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CVC4/CVC4/merges","archive_url":"https://api.github.com/repos/CVC4/CVC4/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CVC4/CVC4/downloads","issues_url":"https://api.github.com/repos/CVC4/CVC4/issues{/number}","pulls_url":"https://api.github.com/repos/CVC4/CVC4/pulls{/number}","milestones_url":"https://api.github.com/repos/CVC4/CVC4/milestones{/number}","notifications_url":"https://api.github.com/repos/CVC4/CVC4/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CVC4/CVC4/labels{/name}","releases_url":"https://api.github.com/repos/CVC4/CVC4/releases{/id}","deployments_url":"https://api.github.com/repos/CVC4/CVC4/deployments","created_at":"2012-12-06T18:45:04Z","updated_at":"2018-04-26T17:00:03Z","pushed_at":"2018-04-27T04:37:09Z","git_url":"git://github.com/CVC4/CVC4.git","ssh_url":"git@github.com:CVC4/CVC4.git","clone_url":"https://github.com/CVC4/CVC4.git","svn_url":"https://github.com/CVC4/CVC4","homepage":null,"size":43696,"stargazers_count":192,"watchers_count":192,"language":"SMT","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":81,"mirror_url":null,"archived":false,"open_issues_count":197,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":81,"open_issues":197,"watchers":192,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CVC4/CVC4/pulls/1819"},"html":{"href":"https://github.com/CVC4/CVC4/pull/1819"},"issue":{"href":"https://api.github.com/repos/CVC4/CVC4/issues/1819"},"comments":{"href":"https://api.github.com/repos/CVC4/CVC4/issues/1819/comments"},"review_comments":{"href":"https://api.github.com/repos/CVC4/CVC4/pulls/1819/comments"},"review_comment":{"href":"https://api.github.com/repos/CVC4/CVC4/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CVC4/CVC4/pulls/1819/commits"},"statuses":{"href":"https://api.github.com/repos/CVC4/CVC4/statuses/4e5bc1d198e95c5c2403912a64cb20fc7d0a96da"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ajreynol"}}