Skip to content

Commit

Permalink
Created using Colaboratory
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgSkv committed Mar 1, 2022
1 parent c2e604e commit 1f1a46c
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions tutorial/Logica_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"#@title Install Logica.\n",
"!pip install logica"
],
"execution_count": 9,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand All @@ -149,7 +149,7 @@
"# auth.authenticate_user()\n",
"# colab_logica.SetProject('YOUR_PROJECT')"
],
"execution_count": 10,
"execution_count": null,
"outputs": []
},
{
Expand Down Expand Up @@ -8938,7 +8938,7 @@
" w == a.z.w;\n",
" "
],
"execution_count": 12,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
Expand Down Expand Up @@ -49117,6 +49117,43 @@
"metadata": {}
}
]
},
{
"cell_type": "markdown",
"source": [
"### Injectible and Concrete predicates\n",
"\n",
"A predicate denoted with `distinct` keyword is called _aggregating_. Note that `distinct` can be implict if aggregated value.\n",
"\n",
"```\n",
"# Example 1 of aggregating predicate.\n",
"\n",
"EmployeesOfRole(role:, employees? Array= office -> name) distinct :-\n",
" Employee(name:, role:, office:)\n",
"\n",
"# Example 2 of aggregating predicate.\n",
"\n",
"EmployeesOfRoleF(role:) Array= office -> name :-\n",
" Employee(name:, role:, office:)\n",
"```\n",
"\n",
"A predicate in Logica is called _injectable_ if it is defined by a single, non-aggregating rule. Injectable predicates may contain aggregating expressions. \n",
"\n",
"A predicate is called _concrete_ if it can be computed as a table, i.e. itself compiled as a SQL query.\n",
"\n",
"Any predicate in Logica must be _injectible_ or _concrete_ or both.\n",
"\n",
"Only _concrete_ predicates can be compiled to SQL. When a predicate Q is compiled and it uses a sub-predicate P then:\n",
"\n",
"* if P is injectible, then it's substituted into the formula of Q,\n",
"\n",
"* otherwise P must be concrete, and it is compiled as a sub-query.\n",
"\n",
"Aggregating expressions are always compiled into sub-queries."
],
"metadata": {
"id": "q55qN2URLwu-"
}
}
]
}

0 comments on commit 1f1a46c

Please sign in to comment.