boolean-logic

Why can't I do boolean logic on bytes?

In C# (3.5) I try the following: byte byte1 = 0x00; byte byte2 = 0x00; byte byte3 = byte1 & byte2; and I get Error 132: "Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?)". The same happens with | and ^. What am I doing wrong? Why is it asking me about ints? Why can't I do bool...

sql query - true => true, false => true or false

Hi, Simple query, possibly impossible but I know there are some clever people out there :) Given a boolean parameter, I wish to define my where clause to either limit a certain column's output - or do nothing. So, given parameter @bit = 1 this would be the result: where column = 1 given parameter @bit = 0 this would be the result: ...

How can I build a Truth Table Generator?

I'm looking to write a Truth Table Generator as a personal project. There are several web-based online ones here and here. (Example screenshot of an existing Truth Table Generator) I have the following questions: How should I go about parsing expressions like: ((P => Q) & (Q => R)) => (P => R) Should I use a parser generator like A...

boolean equation

Can someone check if this is the right equation for the diagram: C = (Not A) AND B ...

PHP Logic - Return False of one or two out of three are not set

Hi all, I have a form that collects information, one piece of which is a phone number. The phone number data comes from three fields, one for an area code, for the first 3 digits, and for the last four, so that numbers are in this format: xxx-xxx-xxxx (basic U.S. format). These three fields are not required, but I would like to do some...

How to do true==false or true!=true in your language?

Booleans seem to be the most primitive building blocks of programming languages, because they can actually take only two (or in some cases three) "singleton" values: true, false (and sometimes undeterminded/null) But it seems that sometimes language design might allow someone to write code where actually "true is false" or "true is not ...

Boolean expressions optimizations in Java

Consider the following method in Java: public static boolean expensiveComputation() { for (int i = 0; i < Integer.MAX_VALUE; ++i); return false; } And the following main method: public static void main(String[] args) { boolean b = false; if (expensiveComputation() && b) { } } Logical conjunction (same as &&) is a commutative o...

Algorithms for optimizing conjunctive normal form expressions for particular instruction sets?

I'm using Espresso to produce a minimized form of a set of boolean equations. However rather than generating logic for a programmable array logic (which is what Espresso is normally used for), I am looking to implement these on a standard microprocessor. The trouble is that Espresso produces output in conjunctive normal form, which is pe...

How can I implement user-friendly boolean logic in a web form GUI?

Currently I have a web application where a user can use dropdown lists to generate SQL SELECT statements like so: Column Select Dropdown | Operator Dropdown (= != > < <= >=) | Value select dropdown The user can do this multiple times, and the "filters" are currently all ANDed together. I want to add the possibility of creating OR stat...

Can this boolean expression be simplified?

(A Or B) And Not (A And B) ...

Create smaller instruction set from x86 assembly

I have a sort of simulator for x86 assembly instructions, but the thing is it doesn't accept the full instruction set. For instance if given an INT command it will terminate. It is possible to run all the binary representation (8bit, 16bit and 32bit) of commands on the simulator and see which one's are valid and which are not. It is fo...

Is this really "correct" and unambiguous?

For one of my beginning CS classes, we are going over "truth functional logic." My question pertains to English translations. Note that ^ is AND; v is (inclusive)OR; ~ is NOT. -> is IF Well, we had this: "RENT being paid is a necessary condition for staying in BUSINESS" RENT -> BUSINESS Whenever we graded everything this was wron...

Python nested lists and recursion problem

Hi guys, I posted this question under an alter yesterday not realising my account was still active after 9 months, sorry for the double post, i've fixed an error in my example pointed out by jellybean and i'll elaborate further on the context of the problem. I'm trying to process a first order logic formula represented as nested lists ...

Boolean Implication

I need some help with this Boolean Implication. Can someone explain how this works in simple terms: A implies B = B + A' (if A then B). Also equivalent to A >= B ...

Need guidance towards evaluative boolean logic tree

I can't seem to find a pointer in the right direction, I am not even sure what the terms are that I should be researching but countless hours of googling seem to be spinning me in circles, so hopefully the collective hive of intelligence of Stack Overflow can help. The problem is this, I need a way to filter data in what I can only call...

What is an appropriate data structure and database schema to store logic rules?

Preface: I don't have experience with rules engines, building rules, modeling rules, implementing data structures for rules, or whatnot. Therefore, I don't know what I'm doing or if what I attempted below is way off base. I'm trying to figure out how to store and process the following hypothetical scenario. To simplify my problem, say t...

Using [0,1] versus ["Y","N"] versus ["T","F"] in a logical/boolean database field?

Just out of curiosity and lack of a definite answer... I was just looking at some data that is sent from a 3rd party to us, and their "Gender" field is a [0,1] denoting either a Female (0) or a Male (1). Is there any better reason to use [0,1] over ["F","M"]? Does it depend on the scenario and the intuitiveness between a field and its...

Filter strings: and, or, minus to exclude

Do you know any solution for building string filters based on human input in PHP? E.g. foo and bar -zoo (like in search enginies) is converted to regex similar to this: .*(foo|bar).*^(zoo).*. I have found this class, but this is not exactly what I am looking for. ...

Boolean expression order of evaluation in Java?

Suppose I have the following expression String myString = getStringFromSomeExternalSource(); if (myString != null && myString.trim().length() != 0) { ... } Eclipse warns me that myString might be null in the second phrase of the boolean expression. However, I know some that some compilers will exit the boolean expression entirely if t...

Simplifying if statement logic

I have seperated out a test to determine if two schedule items overlap because of the unreadability of it. Is there any application to assist in simplifying a logic statement? Example: (originally a faulty example, but exposes reasons I request this) if (x < y && y < z && x < z) could be reduced to if (x < y && y < z) My code ...