passagemath-standard-no-symbolics 10.6.31rc3__cp314-cp314-macosx_13_0_arm64.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.
Potentially problematic release.
This version of passagemath-standard-no-symbolics might be problematic. Click here for more details.
- passagemath_standard_no_symbolics-10.6.31rc3.data/scripts/sage-grep +5 -0
- passagemath_standard_no_symbolics-10.6.31rc3.data/scripts/sage-grepdoc +5 -0
- passagemath_standard_no_symbolics-10.6.31rc3.data/scripts/sage-list-packages +103 -0
- passagemath_standard_no_symbolics-10.6.31rc3.dist-info/METADATA +151 -0
- passagemath_standard_no_symbolics-10.6.31rc3.dist-info/RECORD +82 -0
- passagemath_standard_no_symbolics-10.6.31rc3.dist-info/WHEEL +6 -0
- passagemath_standard_no_symbolics-10.6.31rc3.dist-info/top_level.txt +1 -0
- sage/all.py +207 -0
- sage/all_cmdline.py +36 -0
- sage/cli/__init__.py +61 -0
- sage/cli/__main__.py +5 -0
- sage/cli/eval_cmd.py +45 -0
- sage/cli/eval_cmd_test.py +25 -0
- sage/cli/interactive_shell_cmd.py +28 -0
- sage/cli/notebook_cmd.py +51 -0
- sage/cli/notebook_cmd_test.py +39 -0
- sage/cli/options.py +26 -0
- sage/cli/run_file_cmd.py +50 -0
- sage/cli/version_cmd.py +26 -0
- sage/databases/all.py +83 -0
- sage/databases/cubic_hecke_db.py +1527 -0
- sage/dynamics/all.py +31 -0
- sage/dynamics/surface_dynamics_deprecation.py +32 -0
- sage/ext_data/kenzo/CP2.txt +45 -0
- sage/ext_data/kenzo/CP3.txt +349 -0
- sage/ext_data/kenzo/CP4.txt +4774 -0
- sage/ext_data/kenzo/README.txt +49 -0
- sage/ext_data/kenzo/S4.txt +20 -0
- sage/ext_data/mwrank/PRIMES +1 -0
- sage/ext_data/nbconvert/postprocess.py +48 -0
- sage/ext_data/nbconvert/rst_sage.tpl +99 -0
- sage/ext_data/nodoctest +0 -0
- sage/ext_data/notebook-ipython/kernel.json.in +11 -0
- sage/ext_data/notebook-ipython/logo-64x64.png +0 -0
- sage/ext_data/notebook-ipython/logo.svg +352 -0
- sage/ext_data/valgrind/pyalloc.supp +58 -0
- sage/ext_data/valgrind/sage-additional.supp +417 -0
- sage/ext_data/valgrind/sage.supp +43 -0
- sage/ext_data/valgrind/valgrind-python.supp +480 -0
- sage/geometry/all.py +12 -0
- sage/groups/matrix_gps/pickling_overrides.py +110 -0
- sage/homology/tests.py +66 -0
- sage/interacts/algebra.py +20 -0
- sage/interacts/all.py +25 -0
- sage/interacts/calculus.py +24 -0
- sage/interacts/fractals.py +18 -0
- sage/interacts/geometry.py +19 -0
- sage/interacts/library.py +1950 -0
- sage/interacts/library_cython.cpython-314-darwin.so +0 -0
- sage/interacts/statistics.py +19 -0
- sage/interfaces/axiom.py +1002 -0
- sage/interfaces/kash.py +834 -0
- sage/interfaces/lie.py +950 -0
- sage/interfaces/matlab.py +413 -0
- sage/interfaces/mupad.py +686 -0
- sage/interfaces/octave.py +858 -0
- sage/interfaces/phc.py +943 -0
- sage/interfaces/psage.py +189 -0
- sage/interfaces/qsieve.py +4 -0
- sage/interfaces/r.py +2096 -0
- sage/interfaces/read_data.py +46 -0
- sage/interfaces/scilab.py +576 -0
- sage/interfaces/tests.py +81 -0
- sage/libs/all.py +11 -0
- sage/libs/cremona/__init__.py +0 -0
- sage/libs/mwrank/__init__.py +0 -0
- sage/logic/all.py +3 -0
- sage/logic/booleval.py +160 -0
- sage/logic/boolformula.py +1490 -0
- sage/logic/logic.py +856 -0
- sage/logic/logicparser.py +696 -0
- sage/logic/logictable.py +272 -0
- sage/logic/propcalc.py +311 -0
- sage/misc/all.py +28 -0
- sage/misc/lazy_attribute.pyi +11 -0
- sage/rings/all.py +48 -0
- sage/rings/commutative_algebra.py +38 -0
- sage/rings/finite_rings/all.py +21 -0
- sage/rings/numbers_abc.py +58 -0
- sage/rings/polynomial/all.py +22 -0
- sage/rings/polynomial/convolution.py +421 -0
- sage/symbolic/all__sagemath_standard_no_symbolics.py +0 -0
|
File without changes
|
sage/logic/all.py
ADDED
sage/logic/booleval.py
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
r"""
|
|
2
|
+
Evaluation of Boolean Formulas
|
|
3
|
+
|
|
4
|
+
AUTHORS:
|
|
5
|
+
|
|
6
|
+
- Chris Gorecki (2006): initial version
|
|
7
|
+
|
|
8
|
+
- Paul Scurek (2013-08-05): updated docstring formatting
|
|
9
|
+
|
|
10
|
+
EXAMPLES:
|
|
11
|
+
|
|
12
|
+
We can assign values to the variables and evaluate a formula::
|
|
13
|
+
|
|
14
|
+
sage: import sage.logic.booleval as booleval
|
|
15
|
+
sage: t = ['|', ['&', 'a', 'b'], ['&', 'a', 'c']]
|
|
16
|
+
sage: d = {'a' : True, 'b' : False, 'c' : True}
|
|
17
|
+
sage: booleval.eval_formula(t, d)
|
|
18
|
+
True
|
|
19
|
+
|
|
20
|
+
We can change our assignment of values by modifying the dictionary::
|
|
21
|
+
|
|
22
|
+
sage: d['a'] = False
|
|
23
|
+
sage: booleval.eval_formula(t, d)
|
|
24
|
+
False
|
|
25
|
+
"""
|
|
26
|
+
# ****************************************************************************
|
|
27
|
+
# Copyright (C) 2006 Chris Gorecki <chris.k.gorecki@gmail.com>
|
|
28
|
+
# Copyright (C) 2013 Paul Scurek <scurek86@gmail.com>
|
|
29
|
+
#
|
|
30
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
31
|
+
# as published by the Free Software Foundation; either version 2 of
|
|
32
|
+
# the License, or (at your option) any later version.
|
|
33
|
+
# https://www.gnu.org/licenses/
|
|
34
|
+
# ****************************************************************************
|
|
35
|
+
|
|
36
|
+
from . import logicparser
|
|
37
|
+
|
|
38
|
+
# dictionary containing variable keys and boolean values
|
|
39
|
+
__vars = {}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def eval_formula(tree, vdict):
|
|
43
|
+
r"""
|
|
44
|
+
Evaluate the tree and return a boolean value.
|
|
45
|
+
|
|
46
|
+
INPUT:
|
|
47
|
+
|
|
48
|
+
- ``tree`` -- list of three elements corresponding to a branch of a
|
|
49
|
+
parse tree
|
|
50
|
+
|
|
51
|
+
- ``vdict`` -- dictionary containing variable keys and boolean values
|
|
52
|
+
|
|
53
|
+
OUTPUT: the result of the evaluation as a boolean value
|
|
54
|
+
|
|
55
|
+
EXAMPLES:
|
|
56
|
+
|
|
57
|
+
This example illustrates evaluating a boolean formula::
|
|
58
|
+
|
|
59
|
+
sage: import sage.logic.booleval as booleval
|
|
60
|
+
sage: t = ['|', ['&', 'a', 'b'], ['&', 'a', 'c']]
|
|
61
|
+
sage: d = {'a' : True, 'b' : False, 'c' : True}
|
|
62
|
+
sage: booleval.eval_formula(t, d)
|
|
63
|
+
True
|
|
64
|
+
|
|
65
|
+
::
|
|
66
|
+
|
|
67
|
+
sage: d['a'] = False
|
|
68
|
+
sage: booleval.eval_formula(t, d)
|
|
69
|
+
False
|
|
70
|
+
"""
|
|
71
|
+
global __vars
|
|
72
|
+
__vars = vdict
|
|
73
|
+
return logicparser.apply_func(tree, eval_f)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def eval_f(tree):
|
|
77
|
+
r"""
|
|
78
|
+
Evaluate the tree.
|
|
79
|
+
|
|
80
|
+
INPUT:
|
|
81
|
+
|
|
82
|
+
- ``tree`` -- list of three elements corresponding to a branch of a
|
|
83
|
+
parse tree
|
|
84
|
+
|
|
85
|
+
OUTPUT: the result of the evaluation as a boolean value
|
|
86
|
+
|
|
87
|
+
EXAMPLES:
|
|
88
|
+
|
|
89
|
+
This example illustrates how to evaluate a parse tree::
|
|
90
|
+
|
|
91
|
+
sage: import sage.logic.booleval as booleval
|
|
92
|
+
sage: booleval.eval_f(['&', True, False])
|
|
93
|
+
False
|
|
94
|
+
|
|
95
|
+
sage: booleval.eval_f(['^', True, True])
|
|
96
|
+
False
|
|
97
|
+
|
|
98
|
+
sage: booleval.eval_f(['|', False, True])
|
|
99
|
+
True
|
|
100
|
+
"""
|
|
101
|
+
return eval_op(tree[0], tree[1], tree[2])
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def eval_op(op, lv, rv):
|
|
105
|
+
r"""
|
|
106
|
+
Evaluate ``lv`` and ``rv`` according to the operator ``op``.
|
|
107
|
+
|
|
108
|
+
INPUT:
|
|
109
|
+
|
|
110
|
+
- ``op`` -- string or character representing a boolean operator
|
|
111
|
+
|
|
112
|
+
- ``lv`` -- boolean or variable
|
|
113
|
+
|
|
114
|
+
- ``rv`` -- boolean or variable
|
|
115
|
+
|
|
116
|
+
OUTPUT: the evaluation of ``lv op rv`` as a boolean value
|
|
117
|
+
|
|
118
|
+
EXAMPLES:
|
|
119
|
+
|
|
120
|
+
We can evaluate an operator given the values on either side::
|
|
121
|
+
|
|
122
|
+
sage: import sage.logic.booleval as booleval
|
|
123
|
+
sage: booleval.eval_op('&', True, False)
|
|
124
|
+
False
|
|
125
|
+
|
|
126
|
+
sage: booleval.eval_op('^', True, True)
|
|
127
|
+
False
|
|
128
|
+
|
|
129
|
+
sage: booleval.eval_op('|', False, True)
|
|
130
|
+
True
|
|
131
|
+
"""
|
|
132
|
+
lval = rval = None
|
|
133
|
+
if lv is False:
|
|
134
|
+
lval = False
|
|
135
|
+
elif lv is True:
|
|
136
|
+
lval = True
|
|
137
|
+
elif lv is not None:
|
|
138
|
+
lval = __vars[lv]
|
|
139
|
+
|
|
140
|
+
if rv is False:
|
|
141
|
+
rval = False
|
|
142
|
+
elif rv is True:
|
|
143
|
+
rval = True
|
|
144
|
+
elif rv is not None:
|
|
145
|
+
rval = __vars[rv]
|
|
146
|
+
|
|
147
|
+
if op == '~':
|
|
148
|
+
return not lval
|
|
149
|
+
elif op == '&':
|
|
150
|
+
return lval and rval
|
|
151
|
+
elif op == '|':
|
|
152
|
+
return lval or rval
|
|
153
|
+
elif op == '^':
|
|
154
|
+
return lval ^ rval
|
|
155
|
+
elif op == '->':
|
|
156
|
+
return (not lval) or rval
|
|
157
|
+
elif op == '<->':
|
|
158
|
+
return (not lval or rval) and (not rval or lval)
|
|
159
|
+
else: # one variable
|
|
160
|
+
return __vars[op]
|