How to present boolean options along with selecting exactly 1 of them as “primary”?

I have a situation in a web browser where I have a number (let’s say 3-10) of alternatives to present to the user.

  • The end user must choose at least one of these options to be enabled
  • The end user must choose exactly one of the enabled options to be the “primary” option.

I’m not sure how best to do this, though. Here’s a contrived situation about a stew that might help illustrate this better:

enter image description here

There are 7 potential ingredients, the user has to enable or disable each of them (cries out for a checkbox) but at least one of them has to be enabled; and exactly one of them must be the primary ingredient (cries out for a radio button).

  • If I choose a dumb form with no constraint checking, this is easy to implement, but they could choose Beef, Pork, and Carrots as the enabled ingredients and then Potatoes as the primary ingredient (which is a problem since they did not check the Potatoes box among the enabled ingredients)

  • Or I could put the primary ingredient first, then allow them to select secondary ingredients, and force the primary ingredient to be selected in the list of secondary ingredients (beef in the example below) and not allow it to be unselected. Not too hard to implement in HTML / Javascript, but then there’s some trickiness… what if I start with the UI state below, then select the primary ingredient as Onions, then as Chicken, and then Pork? What happens to the checkboxes for Onions, Chicken, and Beef?

enter image description here

Both of these options require duplicating the list twice.

  • Or I could try to use some kind of multichoice slider to select the primary ingredient… which would eliminate the need to duplicate the list… but this isn’t a built-in HTML feature and I’d have to roll my own or try to apply some 3rd-party UI element.

  • Or I could place a radiobutton and a checkbox in front of each ingredient (radiobutton for primary ingredient, checkbox to enable non-primary ingredients) which is compact and simple in presentation, but most likely confusing in semantics.

Any suggestions?

Addition, multiplication, and apostrophe used to represent boolean algebra expressions?

I’m looking at a worksheet that expresses boolean logic expressions using multiplication, addition, and apostrophes; something I’ve never seen before.

I can make a guess that the apostrophe is equivalent to ¬ (except it’s suffixed instead of prefixed). But I’m not sure what the addition and multiplication of the variables/propositional atoms would mean. Furthermore, I don’t know how a boolean logic formula can “output” something other than just a truth value…

I can’t seem to piece together with certainty the meaning of this representation. Could anyone take a look at the below example and maybe make a guess as to a translation of this representation to the more traditional ^, v, and ¬ symbols?

This arose in the context of digital logic in terms of logic gates and such on a CPU, if that makes a difference.

enter image description here

An alleged truth table of the above two expressions (the first row is filled in as an example):

enter image description here

All 16 Boolean Logic Gates

I was doing some reseach and I came across a website that had listed 16 different boolean logic operators. I was wondering if all of them were real, and if so, what do they do.

Does the naive conversion of a Boolean Formula to CNF have a polynomial or exponential complexity?

I am reading the naive conversion to CNF, this procedure is explaining in this book book, but I have not found a conplexity analysis of this algorithm:

  1. elimination of equivalence
  2. Elimination of Implications
  3. elimination of double negation
  4. De Morgan Laws
  5. distributive law

I found one implementation of this method in this Repo


Simplifying the Boolean expression $A + \bar{A}\bar{B}$?

So I’m trying to simplify the Boolean expression (1) $ A + \bar{A}\bar{B}$ .

I noticed that by Karnaugh maps this is equivalent to $ A+\bar{B}$ , and I also noticed that if I take the complement of (1), I get ~(1)= $ \bar{A}(A + B) = \bar{A}A + \bar{A}B = \bar{A}B$ , so then taking complements again yields (1) = $ A + \bar{B}$ .

But this feels very ad hoc to me, and makes me feel like I’m missing some key point about how to simplify this expression more systematically.

Any thoughts appreciated.


Set injection method to Boolean blind rather than time based

So I’ve managed to break into the database and I’m given the following vulnerabilities

Parameter: postids (GET) Type: boolean-based blind Title: Boolean-based blind - Parameter replace (original value) Payload: d=1&cmd=get_spam_data&postids=(SELECT (CASE WHEN (1972=1972) THEN 2 ELSE (SELECT 1472 UNION SELECT 7373) END))  Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: d=1&cmd=get_spam_data&postids=2 AND (SELECT 9066 FROM (SELECT(SLEEP(5)))VKKG) 

When I run a db query it seems to default to time based instead of the faster boolean based. I’m not interested in waiting an hour for the database search to finish. I tried the default –technique value which does boolean first but it still defaults to time-based.

Name for design pattern used in complex or boolean search criteria

I am looking to see if there is a term that describes this type of design pattern or if there are well known examples of its implementation.

This is an extension of the design pattern where a search term is entered into an input field and becomes a filter/criteria for a search query (e.g. e-commerce website) or tagging of an entity (e.g. UXSE question).

In the diagram below, there are two input fields from which a user can select a combination of the values provided in each list (and it might have some logic embedded depending on the value selected). The values are then combined and presented as a lozenge/badge/chip UI element that can be selected and deleted.

enter image description here

Are there examples of this type of design pattern used anywhere? And is there a name that is commonly associated with it?