MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / generate_parameters

Function generate_parameters

other/davis_putnam_logemann_loveland.py:157–181  ·  view source on GitHub ↗

| Return the clauses and symbols from a formula. | A symbol is the uncomplemented form of a literal. For example, * Symbol of A3 is A3. * Symbol of A5' is A5. >>> formula = Formula([Clause(["A1", "A2'", "A3"]), Clause(["A5'", "A2'", "A1"])]) >>> clauses, symbols =

(formula: Formula)

Source from the content-addressed store, hash-verified

155
156
157def generate_parameters(formula: Formula) -> tuple[list[Clause], list[str]]:
158 """
159 | Return the clauses and symbols from a formula.
160 | A symbol is the uncomplemented form of a literal.
161
162 For example,
163 * Symbol of A3 is A3.
164 * Symbol of A5' is A5.
165
166 >>> formula = Formula([Clause(["A1", "A2'", "A3"]), Clause(["A5'", "A2'", "A1"])])
167 >>> clauses, symbols = generate_parameters(formula)
168 >>> clauses_list = [str(i) for i in clauses]
169 >>> clauses_list
170 ["{A1 , A2' , A3}", "{A5' , A2' , A1}"]
171 >>> symbols
172 ['A1', 'A2', 'A3', 'A5']
173 """
174 clauses = formula.clauses
175 symbols_set = []
176 for clause in formula.clauses:
177 for literal in clause.literals:
178 symbol = literal[:2]
179 if symbol not in symbols_set:
180 symbols_set.append(symbol)
181 return clauses, symbols_set
182
183
184def find_pure_symbols(

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected