pyfunctionhood 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyfunctionhood
3
+ Version: 0.1.0
4
+ Summary: Local computation of immediate neighbours of a given monotone non-degenerate Boolean function
5
+ Author: Patrícia Roxo, José E. R. Cury, Vasco Manquinho, Claudine Chaouiya
6
+ Author-email: "Pedro T. Monteiro" <pedro@pedromonteiro.org>
7
+ License: AGPL-3.0
8
+ Project-URL: Homepage, https://github.com/ptgm/pyfunctionhood
9
+ Project-URL: Repository, https://github.com/ptgm/pyfunctionhood
10
+ Keywords: boolean,monotone,hasse-diagram,functions,bitarray
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3
20
+ Classifier: Intended Audience :: Science/Research
21
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: bitarray
26
+ Dynamic: license-file
27
+
28
+ pyFunctionHood: local computation of immediate neighbours of a given monotone non-degenerate Boolean function
29
+ =================================================================================
30
+
31
+ This Python library implements the set of rules described in [arxiv:2407.01337](https://arxiv.org/abs/2407.01337), to compute the immediate neighbours of a given monotone non-degenerate Boolean function, without the need to generate the whole function space.
32
+
33
+ Here, immediate neighbours, are the monotone Boolean functions that are immediately above (or below) with respect to the partial order, in other words, are the functions that add/remove the minimum number of entries in the truth table.
34
+
35
+ Monotone non-degenerate Boolean functions are represented as sets of clauses, where each clause is represented by the bitarray data structure, and each bit represents the presence/absence of a given variable/regulator.
36
+
37
+ This work corrects and extends our previous work available in [https://github.com/ptgm/functionhood/](https://github.com/ptgm/functionhood/), developed in Java, and described in [arxiv:1901.07623](https://arxiv.org/abs/1901.07623).
38
+
39
+ Given a reference monotone Boolean function, this library can be used in three distinct manners:
40
+ - in the command line passing the reference function as an argument
41
+ - using a graphical interface developed with Tkinter.
42
+ - as a library integrated in other tools
43
+
44
+ ---
45
+
46
+ Usage - command line
47
+ --------------------
48
+ ```
49
+ Usage example: python main.py <type> <dimension> <function>
50
+ <type>: [p]arents or [c]hildren
51
+ <dimension>: 4
52
+ <function>: "{{1,2,3},{1,3,4},{2,3,4}}"
53
+ ```
54
+
55
+ **Parents**
56
+
57
+ To compute the parents (the functions immediately above) of a given monotone Boolean function, on can call:
58
+ ```
59
+ python main.py p 4 "{{1,2,3},{1,3,4},{2,3,4}}"
60
+ R1 {{1,2,3},{1,2,4},{1,3,4},{2,3,4}}
61
+ R2 {{1,3},{2,3,4}}
62
+ R2 {{1,2,3},{3,4}}
63
+ R2 {{1,3,4},{2,3}}
64
+ ```
65
+ which yields one parent function generated by Rule 1 (adding a maximal independent clause), and three parent functions generated by Rule 2 (collapsing pairs of clauses).
66
+
67
+ **Children**
68
+
69
+ To compute the children (the functions immediately below) of a given monotone Boolean function, one just change the first parameter:
70
+ ```
71
+ python main.py c 4 "{{1,2,3},{1,3,4},{2,3,4}}"
72
+ R1 {{1,3,4},{2,3,4}}
73
+ R1 {{1,2,3},{1,3,4}}
74
+ R1 {{1,2,3},{2,3,4}}
75
+ ```
76
+
77
+ ---
78
+
79
+ Usage - Graphical interface
80
+ ---------------------------
81
+
82
+ There is also a graphical interface using Tkinter where the user can define the function dimension and write the desired monotone Boolean function.
83
+
84
+ ![Screenshot of main window](img/pyfunctionhood.png)
85
+
86
+ The interface has a button to automatically write the Infimum function of the chosen dimension, and another for the Supremum function.
87
+
88
+ The user has two buttons to generate the immediate neighbouring functions: **Generate Parents** to generate the list of parent functions, and **Generate Children** to generate the list of children functions.
89
+
90
+ In the text area the immediate neighbouring functions are shown, as well as any error if an invalid function is provided.
91
+
92
+ The button **Default values** cleans the text area and resets the input text boxes to their default values.
93
+
94
+ The button **Close** closes the application.
95
+
96
+ ---
97
+
98
+ Usage - programmatically
99
+ ------------------------
100
+
101
+ If you are using this library directly you should first initialise the Hasse Diagram with a given dimension as a parameter (example below considers monotone Boolean functions of **4** variables/regulators):
102
+ ```
103
+ from hassediagram import *
104
+ hd = HasseDiagram(4)
105
+ ```
106
+
107
+ Then to initialise a function one can use a set of Clauses, where each Clause is a String representing the regulators that are present ("1") or absent ("0"), of dimension **4**:
108
+ ```
109
+ f = Function(4, {Clause('1110'), Clause('1011'), Clause('0111')})
110
+ ```
111
+ or equivalently constructing the Function from its String representation:
112
+ ```
113
+ f = Function.fromString(4, "{{1,2,3},{1,3,4},{2,3,4}}")
114
+ ```
115
+
116
+ Once the Hasse Diagram and the function are defined, the method `hd.get_f_parents(f)` or `hd.get_f_children(f)` can be called, each returning a tuple of three sets of functions.
117
+ The functions generated by Rule 1, by Rule 2 and by Rule 3, respectively.
118
+ Below an example for parent functions generation:
119
+ ```
120
+ s1, s2, s3 = hd.get_f_parents(f)
121
+ print(f'# parents from Rule1:{len(s1)} Rule2:{len(s2)} Rule3:{len(s3)}')
122
+ print('\n'.join(['R1 ' + str(f) for f in s1]\
123
+ + ['R2 ' + str(f) for f in s2]\
124
+ + ['R3 ' + str(f) for f in s3]))
125
+ ```
126
+
127
+ ---
128
+
129
+ License
130
+ -------
131
+
132
+ This code is available under GPL-3.0.
133
+
134
+ Cite
135
+ ----
136
+
137
+ This work is available on [arxiv:2407.01337](https://arxiv.org/abs/2407.01337).
138
+
139
+ Authors
140
+ -------
141
+
142
+ - Patrícia Roxo
143
+ - José E. R. Cury
144
+ - Vasco Manquinho
145
+ - Claudine Chaouiya
146
+ - Pedro T. Monteiro
@@ -0,0 +1,12 @@
1
+ pyfunctionhood/__init__.py,sha256=OE92UysyneS395E4FgW6-Ptef5UCz0krMzhLaeCYGdE,231
2
+ pyfunctionhood/clause.py,sha256=Bnd3l8UyoLf9Ic-Wt3Oxd0yrak90oHvkiwvknVzaGNM,4280
3
+ pyfunctionhood/function.py,sha256=WE3Q7S8fyrPkv1nFEs2V9FITEytqe0hKizpufekE3Ok,3557
4
+ pyfunctionhood/hassediagram.py,sha256=F7NFvlx2MBbme__SpNRwz6f9VLOFJnq9BgM-eaKmfsg,5350
5
+ pyfunctionhood/main.py,sha256=olHPPfDfXLWsGVgE60qjRmcKOAJzCDVpR79waqupKR0,6562
6
+ pyfunctionhood/powerset.py,sha256=aHR7IfiY5ShaE6REdDioKK4eGrxHNNS7KLJf1sNlzzw,3410
7
+ pyfunctionhood-0.1.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
8
+ pyfunctionhood-0.1.0.dist-info/METADATA,sha256=lr0zuy7P1qJQktctJgM5Ikb-GDxUvxo1g7OmKY5OuCI,5955
9
+ pyfunctionhood-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ pyfunctionhood-0.1.0.dist-info/entry_points.txt,sha256=mxn9BOjwtlL0Dix8-t6gNtlZf6QM4oDyQkVTTFS_xc4,60
11
+ pyfunctionhood-0.1.0.dist-info/top_level.txt,sha256=_QWqurgqCz1zIh4kzR7yJfbIBQKnnBlKkx4axyVqrOA,15
12
+ pyfunctionhood-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pyfunctionhood = pyfunctionhood.main:main