{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b5e62be9-cada-42d2-a2bb-7f3ee38aec51",
   "metadata": {},
   "source": [
    "# Playground"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "df1eaaad-6ad2-4601-8d12-3b02d9254bfa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 43604 characters]"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from galois import GF\n",
    "\n",
    "from oraqle.compiler.boolean.bool_or import any_\n",
    "from oraqle.compiler.circuit import Circuit\n",
    "from oraqle.compiler.nodes.leafs import Input\n",
    "\n",
    "gf = GF(5)\n",
    "\n",
    "xs = [Input(f\"x{i}\", gf) for i in range(11)]\n",
    "\n",
    "output = any_(*xs)\n",
    "\n",
    "circuit = Circuit(outputs=[output])\n",
    "circuit.display_graph()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ce27d985-b20c-4f7e-a303-929598c61c17",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 323556 characters]"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "naive_arithmetic_circuit = circuit.arithmetize()\n",
    "naive_arithmetic_circuit.display_graph()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d5c0531f-f50b-4852-b81c-833a813eb235",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4 8.0\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 124004 characters]"
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5 7.0\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 130380 characters]"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for depth, cost, arithmetic_circuit in circuit.arithmetize_depth_aware():\n",
    "    print(depth, cost)\n",
    "    arithmetic_circuit.display_graph()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
