Skip to main content

Open the simulator

Type the premises and the conclusion and check the argument with a truth table, the clausal form and resolution. The simulator is in Spanish.
“If the sensor is triggered and there is no guard, the alarm goes off.” “Someone is Spanish only if they are European.” Is if (a < b || (a >= b && c == d)) the same as if (a < b || c == d)? All three hide the same question: what follows from what. Propositional logic is the simplest tool for answering it, and the foundation of logic programming, software verification, digital circuits and a good part of artificial intelligence.

What you will learn

  • Translate sentences from natural language into formulas, including the tricky ones (“only if”, “is necessary for”, “unless”).
  • Read a formula using the precedence of the connectives and evaluate it under an interpretation.
  • Classify formulas as valid, satisfiable or unsatisfiable, and sets of formulas as consistent or inconsistent.
  • Decide whether an argument is valid with a truth table.
  • Convert any formula into conjunctive normal form and clausal form.
  • Prove an argument by resolution, deriving the empty clause.

How to use the simulator

The simulator’s interface is in Spanish. The table gives each control’s Spanish label.
  • With premises and a conclusion, the simulator says whether the argument is valid and, if it is not, gives a counterexample.
  • With a single formula, it classifies it: valid, satisfiable or unsatisfiable.
  • With several formulas and no conclusion, it says whether the set is consistent.
  • Propositions are lowercase letters (p, q, r, p1…). The constants true and false are written V and F, from the Spanish verdadero and falso.
The formulas are stored in the page address: copy the link to share a specific exercise.

Theory

Propositions and connectives

A proposition is the smallest piece of information that can be said to be true or false: “it is raining”, “John is a doctor”. Questions, exclamations and sentences whose truth depends on a variable (”XX is greater than 3”) are not propositions; the last ones belong to predicate logic. Propositions are combined with five connectives:
”pp only if qq” is p→qp \to q, not q→pq \to p: “someone is Spanish only if they are European” says that being Spanish forces being European, not the other way round. What is necessary goes to the right of the arrow and what is sufficient, to the left.

Syntax and precedence

Well-formed formulas are built from the atomic ones (the propositions and the constants VV and FF): if FF and GG are formulas, so are ¬F\lnot F, (F∧G)(F \land G), (F∨G)(F \lor G), (F→G)(F \to G) and (F↔G)(F \leftrightarrow G). To save brackets, connectives have a precedence, from highest to lowest: ¬>∧>∨>→>↔\lnot \quad > \quad \land \quad > \quad \lor \quad > \quad \to \quad > \quad \leftrightarrow So ¬p∧q→r\lnot p \land q \to r reads ((¬p∧q)→r)((\lnot p \land q) \to r). Between connectives of the same level, the leftmost one goes first: p→q→rp \to q \to r is (p→q)→r(p \to q) \to r. The simulator writes those brackets even when they are not needed, because the formula is hard to read without them.

Semantics: interpretations and truth tables

An interpretation assigns true (V) or false (F) to each proposition. With nn different propositions there are 2n2^n interpretations. The value of a formula is computed with the tables of the connectives: The conditional is false in only one case: true antecedent and false consequent. If the antecedent is false, the conditional is true (“anything follows from a falsehood”). An interpretation that makes a formula true is a model of it; one that makes it false, a countermodel.

Classifying formulas

Every valid formula is satisfiable. The two classes are linked by the mirror principle: F is valid  ⟺  ¬F is unsatisfiableF \text{ is valid} \iff \lnot F \text{ is unsatisfiable} A set of formulas is consistent if a single interpretation makes all of them true, and inconsistent if there is none. Careful: {p, ¬p}\{p,\ \lnot p\} is inconsistent even though each formula on its own is satisfiable.

Logical equivalence

Two formulas are equivalent, F≡GF \equiv G, if they have the same value under every interpretation, that is, if F↔GF \leftrightarrow G is valid. The most useful equivalences:

Logical consequence: when an argument is valid

QQ is a logical consequence of the premises P1,…,PnP_1, \dots, P_n, written {P1,…,Pn}⊨Q\{P_1, \dots, P_n\} \models Q, if every common model of the premises is also a model of QQ. An argument is valid when its conclusion is a logical consequence of its premises. There are two equivalent ways to check it: Theorem I:{P1,…,Pn}⊨Q  ⟺  P1∧⋯∧Pn→Q is valid\textbf{Theorem I:}\quad \{P_1, \dots, P_n\} \models Q \iff P_1 \land \dots \land P_n \to Q \text{ is valid} Theorem II:{P1,…,Pn}⊨Q  ⟺  {P1,…,Pn,¬Q} is inconsistent\textbf{Theorem II:}\quad \{P_1, \dots, P_n\} \models Q \iff \{P_1, \dots, P_n, \lnot Q\} \text{ is inconsistent} The truth table uses Theorem I: look for the rows where every premise is true and check the conclusion. If it is false in any of them, that row is a counterexample and the argument is not valid. The method always works, but with nn propositions there are 2n2^n rows: with 10 there are already 1024.

Conjunctive normal form and clausal form

A literal is a proposition or its negation; LcL^c is its complement (pp and ¬p\lnot p). A formula is in conjunctive normal form (CNF) if it is a conjunction of disjunctions of literals, such as (p∨¬q)∧(¬p∨r∨s)∧p(p \lor \lnot q) \land (\lnot p \lor r \lor s) \land p. Each disjunction is a clause, and the set of clauses is the clausal form. The clause with no literals is the empty clause □\square, which is unsatisfiable. Any formula can be converted to CNF in five steps, the same ones the simulator shows:
1

Eliminate ↔

F↔G≡(F→G)∧(G→F)F \leftrightarrow G \equiv (F \to G) \land (G \to F)
2

Eliminate →

F→G≡¬F∨GF \to G \equiv \lnot F \lor G
3

Push negations inwards

With De Morgan’s laws, until they only apply to propositions, removing double negations.
4

Distribute ∨ over ∧

F∨(G∧H)≡(F∨G)∧(F∨H)F \lor (G \land H) \equiv (F \lor G) \land (F \lor H)
5

Simplify

Remove clauses that contain a literal and its complement (they are tautologies), repeated literals, and clauses absorbed by shorter ones.

Resolution

Resolution (Robinson, 1965) uses a single inference rule, which is very easy to automate: L∨FLc∨GF∨G\frac{L \lor F \qquad L^c \lor G}{F \lor G} A pair of complementary literals is removed and what is left of the two clauses is joined: the result is the resolvent. It works because, if LL is false, FF has to be true, and if LL is true, GG has to be true; either way, F∨GF \lor G holds. To prove an argument, you work by refutation, using Theorem II:
  1. Convert the premises and the negation of the conclusion to clausal form.
  2. Resolve pairs of clauses and add the resolvents.
  3. If the empty clause □\square appears, the set is inconsistent and the argument is valid.
  4. If every possible pair has been resolved without reaching □\square, the set is consistent and the argument is not valid.
The simulator tries every pair level by level (each new clause against all the earlier ones), discards tautologies and absorbed clauses, and finally shows only the resolvents that lead to □\square.
To check by resolution whether a single formula FF is valid, use the mirror principle: convert ¬F\lnot F to clausal form and look for □\square.

Worked examples

Example 1 · The umbrella, with a truth table

“If it is raining and there is no wind, I keep my umbrella open. My umbrella is not open, but it is raining. Therefore, it is windy.”Formalisation: with pp: it is raining, qq: it is windy, and rr: my umbrella is open,{p∧¬q→r, ¬r∧p}⊨q\{p \land \lnot q \to r,\ \lnot r \land p\} \models qTable: the second premise, ¬r∧p\lnot r \land p, is only true when p=Vp = V and r=Fr = F. That leaves two rows: with q=Vq = V, the first premise is F→F=VF \to F = V; with q=Fq = F, it is V→F=FV \to F = F. Both premises are true at the same time only in the row p=V, q=V, r=Fp = V,\ q = V,\ r = F, and there the conclusion qq is true.Conclusion: there is no counterexample. The argument is valid.
Clausal form of the premises: p∧¬q→r≡¬(p∧¬q)∨r≡¬p∨q∨rp \land \lnot q \to r \equiv \lnot(p \land \lnot q) \lor r \equiv \lnot p \lor q \lor r. The second premise gives two clauses: ¬r\lnot r and pp.Negated conclusion: ¬q\lnot q.
  1. ¬p∨q∨r\lnot p \lor q \lor r (premise 1)
  2. ¬r\lnot r (premise 2)
  3. pp (premise 2)
  4. ¬q\lnot q (negated conclusion)
  5. ¬p∨q\lnot p \lor q, resolving 1 and 2 on rr
  6. qq, resolving 3 and 5 on pp
  7. □\square, resolving 4 and 6 on qq
The empty clause appears: the argument is valid.
Convert ¬(p↔¬q)\lnot(p \leftrightarrow \lnot q) to clausal form.Eliminate ↔: ¬((p→¬q)∧(¬q→p))\lnot\big((p \to \lnot q) \land (\lnot q \to p)\big)Eliminate →: ¬((¬p∨¬q)∧(¬¬q∨p))\lnot\big((\lnot p \lor \lnot q) \land (\lnot\lnot q \lor p)\big)Push negations inwards: (p∧q)∨(¬q∧¬p)(p \land q) \lor (\lnot q \land \lnot p)Distribute: (p∨¬q)∧(p∨¬p)∧(q∨¬q)∧(q∨¬p)(p \lor \lnot q) \land (p \lor \lnot p) \land (q \lor \lnot q) \land (q \lor \lnot p)Simplify: the clauses p∨¬pp \lor \lnot p and q∨¬qq \lor \lnot q are tautologies and disappear. Clausal form: {p∨¬q, ¬p∨q}\{p \lor \lnot q,\ \lnot p \lor q\}, which is exactly p↔qp \leftrightarrow q.
“If I study, I pass. I passed. Therefore, I studied”: {p→q, q}⊨p\{p \to q,\ q\} \models p.In the row p=F, q=Vp = F,\ q = V both premises are true (F→V=VF \to V = V and q=Vq = V) and the conclusion is false. That is a counterexample: the argument is not valid. It is the fallacy of affirming the consequent.By resolution: the clauses ¬p∨q\lnot p \lor q, qq and ¬p\lnot p have no complementary pair that gives anything new, so □\square never appears.
Is ¬p∨q∧¬q→¬p\lnot p \lor q \land \lnot q \to \lnot p valid?With the precedence rules, it is (¬p∨(q∧¬q))→¬p(\lnot p \lor (q \land \lnot q)) \to \lnot p. Since q∧¬q≡Fq \land \lnot q \equiv F and ¬p∨F≡¬p\lnot p \lor F \equiv \lnot p, the formula is equivalent to ¬p→¬p\lnot p \to \lnot p, which is always true. It is valid.On the other hand, p→q∨rp \to q \lor r is satisfiable but not valid: it is false only when p=V, q=F, r=Fp = V,\ q = F,\ r = F.

Try it in the simulator

1

Find the counterexample

Load “Falacia del consecuente” (affirming the consequent) and see which row turns red in the table. Change the second premise to ¬q\lnot q and the conclusion to ¬p\lnot p (that is modus tollens): does the counterexample disappear?
2

Three methods, one result

With lab example “Lab. 5b”, compare the truth table (64 rows) with resolution. How many clauses does it take to reach □\square?
3

The mirror principle

Type only p∨¬pp \lor \lnot p, with no conclusion. Then type ¬(p∨¬p)\lnot(p \lor \lnot p). What does the resolution tab show in each case?
4

Consistent or not

Enter p→qp \to q, pp and ¬q\lnot q as premises with no conclusion. Remove one of the three: which interpretation makes the other two true?
5

Precedence matters

Enter p→q→rp \to q \to r and p→(q→r)p \to (q \to r) as two separate formulas and turn on the subformulas in the table. Are they equivalent?

Common mistakes

  • Translating “p only if q” as q→pq \to p. It is p→qp \to q.
  • Thinking that p→qp \to q is false when pp is false. It is only false when pp is true and qq is false.
  • Confusing satisfiable with valid. A formula being true in some row does not make it a tautology.
  • Forgetting to negate the conclusion before resolving. Resolving with QQ instead of ¬Q\lnot Q proves nothing.
  • Resolving on two pairs at once. p∨qp \lor q and ¬p∨¬q\lnot p \lor \lnot q do not give □\square: each resolution step removes a single pair, and here any resolvent is a tautology.
  • Distributing the wrong way. For CNF you distribute ∨\lor over ∧\land, not ∧\land over ∨\lor (that gives the disjunctive normal form).

Limitations

Propositional logic cannot talk about objects or their properties. “All men are mortal; Socrates is a man; therefore Socrates is mortal” is a valid argument that cannot be proved here: it needs the quantifiers (∀\forall, ∃\exists) of predicate logic. Besides, deciding whether a formula is satisfiable (the SAT problem) is NP-complete: no known method does it in polynomial time. Truth tables grow as 2n2^n and resolution can generate a huge number of clauses. The simulator draws tables of up to 7 propositions and stops at 3000 clauses. Even so, modern SAT solvers handle industrial problems with millions of variables.

A bit of history

Aristotle studied syllogisms in the 4th century BC, but logic as a calculus starts with George Boole, who in 1854 treated propositions with the rules of algebra. Gottlob Frege gave the first complete formal system in 1879. In 1935 Gerhard Gentzen proposed natural deduction, which mimics how people reason, and in 1965 John Alan Robinson invented resolution, designed for machines to reason. It led to the Prolog language (1972), which runs programs by resolving Horn clauses.

Frequently asked questions

Γ⊨Q\Gamma \models Q is logical consequence, defined with interpretations (semantics). Γ⊢Q\Gamma \vdash Q means that QQ is derived from Γ\Gamma by applying inference rules (syntax). Resolution is sound and refutation-complete: Γ⊨Q\Gamma \models Q if and only if □\square can be derived from Γ∪{¬Q}\Gamma \cup \{\lnot Q\}.
Because no interpretation makes them all true at once, so there can be no counterexample. By resolution, □\square already comes out of the premises without using the conclusion.
A clause with at most one positive literal, such as ¬p∨¬q∨r\lnot p \lor \lnot q \lor r, which is equivalent to p∧q→rp \land q \to r. They are Prolog’s rules, and with them satisfiability can be decided in linear time.
Yes. With pp = a < b and qq = c == d, the condition a < b || (a >= b && c == d) is p∨(¬p∧q)p \lor (\lnot p \land q), which is equivalent to p∨qp \lor q. Type p∨(¬p∧q)↔p∨qp \lor (\lnot p \land q) \leftrightarrow p \lor q into the simulator and you will see it is valid.
It is the same structure with a different notation: ∧ is the product, ∨ the sum and ¬ the complement (or the bar). A tautology in logic is, in electronics, a circuit whose output is always 1.
These simulators and their notes are in Spanish.

Truth table from an expression

The same idea in Boolean algebra notation, with the gate circuit.

Karnaugh maps

Simplifying logic functions of up to four variables.

Logic gates

AND, OR, NOT, XOR and their truth tables.
Last modified on October 7, 2026