32 of 40 focal problems use RatMath for a calculation or a substantive step.
Direct calculation
29 · 72.5%
Assisted
3 · 7.5%
Worked by hand
8 · 20%
Using the packages
The logic package makes finite truth tables, countermodels and many proof steps inspectable. Translating ordinary language, choosing a calculus and checking side conditions still require judgment.
Calculator interface
Offer a formula editor with scopes highlighted, a truth-table view with counterexample rows and a proof tree that displays discharged assumptions and fresh-variable conditions.
Each of the 40 focal problems has equal weight. Direct means the displayed package calculation answers the computational question after the inputs are set up. Assisted means it contributes a step and the worked solution supplies essential reasoning, interpretation or selection. Worked by hand means the guide relies on a construction, argument or judgment for that task. The helpful share combines direct and assisted days. Courses and instructors assign different mixes of problems. The percentages describe this syllabus.
Classroom inputs and practical limits
32 of 40 days include a checked executable example. On 10 days the measured size sweep exercises a named API used in the lesson. Each day identifies its tested inputs and the mathematical property checked. Hand-worked days give the input scale and the argument to verify.
Ranges across the five units
Days 1–8 · Propositions and translation. Two to six named propositions and short formulas; truth tables have 2ⁿ valuations.
Unit benchmark · logic.countModels, Boolean atoms. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24.
Days 9–16 · Boolean normal forms. Typically 2–6 atoms for truth tables, CNF, DNF or model counting; explicit normal forms can expand exponentially.
Unit benchmark · logic.countModels, Boolean atoms. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24.
Days 17–24 · Proof systems. Natural-deduction and resolution exercises commonly use 3–20 lines and a few premises or assumptions.
Unit benchmark · logic.entails, successive implications. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family.
Days 25–32 · Quantification and models. One or two quantifier alternations and finite structures with about 1–5 elements for examples; arbitrary first-order validity has no decision procedure.
Unit benchmark · logic.entails, successive implications. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family.
Days 33–40 · Modal and metatheoretic reasoning. Short modal formulas and frames with a few worlds; distinguish frame assumptions, quantified validity and bounded countermodel search.
Unit benchmark · logic.entails, successive implications. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family.
Accuracy notes (2)
Fixed · The 20-atom model count passes. The disjunction of 20 distinct atoms has 2²⁰−1 = 1048575 satisfying assignments. Both runtimes now return that count. Logic also removed the extra bit required by its earlier intermediate mask.
Fixed · The first-order checker rejects variable capture. Equality substitution from x=a and ∀x P(a) to ∀x P(x) now produces errors. A two-element model with x assigned to a and P true only of a refutes the conclusion.
Does wet pavement imply rain if rain implies wet pavement?
Worked solution
A sprinkler makes the pavement wet without rain. This valuation satisfies the implication and falsifies its converse.
Using RatMath
Translate the statement into the propositional syntax in the example. Parenthesize the intended scope and read a valuation as an assignment to those named propositions.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.entails("p -> q, q","p").status);
Checked output
invalid
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Two to six named propositions and short formulas; truth tables have 2ⁿ valuations.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.336 ms on Node.
Same API, measured input family.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.entails · 2 passing test cases, 3 distinct argument descriptions
The four clauses rule out each of the four assignments to : unsatisfiable.
Using RatMath
Translate the statement into the propositional syntax in the example. Parenthesize the intended scope and read a valuation as an assignment to those named propositions.
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Two to six named propositions and short formulas; truth tables have 2ⁿ valuations.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.397 ms on Node.
Related workload in this unit.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.satisfiable · 4 passing test cases, 7 distinct argument descriptions
In any valuation with true, forces true, contradicting . So is false (modus tollens).
Using RatMath
Translate the statement into the propositional syntax in the example. Parenthesize the intended scope and read a valuation as an assignment to those named propositions.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.entails("p -> q, ~q", "~p").status);
Checked output
valid
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Two to six named propositions and short formulas; truth tables have 2ⁿ valuations.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.321 ms on Node.
Same API, measured input family.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.entails · 2 passing test cases, 3 distinct argument descriptions
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.valid("((p -> q) & (q -> r)) -> (p -> r)").status);
Checked output
valid
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Two to six named propositions and short formulas; truth tables have 2ⁿ valuations.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.230 ms on Node.
Related workload in this unit.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.valid · 5 passing test cases, 4 distinct argument descriptions
Yes (hypothetical syllogism): the only way to make false is true, false, and then one of the hypotheses is false.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.classify("((p -> q) & (q -> r)) -> (p -> r)").kind);
Checked output
tautology
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Two to six named propositions and short formulas; truth tables have 2ⁿ valuations.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 2.53 ms on Node.
Related workload in this unit.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.classify · 2 passing test cases, 5 distinct argument descriptions
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.equivalent("!(p & q)", "!p | !q").status);
Checked output
equivalent
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Two to six named propositions and short formulas; truth tables have 2ⁿ valuations.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.330 ms on Node.
Related workload in this unit.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.equivalent · 3 passing test cases, 4 distinct argument descriptions
What truth value should a conjunction of no premises have?
Worked solution
True is the identity for conjunction. Adding the empty list of premises must leave a conjunction unchanged.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. Two to six named propositions and short formulas; truth tables have 2ⁿ valuations.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 08 / 40 · Propositions and translation
Counting models
Direct calculation@ratmath/logic
Problem
How many of the 8 valuations of satisfy ?
Worked solution
All but the all-false one: 7.
Using RatMath
Translate the statement into the propositional syntax in the example. Parenthesize the intended scope and read a valuation as an assignment to those named propositions.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.countModels("p | q | r", ["p", "q", "r"]));
Checked output
7n
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Two to six named propositions and short formulas; truth tables have 2ⁿ valuations.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.402 ms on Node.
Same API, measured input family.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.countModels · 1 passing test case, 2 distinct argument descriptions
Implementation limit. A displayed truth table is capped at 16 atoms. Packed bit-table operations have a 22-atom library limit and can hit an engine limit sooner. Source at the tested revision
Accuracy notes (1)
Fixed · The 20-atom model count passes. The disjunction of 20 distinct atoms has 2²⁰−1 = 1048575 satisfying assignments. Both runtimes now return that count. Logic also removed the extra bit required by its earlier intermediate mask.
Day 09 / 40 · Boolean normal forms
Conjunctive normal form
Direct calculation@ratmath/logic
Problem
Put in conjunctive normal form.
Worked solution
.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(String(logic.cnf("p <-> q")));
Checked output
(p ∨ ¬q) ∧ (¬p ∨ q)
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Typically 2–6 atoms for truth tables, CNF, DNF or model counting; explicit normal forms can expand exponentially.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.339 ms on Node.
Related workload in this unit.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.cnf · 3 passing test cases, 12 distinct argument descriptions
The minterms form a 6-cycle on the cube; it is covered by three of its edges, e.g. (the other cover is ). Three terms of two literals.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(
String(logic.minimize(logic.fromMinterms(["a", "b", "c"], [0, 1, 2, 5, 6, 7])).formula)
);
Checked output
(a ∧ c) ∨ (b ∧ ¬c) ∨ (¬a ∧ ¬b)
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Typically 2–6 atoms for truth tables, CNF, DNF or model counting; explicit normal forms can expand exponentially.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 1.39 ms on Node.
Related workload in this unit.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.minimize · 3 passing test cases, 4 distinct argument descriptions
Add . Resolve with on : . Resolve with : the empty clause.
Using RatMath
Translate the statement into the propositional syntax in the example. Parenthesize the intended scope and read a valuation as an assignment to those named propositions.
JavaScript module
import * as logic from "@ratmath/logic";
const r = logic.entails("p | q, ~p | q", "q");
console.log(
[r.status, logic.checkResolution(r.refutation).ok ?? logic.checkResolution(r.refutation).status]
);
Checked output
["valid", true]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Typically 2–6 atoms for truth tables, CNF, DNF or model counting; explicit normal forms can expand exponentially.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.235 ms on Node.
Same API, measured input family.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.entails · 2 passing test cases, 3 distinct argument descriptions
logic.checkResolution · 2 passing test cases, 9 distinct argument descriptions
"1. p | q premise\n2. ~p | q premise\n3. ~q … (106 chars)", {premises=["p | q", "~p | q", "~q"] (n=3)} or "1. p | q premise\n2. ~p | q premise\n3. ~q … (106 chars)", {premises=["p | q", "~q"] (n=2)} · a proof written by hand is checked line by line
"p | q premise\n~p premise\nq | r res 1, 2" or "p | q\nr\nq res 1, 2" · what is wrong is named
Day 12 / 40 · Boolean normal forms
Circuits
Direct calculation@ratmath/logic
Problem
A full adder adds bits and a carry . What are the sum and carry for ?
Worked solution
: sum 1, carry 1.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.adders.full().evaluate({ a: 1, b: 1, cin: 1 }));
Checked output
{ sum: 1, cout: 1 }
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Typically 2–6 atoms for truth tables, CNF, DNF or model counting; explicit normal forms can expand exponentially.
Focal example. The code above passed its displayed check in 0.449 ms on Node.
Related workload in this unit.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.adders.full · 1 passing test case, 1 distinct argument description
Try : then (clause 2), so (clause 3); clause 1 holds by , clause 4 by . Satisfiable with .
Using RatMath
Translate the statement into the propositional syntax in the example. Parenthesize the intended scope and read a valuation as an assignment to those named propositions.
JavaScript module
import * as logic from "@ratmath/logic";
const r = logic.satisfiable("(x1 | x2) & (~x1 | x3) & (~x2 | ~x3) & (x1 | ~x3)");
console.log([r.status, r.model ?? r.assignment]);
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Typically 2–6 atoms for truth tables, CNF, DNF or model counting; explicit normal forms can expand exponentially.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.289 ms on Node.
Related workload in this unit.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.satisfiable · 4 passing test cases, 7 distinct argument descriptions
Can adding fresh variables preserve satisfiability while changing the number of models?
Worked solution
Yes. The tautology p∨¬p has two assignments on p. Conjoining q∨¬q allows four assignments on p,q.
Using RatMath
Translate the statement into the propositional syntax in the example. Parenthesize the intended scope and read a valuation as an assignment to those named propositions.
JavaScript module
import * as logic from "@ratmath/logic";
console.log([logic.countModels("p | ~p"),logic.countModels("(p | ~p) & (q | ~q)")]);
Checked output
[2n, 4n]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Typically 2–6 atoms for truth tables, CNF, DNF or model counting; explicit normal forms can expand exponentially.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.118 ms on Node.
Same API, measured input family.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.countModels · 1 passing test case, 2 distinct argument descriptions
Implementation limit. A displayed truth table is capped at 16 atoms. Packed bit-table operations have a 22-atom library limit and can hit an engine limit sooner. Source at the tested revision
Accuracy notes (1)
Fixed · The 20-atom model count passes. The disjunction of 20 distinct atoms has 2²⁰−1 = 1048575 satisfying assignments. Both runtimes now return that count. Logic also removed the extra bit required by its earlier intermediate mask.
Day 15 / 40 · Boolean normal forms
Resolution invariant
Assisted@ratmath/logic
Problem
Why does resolving A∨p and B∨¬p entail A∨B?
Worked solution
If both A and B were false, the two premises would force p and its negation simultaneously.
Using RatMath
Translate the statement into the propositional syntax in the example. Parenthesize the intended scope and read a valuation as an assignment to those named propositions.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.entails("a | p, b | ~p","a | b").status);
Checked output
valid
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Typically 2–6 atoms for truth tables, CNF, DNF or model counting; explicit normal forms can expand exponentially.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.314 ms on Node.
Same API, measured input family.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.entails · 2 passing test cases, 3 distinct argument descriptions
A four-bit ripple adder has no carry input. It uses one half adder (XOR, AND) and three five-gate full adders. Count the gates and the longest input-to-output gate depth.
Worked solution
There are 2+3×5=17 gates. The half adder produces its carry at depth 1. Each further carry adds an AND and an OR along the critical path, giving depth 1+2×3=7.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
const c = logic.adders.ripple(4);
console.log([c.size, c.depth]);
Checked output
[17, 7]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Typically 2–6 atoms for truth tables, CNF, DNF or model counting; explicit normal forms can expand exponentially.
Focal example. The code above passed its displayed check in 0.487 ms on Node.
Related workload in this unit.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.adders.ripple · 1 passing test case, 1 distinct argument description
Assume ; assume ; assume ; then by E, contradiction with ; so by I; discharge twice with I.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
const r = logic.prove("", "(p -> q) -> (~q -> ~p)");
console.log([r.status, logic.checkProof(String(r.proof)).status]);
Checked output
["proved", "proof"]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Natural-deduction and resolution exercises commonly use 3–20 lines and a few premises or assumptions.
For this problem type. Use a handful of premises and approximately 3–20 proof lines. Subproofs, rule scope and variable binding determine validity.
Focal example. The code above passed its displayed check in 3.63 ms on Node.
Related workload in this unit.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.prove · 4 passing test cases, 18 distinct argument descriptions
logic.checkProof · 8 passing test cases, 28 distinct argument descriptions
"1. p -> q premise\n2. q -> r premis… (152 chars)", {premises="p -> q, q -> r", conclusion="p -> r"} or [{n=1, depth=0, formula=Formula, rule="premise", cites=array[0]}, {n=2, depth=0, formula=Formula, rule="premise", cites=array[0]}, {n=3, depth=1, formula=Formula, rule="assump · a correct proof
"1. p & q premise\n2. (q & p) -> r premise\n3. q … (73 chars)", {rules={name="my rules", logic=undefined, rules=array[2], find=function}} or "1. p & q premise\n2. p &E 1", {rules={name="my rules", logic=undefined, rules=array[2], find=function}} · a rule set of one's own is data
Day 18 / 40 · Proof systems
Checking a proof
Direct calculation@ratmath/logic
Problem
Check this proof of : 1. premise; 2. premise; 3. assumption; 4. E 1, 3; 5. E 4, 2; 6. I 3–5.
Worked solution
Each line follows by the rule cited; the assumption at 3 is discharged at 6. It is a correct proof of .
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
const r = logic.checkProof(`1. p -> q premise
2. ~q premise
3. | p assumption
4. | q ->E 1, 3
5. | _|_ ~E 4, 2
6. ~p ~I 3-5`);
console.log([r.status, r.proves]);
Checked output
["proof", "p → q, ¬q ⊢ ¬p"]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Natural-deduction and resolution exercises commonly use 3–20 lines and a few premises or assumptions.
For this problem type. Use a handful of premises and approximately 3–20 proof lines. Subproofs, rule scope and variable binding determine validity.
Focal example. The code above passed its displayed check in 0.382 ms on Node.
Related workload in this unit.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.checkProof · 8 passing test cases, 28 distinct argument descriptions
"1. p -> q premise\n2. q -> r premis… (152 chars)", {premises="p -> q, q -> r", conclusion="p -> r"} or [{n=1, depth=0, formula=Formula, rule="premise", cites=array[0]}, {n=2, depth=0, formula=Formula, rule="premise", cites=array[0]}, {n=3, depth=1, formula=Formula, rule="assump · a correct proof
"1. p & q premise\n2. (q & p) -> r premise\n3. q … (73 chars)", {rules={name="my rules", logic=undefined, rules=array[2], find=function}} or "1. p & q premise\n2. p &E 1", {rules={name="my rules", logic=undefined, rules=array[2], find=function}} · a rule set of one's own is data
Day 19 / 40 · Proof systems
Intuitionistic logic
Direct calculation@ratmath/logic
Problem
Which of these are provable intuitionistically: ; ; Peirce's law ? Which classically?
Worked solution
Intuitionistically only : assume ; then gives a contradiction, so , so , a contradiction. Excluded middle and Peirce's law are classical tautologies but not intuitionistic theorems.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Natural-deduction and resolution exercises commonly use 3–20 lines and a few premises or assumptions.
For this problem type. Use a handful of premises and approximately 3–20 proof lines. Subproofs, rule scope and variable binding determine validity.
Focal example. The code above passed its displayed check in 1.70 ms on Node.
Related workload in this unit.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.prove · 4 passing test cases, 18 distinct argument descriptions
Is "All M are P; all S are M; therefore all S are P" valid? What is its traditional name?
Worked solution
Valid: mood AAA in the first figure, Barbara.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
const r = logic.syllogism("All M are P", "All S are M", "All S are P");
console.log([r.valid, r.form, r.name]);
Checked output
[true, "AAA-1", "Barbara"]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Natural-deduction and resolution exercises commonly use 3–20 lines and a few premises or assumptions.
For this problem type. Use a handful of premises and approximately 3–20 proof lines. Subproofs, rule scope and variable binding determine validity.
Focal example. The code above passed its displayed check in 1.66 ms on Node.
Related workload in this unit.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.syllogism · 3 passing test cases, 11 distinct argument descriptions
"All men are mortal", "All Greeks are men", "All Greeks are mortal" · statements in words
Of the 256 syllogistic forms, how many are valid in modern logic, and how many with Aristotle's existential import?
Worked solution
15 unconditionally valid; with existential import 9 more (the weakened and strengthened moods such as Darapti and Barbari): 24.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(
[logic.validSyllogisms().length, logic.validSyllogisms({ existentialImport: true }).length]
);
Checked output
[15, 24]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Natural-deduction and resolution exercises commonly use 3–20 lines and a few premises or assumptions.
Focal example. The code above passed its displayed check in 205 ms on Node.
Related workload in this unit.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.validSyllogisms · 2 passing test cases, 2 distinct argument descriptions
From a temporary assumption P one derives Q. What survives after discharging P?
Worked solution
Implication introduction yields P→Q in the remaining context. The derivation does not give unconditional Q.
Using RatMath
Translate the statement into the propositional syntax in the example. Parenthesize the intended scope and read a valuation as an assignment to those named propositions.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.entails("p -> q","q").status);
Checked output
invalid
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Natural-deduction and resolution exercises commonly use 3–20 lines and a few premises or assumptions.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.254 ms on Node.
Same API, measured input family.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.entails · 2 passing test cases, 3 distinct argument descriptions
Yes. A counterexample needs an element of the empty set, so none exists.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. Natural-deduction and resolution exercises commonly use 3–20 lines and a few premises or assumptions.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 24 / 40 · Proof systems
A sum proved by induction
Direct calculation@ratmath/symbolic
Problem
Find a closed form for .
Worked solution
.
Using RatMath
Enter the expression in the form given. Expand or factor the result in reverse to check that it represents the original expression.
JavaScript module
import * as symbolic from "@ratmath/symbolic";
console.log(String(symbolic.factor(symbolic.sum("k^3", "k", 1, "n").value)));
Checked output
n^2*(n + 1)^2/4
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Natural-deduction and resolution exercises commonly use 3–20 lines and a few premises or assumptions.
For this problem type. Use one or two variables and polynomial degrees roughly 2–6. Rational expressions often have two or three denominator factors.
Focal example. The code above passed its displayed check in 1.83 ms on Node.
Related workload in this unit.core.range · terms. Baseline test points across courses 1, 10, 100, 1,000. Check length and every consecutive integer from 1 through n.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 1,000,000 (141 ms, 277.5 MiB peak process RSS). The first sampled passing call above 100 ms used 1,000,000 (141 ms). The runs did not locate a ceiling for this family. Keeping the entire result requires storage proportional to its length. Shortening the displayed list after construction still pays that cost.
Measured times, memory and outcomes
terms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.173
75.5
10
Baseline
Passed
0.192
74.9
100
Baseline
Passed
0.269
74.7
1,000
Baseline
Passed
1.52
75.6
10,000
Stretch
Passed
5.29
80.9
100,000
Stretch
Passed
11.57
109.6
1,000,000
Stretch
Passed
141
277.5
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
symbolic.factor · 1 passing test case, 4 distinct argument descriptions
Yes, given that domains are non-empty: pick any element ; holds, so .
Using RatMath
Write down the domain, bound variables and scope of each quantifier before translating the formula. Track the free variables when interpreting the result.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.foEntails([], "(forall x. P(x)) -> exists x. P(x)").status);
Checked output
valid
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. One or two quantifier alternations and finite structures with about 1–5 elements for examples; arbitrary first-order validity has no decision procedure.
For this problem type. Use one or two quantifier alternations, a few predicate symbols and 1–5 individuals or worlds in explicit finite models. A universal validity claim ranges beyond these finite examples.
Focal example. The code above passed its displayed check in 1.96 ms on Node.
Same API, measured input family.logic.foEntails · unary predicate premises. Baseline test points across courses 1, 2, 3, 5. Universal premises ∀x Pᵢ(x) entail their conjunction at the named individual a by instantiation.
Practical limit. Largest passing sample 20 (7.98 ms, 77.7 MiB peak process RSS). The runs did not locate a ceiling for this family. These cases use universal instantiation over a nonempty domain. Alternating quantifiers and function symbols can lead to unbounded proof search. A bounded search result needs its status and assumptions.
Measured times, memory and outcomes
unary predicate premises · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
4.27
74.7
2
Baseline
Passed
4.64
75.5
3
Baseline
Passed
3.41
75.6
5
Baseline
Passed
2.77
74.7
8
Stretch
Passed
7.06
76.2
12
Stretch
Passed
10.09
77.2
20
Stretch
Passed
7.98
77.7
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Implementation limit. Defaults search for countermodels up to four elements and allow a 5,000-step tableau budget. An unresolved result leaves the entailment open. Source at the tested revision
Accuracy notes (1)
Fixed · The first-order checker rejects variable capture. Equality substitution from x=a and ∀x P(a) to ∀x P(x) now produces errors. A two-element model with x assigned to a and P true only of a refutes the conclusion.
Day 26 / 40 · Quantification and models
Swapping quantifiers
Direct calculation@ratmath/logic
Problem
Show , and that the converse fails.
Worked solution
If is related to every , then every has . Converse: on with every has some , but no works for all .
Using RatMath
Write down the domain, bound variables and scope of each quantifier before translating the formula. Track the free variables when interpreting the result.
JavaScript module
import * as logic from "@ratmath/logic";
const fwd = logic.foEntails(["exists x. forall y. R(x,y)"], "forall y. exists x. R(x,y)");
const back = logic.foEntails(["forall y. exists x. R(x,y)"], "exists x. forall y. R(x,y)");
console.log([fwd.status, back.status, back.countermodel.size]);
Checked output
["valid", "invalid", 2]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. One or two quantifier alternations and finite structures with about 1–5 elements for examples; arbitrary first-order validity has no decision procedure.
For this problem type. Use one or two quantifier alternations, a few predicate symbols and 1–5 individuals or worlds in explicit finite models. A universal validity claim ranges beyond these finite examples.
Focal example. The code above passed its displayed check in 5.33 ms on Node.
Same API, measured input family.logic.foEntails · unary predicate premises. Baseline test points across courses 1, 2, 3, 5. Universal premises ∀x Pᵢ(x) entail their conjunction at the named individual a by instantiation.
Practical limit. Largest passing sample 20 (7.98 ms, 77.7 MiB peak process RSS). The runs did not locate a ceiling for this family. These cases use universal instantiation over a nonempty domain. Alternating quantifiers and function symbols can lead to unbounded proof search. A bounded search result needs its status and assumptions.
Measured times, memory and outcomes
unary predicate premises · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
4.27
74.7
2
Baseline
Passed
4.64
75.5
3
Baseline
Passed
3.41
75.6
5
Baseline
Passed
2.77
74.7
8
Stretch
Passed
7.06
76.2
12
Stretch
Passed
10.09
77.2
20
Stretch
Passed
7.98
77.7
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Implementation limit. Defaults search for countermodels up to four elements and allow a 5,000-step tableau budget. An unresolved result leaves the entailment open. Source at the tested revision
Accuracy notes (1)
Fixed · The first-order checker rejects variable capture. Equality substitution from x=a and ∀x P(a) to ∀x P(x) now produces errors. A two-element model with x assigned to a and P true only of a refutes the conclusion.
Day 27 / 40 · Quantification and models
Prenex normal form
Direct calculation@ratmath/logic
Problem
Put in prenex form.
Worked solution
.
Using RatMath
Write down the domain, bound variables and scope of each quantifier before translating the formula. Track the free variables when interpreting the result.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(String(logic.prenex("(forall x. P(x)) -> exists y. Q(y)")));
Checked output
∃x ∃y (¬P(x) ∨ Q(y))
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. One or two quantifier alternations and finite structures with about 1–5 elements for examples; arbitrary first-order validity has no decision procedure.
For this problem type. Use one or two quantifier alternations, a few predicate symbols and 1–5 individuals or worlds in explicit finite models. A universal validity claim ranges beyond these finite examples.
Focal example. The code above passed its displayed check in 0.457 ms on Node.
Related workload in this unit.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.prenex · 1 passing test case, 1 distinct argument description
Replace by a new function of the universally quantified : . Equisatisfiable, not equivalent.
Using RatMath
Write down the domain, bound variables and scope of each quantifier before translating the formula. Track the free variables when interpreting the result.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(String(logic.skolemize("forall x. exists y. R(x,y)")));
Checked output
∀x R(x, sk1(x))
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. One or two quantifier alternations and finite structures with about 1–5 elements for examples; arbitrary first-order validity has no decision procedure.
For this problem type. Use one or two quantifier alternations, a few predicate symbols and 1–5 individuals or worlds in explicit finite models. A universal validity claim ranges beyond these finite examples.
Focal example. The code above passed its displayed check in 0.265 ms on Node.
Related workload in this unit.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.skolemize · 1 passing test case, 1 distinct argument description
Each element has a successor in the cycle: the first is true. No element is related to all three: the second is false.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
const M = logic.structure({ domain: [1, 2, 3], predicates: { L: [[1, 2], [2, 3], [3, 1]] } });
console.log(
[logic.evaluate("forall x. exists y. L(x, y)", M).value, logic.evaluate("exists x. forall y. L(x, y)", M).value]
);
Checked output
[true, false]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. One or two quantifier alternations and finite structures with about 1–5 elements for examples; arbitrary first-order validity has no decision procedure.
For this problem type. Use one or two quantifier alternations, a few predicate symbols and 1–5 individuals or worlds in explicit finite models. A universal validity claim ranges beyond these finite examples.
Focal example. The code above passed its displayed check in 0.266 ms on Node.
Related workload in this unit.logic.countModels · Boolean atoms. Baseline test points across courses 1, 2, 4, 8. A disjunction of n distinct atoms is false in exactly one of its 2^n valuations.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 20 (21.16 ms, 97.1 MiB peak process RSS). Library refusal at 24. An n-atom truth table has 2ⁿ rows. This implementation guards tables above 22 atoms. SAT search has different resource costs.
Measured times, memory and outcomes
Boolean atoms · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.290
75.3
2
Baseline
Passed
0.268
74.6
4
Baseline
Passed
0.426
76.4
8
Baseline
Passed
0.371
75.4
12
Stretch
Passed
0.720
75.6
16
Stretch
Passed
2.33
78
19
Stretch
Passed
10.50
88.2
20
Stretch
Passed
21.16
97.1
24
Stretch
Library refusal · LogicError: a table over 24 atoms has 2^24 rows; use satisfiable() or valid() instead
0.440
75.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.structure · 1 passing test case, 6 distinct argument descriptions
One element cannot work (it would need ). Two do: . Smallest size 2.
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.findModel("(forall x. exists y. R(x,y)) & forall x. ~R(x,x)").size);
Checked output
2
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. One or two quantifier alternations and finite structures with about 1–5 elements for examples; arbitrary first-order validity has no decision procedure.
For this problem type. Use one or two quantifier alternations, a few predicate symbols and 1–5 individuals or worlds in explicit finite models. A universal validity claim ranges beyond these finite examples.
Focal example. The code above passed its displayed check in 0.417 ms on Node.
Related workload in this unit.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.findModel · 1 passing test case, 2 distinct argument descriptions
First rename bound y to a fresh z. The result ∀z R(y,z) leaves the substituted y free.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. One or two quantifier alternations and finite structures with about 1–5 elements for examples; arbitrary first-order validity has no decision procedure.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 32 / 40 · Quantification and models
Existence versus uniqueness
Worked by hand
Problem
Give a first-order formula for exactly one object satisfying P.
Worked solution
Use ∃x (P(x) ∧ ∀y (P(y) → y=x)). Existence and the uniqueness condition are both necessary.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. One or two quantifier alternations and finite structures with about 1–5 elements for examples; arbitrary first-order validity has no decision procedure.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 33 / 40 · Modal and metatheoretic reasoning
Modal logic: K
Direct calculation@ratmath/logic
Problem
Is the distribution axiom valid in every Kripke model? Is ?
Worked solution
The first is valid on all frames (axiom K). fails at a world where is false but every world sees has (for example, sees nothing, so holds vacuously).
Using RatMath
Use the data and parameter order shown below. Compare the returned value with the intermediate quantities in the worked solution.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(
[logic.modalValid("[](p -> q) -> ([]p -> []q)").status, logic.modalValid("[]p -> p").status]
);
Checked output
["valid", "invalid"]
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Short modal formulas and frames with a few worlds; distinguish frame assumptions, quantified validity and bounded countermodel search.
For this problem type. Use one or two quantifier alternations, a few predicate symbols and 1–5 individuals or worlds in explicit finite models. A universal validity claim ranges beyond these finite examples.
Focal example. The code above passed its displayed check in 1.95 ms on Node.
Related workload in this unit.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.modalValid · 1 passing test case, 1 distinct argument description
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Short modal formulas and frames with a few worlds; distinguish frame assumptions, quantified validity and bounded countermodel search.
For this problem type. Use one or two quantifier alternations, a few predicate symbols and 1–5 individuals or worlds in explicit finite models. A universal validity claim ranges beyond these finite examples.
Focal example. The code above passed its displayed check in 0.353 ms on Node.
Related workload in this unit.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.modalValid · 1 passing test case, 1 distinct argument description
Is there an algorithm that decides, for every program and input, whether the program halts?
Worked solution
No (Turing). If decided halting, the program that runs on its own code and does the opposite would halt exactly when it does not.
Using RatMath
A budget of 1000 steps gives a finite trace. The diagonal contradiction in the solution establishes undecidability.
JavaScript module
import * as logic from "@ratmath/logic";
// A run with a budget can only report "running" for a machine that has not stopped yet.
const loop = logic.turing({ start: "s", accept: "y", reject: "n", delta: { "s,_": ["s", "_", "R"] } });
console.log(loop.run("", { budget: 1000 }).status);
Checked output
running
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Short modal formulas and frames with a few worlds; distinguish frame assumptions, quantified validity and bounded countermodel search.
For this problem type. Use a handful of states or rules, an alphabet of 1–3 symbols and words commonly of length 0–20. State a step budget for search or simulation.
Focal example. The code above passed its displayed check in 0.618 ms on Node.
Related workload in this unit.logic.binaryIncrement.run · input bits. Baseline test points across courses 1, 2, 4, 8. Incrementing a string of n ones gives 1 followed by n zeroes.
Practical limit. The cutoff for this lesson’s own code is unmeasured. Largest passing sample 2,048 (21.81 ms, 75.1 MiB peak process RSS). The runs did not locate a ceiling for this family. Simulation cost depends on executed transitions and tape use. Reaching a step budget establishes an incomplete trace only.
Measured times, memory and outcomes
input bits · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
0.248
75.8
2
Baseline
Passed
0.141
74.4
4
Baseline
Passed
0.141
76
8
Baseline
Passed
0.149
74.7
32
Stretch
Passed
0.201
74.9
128
Stretch
Passed
0.349
75.1
512
Stretch
Passed
1.56
75.1
2,048
Stretch
Passed
21.81
75.1
Each row measures the stated fixture. This workload uses a different operation or expression from the focal example. Its thresholds apply only to the named fixture. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.turing · 1 passing test case, 1 distinct argument description
In Kripke semantics, why does ¬□¬P have the same truth value as ◇P?
Worked solution
Negating “every successor falsifies P” gives “some successor satisfies P.” At a dead end the box is vacuously true and both dual diamond expressions are false.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. Short modal formulas and frames with a few worlds; distinguish frame assumptions, quantified validity and bounded countermodel search.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 37 / 40 · Modal and metatheoretic reasoning
Semantic compactness
Worked by hand
Problem
If an infinite set of classical propositional formulas has no model, must some finite subset already lack a model?
Worked solution
Yes, by compactness. Its contrapositive says that satisfiability of every finite subset implies satisfiability of the full set.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. Short modal formulas and frames with a few worlds; distinguish frame assumptions, quantified validity and bounded countermodel search.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 38 / 40 · Modal and metatheoretic reasoning
Inconsistent assumptions
Direct calculation@ratmath/logic
Problem
Why is every formula a semantic consequence of {P,¬P} in classical logic?
Worked solution
Entailment quantifies over valuations satisfying all premises. There are none, so none can falsify the proposed conclusion while satisfying the premises.
Using RatMath
Translate the statement into the propositional syntax in the example. Parenthesize the intended scope and read a valuation as an assignment to those named propositions.
JavaScript module
import * as logic from "@ratmath/logic";
console.log(logic.entails("p, ~p","q").status);
Checked output
valid
Run this example locally
Use the integrated RatMath workspace with the subject packages linked. Save this example as lesson.mjs in its root and run node lesson.mjs. The guide formats library objects as mathematical values. Your console may also print their fields or JavaScript type suffixes.
Typical inputs for this unit. Short modal formulas and frames with a few worlds; distinguish frame assumptions, quantified validity and bounded countermodel search.
For this problem type. Typical written truth tables have 1–6 atoms and therefore 2–64 rows. Proof search and identifying a single model have different scaling.
Focal example. The code above passed its displayed check in 0.156 ms on Node.
Same API, measured input family.logic.entails · successive implications. Baseline test points across courses 1, 2, 4, 8. The assumptions p₀, p₀→p₁, … imply pₙ by repeated modus ponens.
Practical limit. Largest passing sample 128 (20.49 ms, 89.4 MiB peak process RSS). The runs did not locate a ceiling for this family. A chain of implications is a favorable entailment instance. Search depth, branching and quantifiers can be decisive even for short formulas.
Measured times, memory and outcomes
successive implications · one run per input
Input
Sample
Result
Call (ms)
Peak RSS (MiB)
1
Baseline
Passed
1.84
75.5
2
Baseline
Passed
1.91
75.9
4
Baseline
Passed
2.18
75.8
8
Baseline
Passed
2.75
76.8
16
Stretch
Passed
3.05
76.1
32
Stretch
Passed
9.72
75.9
64
Stretch
Passed
6.86
78.4
128
Stretch
Passed
20.49
89.4
Each row measures the stated fixture. Other inputs to this API can take different paths. Course intervals are estimates. Finite samples leave intermediate inputs and other problem families unverified.
Additional inputs from package tests
These arguments were observed in passing test cases. The linked assertions show what the tests actually checked. Structured inputs are abbreviated.
logic.entails · 2 passing test cases, 3 distinct argument descriptions
The current world is one of its own accessible worlds, so truth at every accessible world includes truth here.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. Short modal formulas and frames with a few worlds; distinguish frame assumptions, quantified validity and bounded countermodel search.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.
Day 40 / 40 · Modal and metatheoretic reasoning
Soundness versus completeness
Worked by hand
Problem
What direction does each property connect derivability and semantic consequence?
Worked solution
Soundness sends a derivation to validity in all models. Completeness sends validity in all models to existence of a derivation.
Working without a calculator
Use the argument or construction in the worked solution. This lesson assigns the reasoning to the student.
Input range and limits
Typical inputs for this unit. Short modal formulas and frames with a few worlds; distinguish frame assumptions, quantified validity and bounded countermodel search.
Scope of verification. This day asks for a hand argument, construction or interpretation. The worked instance gives the input. General claims need the reasoning shown above. A measured time, memory ceiling or finite input sweep would not verify that claim.