EventLattice-checkpoint.ipynb 2.49 KB
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "57fc5921-9d6b-4b43-a8f6-743a03650d63",
   "metadata": {},
   "outputs": [],
   "source": [
    "import event_lattice as el"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "00f0eb68",
   "metadata": {},
   "outputs": [],
   "source": [
    "def zoom_event(event_str, lattice, lower_op=el.sum_op, upper_op=el.prod_op):\n",
    "    event = el.Event.from_str(event_str)\n",
    "    event_class = lattice.event_class(event)\n",
    "    propagated = lattice.propagated_value(\n",
    "        event, lower_op=lower_op, upper_op=upper_op)\n",
    "\n",
    "    print(\n",
    "        f\"Event: {event}\\n\\tClass: {event_class} \\n\\tValue: {propagated}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cdd8c6d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "smodels = el.Lattice.parse({\n",
    "    \"A\": 2,\n",
    "    \"ab\": 3,\n",
    "    \"ac\": 5\n",
    "})\n",
    "\n",
    "lattice = el.Lattice(smodels)\n",
    "\n",
    "print(lattice)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2b445339",
   "metadata": {},
   "outputs": [],
   "source": [
    "zoom_event(\"abc\", lattice)\n",
    "zoom_event(\"a\", lattice)\n",
    "zoom_event(\"b\", lattice)\n",
    "zoom_event(\"bc\", lattice)\n",
    "zoom_event(\"ac\", lattice)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f1b85255",
   "metadata": {},
   "outputs": [],
   "source": [
    "from itertools import *\n",
    "\n",
    "lits = lattice.literals()\n",
    "for len_lit in range(len(lits)+1):\n",
    "    events = list(\"\".join(c) for c in combinations(lits, len_lit))\n",
    "    for event in events:\n",
    "        zoom_event(event, lattice)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "07973a47",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.9.13 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  },
  "vscode": {
   "interpreter": {
    "hash": "a59afa236e16843183c59a167f072b6fa0409044b3c4938e82ac98aad91bf217"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}