EventLattice-checkpoint.ipynb
2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{
"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
}