QED
This manual documents v0.1.0 of Luna-Flow/QED, as it stands on main.
Overview
QED (Quite Easy Deduction) is a theorem prover for higher-order logic written in MoonBit. It follows the LCF approach: a small trusted kernel implements the primitive inference rules of HOL and is the only code that can create theorems, and everything else, from the parser to the command-line tool, builds on it without being trusted. Proofs are written as short theorem scripts with goal-directed steps; a script either yields a kernel theorem, fails with a structured diagnostic, or reports an unfinished proof. A formal specification defines the kernel, and the Typed HOL development in formal_verification/ proves the mathematical calculus; MoonBit refinement remains separate.
The shipped proof language covers propositional logic with equality, theorem-header binders and goal-level forall; the user manual has the exact support matrix.
Install
moon add Luna-Flow/QED@0.1.0
Then import the packages you need in your moon.pkg, for example "Luna-Flow/QED/prover" to run theorem scripts or "Luna-Flow/QED/kernel" to build theorems directly. QED needs the MoonBit toolchain 0.10.20 or later (moonc ≥ 0.10.20), and depends on moonbitlang/x for file access in the command-line tool.
To work in the repository:
moon check --target all
moon test
moon run src/cmd examples/truth_file.qed
Formal specification
The formal specification is the only normative source for the kernel.
Formal description includes the embedded PDF preview of the QED formal specification.
Pages
The packages are layered: each depends only on packages to its left, kernel → logic/elab → parser → tactics → prover → cmd, and only kernel is trusted. research_rewrite sits outside this chain.
| Part | Tutorial | API | Design |
|---|---|---|---|
kernel: types, terms, theorems, primitive rules, scoped signature, extension gates | tutorial | API | design |
logic: connectives as definitions, derived rules, replay helpers, theorem catalog | tutorial | API | design |
elab: name resolution with frozen constant identities, core typing, lowering | tutorial | API | design |
parser: normalisation, terms, goals, theorem scripts, source positions | tutorial | API | design |
tactics: backward proof states, replayed forward to kernel theorems | tutorial | API | design |
prover: theorem-script driver, structured results, regression corpus | tutorial | API | design |
cmd: the command-line tool qed-cmd (executable package) | tutorial | API | design |
research_rewrite: research-only rewriting prototype, not shipped | tutorial | API | design |
Repository guides:
| Guide | Contents |
|---|---|
| User manual | The user guide and implementation contract, with the support matrix and the stable examples |
| Syntax guide | The theorem-script syntax |
| Compliance review | Implementation mapping, proof obligations, evidence boundary, and contributor checks |
| Formal description | Normative specification entry point and PDF preview |
| Initial verification audit (2026-10-14) | Research-only baseline, reproducible evidence and next promotion |
Blackbox test files (*_test.mbt) and the alias files alias.mbt and alias_test.mbt belong to their packages; the compliance review defines their maintenance obligations. The theorem files in examples/ and prelude/ are inputs for the command-line tool, not packages.
Exported items
Trusted kernel
- Types and terms:
HolType,Term,DbTermand their constructors, destructors and substitutions - Theorems: the abstract
Thm, read withthm_concl,thm_hypsandthm_is_admissible - Primitive rules:
refl_checked,assume_checked,trans_checked,mk_comb_rule_checked,abs_rule_checked,beta_rule_checked,eq_mp_checked,deduct_antisym_rule_checked,inst_type,inst_checked, and the derivedadd_assum_checked - State and gates:
KernelState, scopes,ks_define_const_thm(DefOK),ks_register_type_definition(TypeDefOK),ks_specify_const(SpecOK), audit certificates
Untrusted layers
logic:install_prop_prelude, the connective buildersprop_mk_*and recognisersprop_dest_*, the natural-deduction ruleslogic_prop_*_thm, the theorem catalogelab:RTerm,elab_resolve_*,elab_check_core_type,elab_lower_to_termparser:parse_term,parse_goal,parse_theorem_script_rawand their_rawand_with_envvariants,ParseErrorwith raw offsetstactics:ProofState,ps_init,ps_apply,ps_qed, the stepsstep_intro,step_split,step_left,step_right,step_apply,step_exact,step_assumptionprover:prove_theorem_script_detailed,prove_theorem_file_results_detailed,ProverRunResult, the regression corpus
Where to read next
- New to proof assistants: read “For readers new to HOL” and the quick start in the user manual, then run the examples with the cmd tutorial. The syntax guide answers “how do I write this step”.
- Using QED from MoonBit: start with the prover tutorial to run scripts and read results. Go down to the tactics tutorial to drive proofs step by step, and to the logic and kernel tutorials to build theorems forwards. Keep the API pages at hand; each lists the failure cases of every function.
- Checking why it is sound: read the kernel design, which derives the rules and explains why soundness reduces to the kernel, then the logic and tactics designs, which show that the upper layers add no authority. The formal specification above is normative.
- Contributing: read the compliance review for the code/test mapping, proof obligations, package boundaries, and evidence limits. The initial verification audit records dated research evidence.
Validation
Recommended release checks:
moon check --target all
moon test
The examples on the package pages compile against the current code; specification conformance describes how they are checked. The Typed HOL proof builds separately with lake build in formal_verification/; it formalizes the mathematical calculus and does not yet prove a refinement from the MoonBit implementation.