Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AngelMoralesChazari/TautoTeacher-2.0/llms.txt
Use this file to discover all available pages before exploring further.
TablaVerdad (in tautoteacher2.core.logica) is a utility class that produces structured Resultado objects consumed by the UI’s Visualización Clara panel. This is separate from the plain-text output of MotorLogico.generarTablaVerdad: where MotorLogico renders a raw tab-separated string for display in the explanation area, TablaVerdad builds typed Java records that the visualization panel can iterate over, colour, and interact with. The class is final and has a private constructor — all access is through its static factory method construir.
Data model
The two public record types are nested insideTablaVerdad:
TablaVerdad.Fila
Represents a single row in the truth table.
boolean[] valoresVariables— ordered array of truth values, one entry per variable, in the same alphabetical order asResultado.variables.boolean resultadoFormula— the computed truth value of the formula under this assignment.
TablaVerdad.Resultado
Encapsulates the complete table.
String formula— the original formula string as supplied.List<String> variables— immutable, alphabetically sorted list of variable names.List<Fila> filas— immutable list of all 2ⁿ rows.String mensajeInformativo— non-null when no data is available (e.g. validation failed or variable count exceeds the limit);nullwhen the table is fully populated.boolean tieneDatos()— convenience helper that returnstrueonly when bothvariablesandfilasare non-empty.
Both
variables and filas are wrapped in List.copyOf inside the Resultado compact constructor, making them truly immutable. Any attempt to mutate them at runtime throws UnsupportedOperationException.Static factory
The sole entry point for building a truth table. Its behaviour, step by step:
- Null / blank guard — returns an empty
Resultadowith a"No hay fórmula para mostrar."message if the formula is null or blank. - Validation — delegates to
MotorLogico.tipoFormulapurely for its side-effect of throwingIllegalArgumentExceptionon invalid input; the returned type string is discarded. On failure an emptyResultadois returned with the exception message. - Variable extraction — uses a
TreeSet<String>to collect all single-letter matches from the normalised expression. BecauseTreeSetorders entries naturally, the resulting variable list is always alphabetical. - Variable-count cap — if more than 4 variables are found, a
Resultadowith emptyvariablesandfilasis returned immediately, with the message"La fórmula tiene más de 4 variables; no se muestra la tabla.". - Row enumeration — iterates over all 2ⁿ combinations using a bit-mask (
i & (1 << j)), substitutes each variable by name into the normalised expression, and callsMotorLogico.evaluaParaTablaVerdad(package-private) to compute the row result. - Returns a fully populated
ResultadowithmensajeInformativoset tonull.
A convenience method that pairs a variable list with a single
Fila to produce a LinkedHashMap<String, Boolean> keyed by variable name. Because it uses LinkedHashMap, the iteration order mirrors the original alphabetical variable order — useful when you need named lookups for tree construction or display.Code example
p∧q:
| p | q | p∧q |
|---|---|---|
| F | F | F |
| V | F | F |
| F | V | F |
| V | V | V |
Variable ordering is determined by
TreeSet (natural alphabetical ordering), so variables always appear left to right as p, q, r, s — regardless of the order they appear in the formula string. This guarantees a consistent column layout across the truth table and evaluation tree panels.Handling the variable cap
When a formula exceeds the four-variable limit,tieneDatos() returns false and mensajeInformativo carries a descriptive message. The UI uses this pattern to decide whether to render the table widget or show the informational message instead: