boolean-logic

Why are products called minterms and sums called maxterms?

血红的双手。 提交于 2020-01-11 15:30:09
问题 Do they have a reason for doing so? I mean, in the sum of minterms, you look for the terms with the output 1; I don't get why they call it "minterms." Why not maxterms because 1 is well bigger than 0? Is there a reason behind this that I don't know? Or should I just accept it without asking why? 回答1: The convention for calling these terms "minterms" and "maxterms" does not correspond to 1 being greater than 0. I think the best way to answer is with an example: Say that you have a circuit and

Validate a Boolean expression with brackets in C#

喜欢而已 提交于 2020-01-11 08:20:57
问题 I want to validate a string in C# that contains a Boolean expression with brackets. The string should only contain numbers 1-9, round brackets, "OR" , "AND". Examples of good strings: "1 AND 2" "2 OR 4" "4 AND (3 OR 5)" "2" And so on... I am not sure if Regular Expression are flexible enough for this task. Is there a nice short way of achieving this in C# ? 回答1: It's probably simpler to do this with a simple parser. But you can do this with .NET regex by using balancing groups and realizing

Algorithm to Calculate Density of Boolean Function

爱⌒轻易说出口 提交于 2020-01-06 19:09:08
问题 I'm trying to write a program that requires the calculation of a specific value dealing with Boolean functions. Given a single-output Boolean function f, given by a cover F, let's say I define the density of the function as the fraction of all input vectors where the function has the value 1. For example, suppose I pass in the given function f(a, b, c) which is defined by cover F = ab'+c'. The function has 5 ON-set minterms, and 8 total minterms, hence its density is d(f) = 5/8 = 0.625. It

How to test multiple variables against a value?

偶尔善良 提交于 2020-01-06 13:05:41
问题 I'm trying to make a function that will compare multiple variables to an integer and output a string of three letters. I was wondering if there was a way to translate this into Python. So say: x = 0 y = 1 z = 3 mylist = [] if x or y or z == 0 : mylist.append("c") if x or y or z == 1 : mylist.append("d") if x or y or z == 2 : mylist.append("e") if x or y or z == 3 : mylist.append("f") which would return a list of ["c", "d", "f"] Is something like this possible? 回答1: You misunderstand how

How to test multiple variables against a value?

霸气de小男生 提交于 2020-01-06 13:04:49
问题 I'm trying to make a function that will compare multiple variables to an integer and output a string of three letters. I was wondering if there was a way to translate this into Python. So say: x = 0 y = 1 z = 3 mylist = [] if x or y or z == 0 : mylist.append("c") if x or y or z == 1 : mylist.append("d") if x or y or z == 2 : mylist.append("e") if x or y or z == 3 : mylist.append("f") which would return a list of ["c", "d", "f"] Is something like this possible? 回答1: You misunderstand how

Aggregate boolean values to true if any of the source columns is true

半城伤御伤魂 提交于 2020-01-04 03:56:07
问题 Let say I have the following table: id column_a column_b column_c 1 t f t 2 t f f 3 f t f From the above table, I want to: select rows from id = 1,2; The result should be: column_a column_b column_c t f t If any of the rows among the defined id has a true for a particular column we assume the result to be true. 回答1: Use the aggregate function bool_or(). SELECT bool_or(column_a) AS column_a , bool_or(column_b) AS column_b , bool_or(column_c) AS column_c FROM tbl WHERE id IN (1,2); The manual:

Tool to refactor boolean expressions [closed]

99封情书 提交于 2020-01-03 10:43:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I'm looking for a tool to refactor boolean expression. I've got expressions like a1 => (b1 <=> c or d) AND a2 => (b2 <=> c or d) AND a2 => (b2 <=> c or d) The tool should be able to simplify expressions, e.g. extract the sub expression "c or d" in the example above. Is there a free computer algebra system which

LESS docs on guarded mixins — why will this rule not match any mixins?

♀尐吖头ヾ 提交于 2020-01-02 15:02:38
问题 Having primarily used SASS when writing CSS, I am now preparing to try out LESS as well. Having a read through the docs, I'm confused with the following in the context of guarded mixins: Additionally, the keyword true is the only truthy value, making these two mixins equivalent: .truth (@a) when (@a) { ... } .truth (@a) when (@a = true) { ... } Any value other than the keyword true is falsy: .class { .truth(40); // Will not match any of the above definitions. } Why will truth(40) not match

Tool to solve propositional logic / boolean expressions (SAT Solver?)

戏子无情 提交于 2020-01-02 05:16:20
问题 I am new to the topic of propositional logic and boolean expressions. So this is why I need help. Here is my problem: In the car industry you have thousand of different variants of components available to choose from when you buy a car. Not every component is combinable, so for each car there exist a lot of rules that are expressed in propositional logic. In my case each car has between 2000 and 4000 rules. They look like this: A → B ∨ C ∨ D C → ¬F F ∧ G → D ... where "∧" = "and" / "∨" = "or"

What's the difference between the dual and the complement of a boolean expression?

☆樱花仙子☆ 提交于 2020-01-01 01:18:30
问题 Its the same thing right? Or is there a slight difference? I just wanna make sure I'm not misunderstanding anything. 回答1: Boolean duals are generated by simply replacing ANDs with ORs and ORs with ANDs. The complements themselves are unaffected, where as the complement of an expression is the negation of the variables WITH the replacement of ANDs with ORs and vice versa. Consider: A+B Complement: A'B' Dual: AB 回答2: "The Dual of an identity is also an identity. This is called the Duality