Utvikling · verktøy

Generator for logiske sannhetstabeller

Skriv inn et boolsk uttrykk med variablene A–Z, parenteser, !, &, |, ^, -> og <->.

Kjøres i nettleseren. Ingen opplasting.

Values are processed locally in this browser.

Result

—

Om verktøyet

Generator for logiske sannhetstabeller sem complicação.

Uttrykket tolkes lokalt som boolsk logikk og kjøres aldri som JavaScript. Operatorprioriteten vises i hjelpeteksten under verktøyet.

Veiledning

Slik bruker du Generator for logiske sannhetstabeller

The Logic Truth Table Generator builds a table for a Boolean expression. You type something like A & !B, and it lists every mix of 0 and 1 for the letters and the result for each row. It accepts up to six different variables and the operators not, and, or, xor, implies and if-and-only-if. It reads the text as logic and never runs it as code, and it does not simplify the expression.

Slik gjør du

  1. Type an expression using single letters as variables, the constants 0 and 1, brackets, and the operators ! & | ^ -> <->. The symbols ¬ ∧ ∨ ⊕ are accepted as well, and so are the arrow symbols for implies and if-and-only-if.
  2. Press Calculate. The result shows a header row with the variables in alphabetical order, then one row per combination, ending with a Result column.
  3. Read 1 as true and 0 as false. Press Copy result to copy the table as plain text.
  4. If you get an error, check the brackets and make sure each operator has something on both sides. When unsure about the order, add brackets.

Eksempler

A and not B

Du skriver inn
Uttrykk
A & !B
Du får
Rader
A B | Result; 0 0 | 0; 0 1 | 0; 1 0 | 1; 1 1 | 0

The result is true only when A is true and B is false. That is the single row 1 0, so the Result column has one 1.

Kjørt med verktøyets egen kode.

Implication

Du skriver inn
Uttrykk
A -> B
Du får
Rader
A B | Result; 0 0 | 1; 0 1 | 1; 1 0 | 0; 1 1 | 1

A -> B is false only when A is true and B is false. If A is false the statement counts as true whatever B is.

Kjørt med verktøyets egen kode.

Which operator binds first

Du skriver inn
Uttrykk
A ^ B | C
Du får
Rader
A B C | Result; 0 0 0 | 0; 0 0 1 | 1; 0 1 0 | 1; 0 1 1 | 1; 1 0 0 | 1; 1 0 1 | 1; 1 1 0 | 0; 1 1 1 | 1

The tool groups ^ before |, so this reads (A xor B) or C. In row 1 1 0 the xor is 0 and C is 0, which gives 0. Other tools may group these two differently.

Kjørt med verktøyets egen kode.

Chained implications group to the right

Du skriver inn
Uttrykk
A -> B -> C
Du får
Rad 0 0 0
1
Rad 1 1 0
0
Betydning
A -> (B -> C)

With A = 0, B = 0, C = 0 the inner part B -> C is true, so the whole statement is true. Grouping to the left, (A -> B) -> C, would give 0 in that row, so the grouping matters.

Kjørt med verktøyets egen kode.

Two expressions that always agree

Du skriver inn
Uttrykk
!A & !B <-> !(A | B)
Du får
Resultatkolonne
1; 1; 1; 1

A column of all 1s means the two sides match in every row. This is one of De Morgan's laws, and the table confirms it for all four combinations of A and B.

Kjørt med verktøyets egen kode.

Når det er nyttig

  • Check homework on logic, discrete maths or digital circuits by comparing your hand-made table with the tool's.
  • See whether two Boolean expressions are the same by joining them with <-> and looking for a column of 1s.
  • Test the condition of an if statement in code, to find which input combinations make it true.
  • Spot a tautology, an expression that is true in every row, or a contradiction that never is.

Begrensninger

  • At most six different variables are allowed, which gives 64 rows. A seventh letter or an expression with no letters gives the message "Use 1–6 distinct variables."
  • Variables are single letters. The page says A–Z, but lowercase letters are also read, and a and A count as two separate variables, so keep to one case.
  • Only the symbols listed are understood. Words such as AND or NAND, numbers other than 0 and 1, and other signs give an error. The tool shows the table but does not simplify, draw gates or make a Karnaugh map.
  • The result is plain text with no colour or grid, and there is no way to show only the rows where the result is 1.

Tips

  • Add brackets around anything you are not sure about, so your table matches the meaning you had in mind.
  • Order from tightest to loosest is !, &, ^, |, ->, <->, which is also printed under every table.
  • To test whether two expressions are equal, put <-> between them in brackets and check that the Result column is all 1s.

Vanlige spørsmål

Sobre Generator for logiske sannhetstabeller.

Which operators can I use, and in what order do they apply?

You can use ! (not), & (and), | (or), ^ (xor), -> (implies) and <-> (if and only if). From tightest to loosest the tool applies them in the order !, &, ^, |, ->, <->. Brackets always come first, so use them whenever the order is unclear.

How do I tell if an expression is always true?

Look at the Result column. If every row shows 1, the expression is true for all combinations, which logicians call a tautology. If every row shows 0 it is a contradiction. A mix of 0 and 1 means the result depends on the inputs.

What does the arrow -> mean?

It means implies, as in if A then B. The statement is false only when A is true and B is false. When A is false it is true no matter what B is. The tool groups a chain like A -> B -> C to the right.

Is my expression run as JavaScript?

No. The page says the text is parsed locally as Boolean logic and is never executed as code. The tool breaks it into allowed pieces and rejects anything else, which is why unknown symbols return an error instead of doing something.

How many variables can I use?

Between one and six different letters. The columns are sorted alphabetically, and every extra variable doubles the number of rows, so six variables give 64 rows. An expression made only of 0 and 1 has no variable and is refused.

Can I type 0 and 1 inside the expression?

Yes. The tool reads 0 as false and 1 as true, so A & 1 behaves like A. The help line on the page lists only letters and operators, but constants are accepted by the code, as long as at least one letter is present.

Hvordan bruker du Sannhetstabellgenerator?

Skriv inn et boolsk uttrykk med variablene A–Z, parenteser, !, &, |, ^, -> og <->.

Lastes dataene mine opp til en server?

Nei. Behandlingen skjer i nettleseren din, og opplysningene dine lastes ikke opp.