Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

HOL Quick Reference

A one-page-style summary of the tactics, rules, conversions, and support functions that come up most often in day-to-day HOL4 proof. Names link to their full entry in the Reference manual; names shown in plain type have no separate Reference entry.

Creating Theories

Theory.new_theory namecreates a new theory
Theory.export_theory()writes theory to disk
TotalDefn.Define termfunction definition
bossLib.Hol_datatype type-decdefines a concrete datatype
EquivType.define_equivalence_type rectype of equivalence classes
Theory.save_thm(name,thm)stores theorem
Tactical.prove(term,tactic)proves theorem using tactic
Tactical.store_thm(name,term,tactic)proves and stores theorem

Goal Stack Operations

proofManagerLib.g termstarts a new goal
proofManagerLib.e tacticapplies a tactic to the top goal
proofManagerLib.b()undoes previous expansion
proofManagerLib.restart()undoes all expansions
proofManagerLib.drop()abandons the top goal
proofManagerLib.dropn intabandons a number of goals
proofManagerLib.p()prints the state of the top goal
proofManagerLib.status()prints the state of all goals
proofManagerLib.top_thm()returns the last theorem proved
proofManagerLib.r introtates sub-goals
proofManagerLib.R introtates proofs

Some Basic Tactics

bossLib.Casescase analysis on outermost variable
bossLib.Cases_on termcase analysis on given term
bossLib.Inductinduct on outermost variable
bossLib.Induct_on terminduct on given term
Tactic.STRIP_TACsplits on outermost connective
Tactic.EXISTS_TAC termgives witness for existential
Tactic.SELECT_ELIM_TACeliminates Hilbert choice operator
Tactic.EQ_TACreduces boolean equality to implication
Tactic.ASSUME_TAC thmadds an assumption
Tactic.DISJ1_TACselects left disjunct
Tactic.DISJ2_TACselects right disjunct
bossLib.SPOSE_NOT_THEN thm-tacticstarts proof by contradiction

Some Basic Tacticals

Tactical.THENapplies tactics in sequence
Tactical.THENLapplies list of tactics to sub-goals
Tactical.THEN1applies the second tactic to first sub-goal
Tactical.ORELSEapplies second tactic only if the first fails
Tactical.REVERSEreverses the order of sub-goals
Tactical.ALL_TACleaves the goal unchanged
Tactical.TRYdo nothing if the tactic fails
Tactical.REPEATrepeat a tactic until it fails
Tactic.NTACapply a tactic some number of times
Tactical.MAP_EVERYapply a tactic using theorems in a list

Using Assumptions

bossLib.by(term,tactic)add assumption using proof
Tactical.ASSUM_LIST [thms]adds list of theorems
Tactical.POP_ASSUM thm-tacticuse first assumption
Tactical.POP_ASSUM_LIST thms-tacticuse all assumptions
Tactical.PAT_ASSUM thm-tacticuse matching assumption
Tactical.FIRST_X_ASSUM thm-tacticuse first successful assumption
Tactic.STRIP_ASSUME_TAC thmsplit and add assumption
Tactic.WEAKEN_TAC term-predremove assumptions
Tactic.RULE_ASSUM_TACapply rule to assumptions
Tactic.IMP_RES_TAC thmresolve thm using assumptions
Tactic.RES_TACmutually resolve assumptions
Q.ABBREV_TACabbreviate goal's sub-term

Decision Procedures

tautLib.TAUT_TACtautology checker
bossLib.DECIDE_TACabove, plus linear arithmetic
mesonLib.MESON_TAC [thms]first-order prover
BasicProvers.PROVE_TAC [thms]uses Meson
metisLib.METIS_TAC [thms]new first-order prover
bossLib.EVAL_TACevaluation tactic
numLib.ARITH_TACfor Presburger arithmetic
intLib.ARITH_TACuses Omega test
intLib.COOPER_TACCooper's algorithm
realLib.REAL_ARITH_TAC

Term Rewriting Tactics

Rewrite.GEN_REWRITE_TAC conv-op rws [thms]used to construct bespoke rewriting tactics; applies conv-op to the rewriting conversion
Rewrite.PURE_REWRITE_TAC [thms]rewrites goal only using the given theorems
Rewrite.PURE_ONCE_REWRITE_TAC [thms]as above but executes just a single rewrite
Rewrite.REWRITE_TAC [thms]rewrites goal using theorems and some basic rewrites
Rewrite.ONCE_REWRITE_TAC [thms]as above but executes just a single rewrite
Rewrite.PURE_ASM_REWRITE_TAC [thms]rewrites goal only using assumptions and theorems
Rewrite.PURE_ONCE_ASM_REWRITE_TAC [thms]as above but executes just a single rewrite
Rewrite.ASM_REWRITE_TAC [thms]rewrites using assumptions, theorems and basic rewrites
Rewrite.ONCE_ASM_REWRITE_TAC [thms]as above but executes just a single rewrite

Simplification Tactics

simpLib.SIMP_TAC simpset [thms]simplifies goal using theorems and simplification set
simpLib.ASM_SIMP_TAC simpset [thms]as above but also uses the assumptions
simpLib.FULL_SIMP_TAC simpset [thms]simplifies the goal and all the assumptions
BasicProvers.RW_TAC simpset [thms]more aggressive simplifier; uses type information & case splits
BasicProvers.SRW_TAC [ssfrags][thms]as above but uses a list of simpset fragments
simpLib.rewrites [thms]constructs a rewrite fragment
simpLib.mk_simpset [ssfrag]constructs a simpset from fragments
simpLib.++(simpset,ssfrag)adds a fragment to a simpset
simpLib.&&(simpset,[thms])adds rewrites to a simpset
simpLib.AC thm thmconstructs tagged theorem to enable AC simplification

Simplification Sets and Fragments

pureSimps.pure_ssminimal simpset for conditional rewriting
boolSimps.bool_sspropositional and first-order logic simplifications, plus beta-conversion
bossLib.std_ssas above + pairs, options, sums, numeral evaluation & eta reduction
bossLib.arith_ssas above + arithmetic rewrites and decision procedure for linear arithmetic
bossLib.list_ssa version of the above for the theory of lists
realLib.real_ssadds some real number evaluation and rewrites to the arithmetic simpset
bossLib.srw_ss()returns stateful simpset; has type theorems from loaded theories
bossLib.augment_srw_ss [ssfrag]adds fragments to the stateful simpset
BasicProvers.export_rewrites [names]exports named theorems to the stateful simpset

Simpset fragments

boolSimps.CONJ_sscongruence rule for conjunction
boolSimps.ETA_sseta conversion
boolSimps.LET_ssrewrites out let terms
boolSimps.DNF_ssconverts term to disjunctive-normal-form
pairSimps.PAIR_ssrewrites for pairs
optionSimps.OPTION_ssrewrites for options
stringSimps.STRING_ssrewrites for strings
numSimps.ARITH_ssarithmetic rewrites and decision procedure
numSimps.ARITH_AC_ssAC fragment for addition and multiplication
numSimps.REDUCE_ssreduces ground-term expressions
listSimps.LIST_ssrewrites for lists
pred_setSimps.SET_SPEC_ssrewrites for set membership
pred_setSimps.PRED_SET_ssrewrites for sets

Specialize and Generalize Rules

Thm.SPEC termspecializes one variable in the conclusion of a theorem
Drule.SPECL [terms]specializes zero or more variables in the conclusion of a theorem
Drule.SPEC_ALLspecializes the conclusion of a theorem with its own quantified variables
Drule.GSPECas above but uses unique variables
Drule.ISPEC termspecializes theorem, with type instantiation if necessary
Drule.ISPECL [terms]specializes theorem zero or more times, with type instantiation if necessary
Thm.INST [term |-> term]instantiates free variables in a theorem
Thm.GEN termgeneralizes the conclusion of a theorem
Thm.GENL [terms]generalizes zero or more variables in the conclusion of a theorem
Drule.GEN_ALLgeneralizes the conclusion of a theorem over its own free variables

Some Inference Rules

Conv.CONV_RULE convmakes an inference rule from a conversion
Conv.GSYM thmreverses the first equation(s) encountered in a top-down search
Drule.NOT_EQ_SYM thmswaps left-hand and right-hand sides of a negated equation
Thm.CONJUNCT1 thmextracts left conjunct of theorem
Thm.CONJUNCT2 thmextracts right conjunct of theorem
Drule.CONJUNCTS thmrecursively splits conjunctions into a list of conjuncts
Drule.MATCH_MP thm thmModus Ponens inference rule with automatic matching
Thm.EQ_MP thm thmequality version of the Modus Ponens rule
Thm.EQ_IMP_RULE thmderives forward and backward implication from equality of boolean terms

Some Conversions

bossLib.DECIDEprove term using a tautology checker and linear arithmetic
Rewrite.REWRITE_CONV [thms]rewrites term using basic rewrites and given theorems
simpLib.SIMP_CONV simpset [thms]simplifies term using simpset and theorems
computeLib.CBV_CONV compsetcall-by-value conversion
numLib.num_CONVequates a non-zero numeral with the form $\mathrm{SUC}\,x$ for some $x$
reduceLib.REDUCE_CONVevaluates arithmetic and boolean ground expressions
numLib.SUC_TO_NUMERAL_DEFN_CONVtranslates $\mathrm{SUC}\,x$ equations to use numeral constructors
numLib.EXISTS_LEAST_CONVwhen applied to a term $\exists n.\,P(n)$, returns:
$\vdash (\exists n.\,P(n)) = \exists n.\,P(n) \wedge \forall n'.\,n' < n \Rightarrow \neg P(n')$
Conv.SYM_CONVinterchanges the left and right-hand sides of an equation
Conv.SKOLEM_CONVproves the existence of a Skolem function
Drule.GEN_ALPHA_CONVrenames the bound variable of an abstraction, quantified term, etc.
Thm.BETA_CONVperforms a single step of beta-conversion
Drule.ETA_CONVperforms a top level eta-conversion
PairRules.GEN_PALPHA_CONVpaired variable version of the above
PairRules.PBETA_CONVpaired variable version of the above
PairRules.PETA_CONVpaired variable version of the above

Quantification Conversions

Conv.SWAP_VARS_CONVswaps two universally quantified variables
Conv.SWAP_EXISTS_CONVswaps two existentially quantified variables
Conv.{NOT|AND|OR}_{EXISTS|FORALL}_CONVmoves operation inwards through quantifier
Conv.{EXISTS|FORALL}_{NOT|AND|OR|IMP}_CONVmoves quantifier inwards through operation
Conv.{LEFT|RIGHT}_{AND|OR|IMP}_{EXISTS|FORALL}_CONVmoves quantifier of left/right operand outward

Conversion Operations

Conv.DEPTH_CONVapplies conversion repeatedly to all sub-terms, in bottom-up order
Conv.REDEPTH_CONVapplies conversion bottom-up to sub-terms, retraversing changed ones
Conv.ONCE_DEPTH_CONVapplies conversion once to the first suitable sub-term in top-down order
Conv.TOP_DEPTH_CONVapplies conversion top-down to all sub-terms, retraversing changed ones
Conv.LAND_CONVapplies conversion to the left-hand argument of a binary operator
Conv.RAND_CONVapplies conversion to the operand of an application
Conv.RATOR_CONVapplies conversion to the operator of an application
Conv.BINOP_CONVapplies conversion to both arguments of a binary operator
Conv.LHS_CONVapplies conversion to the left-hand side of an equality
Conv.RHS_CONVapplies conversion to the right-hand side of an equality
Conv.STRIP_QUANT_CONVapplies conversion underneath a quantifier prefix
Conv.STRIP_BINDER_CONVapplies conversion underneath a binder prefix
Conv.FORK_CONV(conv,conv)applies a pair of conversions to the arguments of a binary operator
Conv.THENC(conv,conv)applies two conversions in sequence
Conv.ORELSEC(conv,conv)applies the first of two conversions that succeeds

Parsing

numLib.prefer_num()give numerals and operators natural number types by default
intLib.prefer_int()give numerals and operators integer types by default
Parse.overload_on(name,term)establishes constant as one of the overloading possibilities for a string
Parse.add_infix(name,int,assoc)adds string as infix with given precedence & associativity to grammar
Parse.set_fixity name fixityallows the fixity of tokens to be updated
Parse.type_abbrev(name,type)establishes a type abbreviation
Parse.add_rule recordadds a parsing/printing rule to the global grammar

The Database

DB.match [names] termattempt to find matching theorems in the specified theories
DB.find stringsearch for theory element by name fragment
DB.axioms nameall the axioms stored in the named theory
DB.theorems nameall the theorems stored in the named theory
DB.definitions nameall the definitions stored in the named theory
DB.export_theory_as_docfiles nameproduce .doc files for the named theory
DB.html_theory nameproduce web-page for the named theory

Tracing

Feedback.traces()returns a list of registered tracing variables
Feedback.set_trace name intset a tracing level for a registered trace
Feedback.reset_trace nameresets a tracing variable to its default value
Feedback.reset_traces()resets all registered tracing variables to their default values

Some commonly-traced variables (with their value ranges):

"Rewrite"tracing variable for term rewriting (0–1)
"Subgoal number"number of printed sub-goals (10–10000)
"meson"for the first-order prover (1–2)
"numeral types"show types of numerals (0–1)
"simplifier"for the simplifier (0–7)
"types"printing of types (0–2)
Globals.show_types := boolflag controlling printing of HOL types
Globals.show_assums := boolflag for controlling display of theorem assumptions
Globals.show_tags := boolflag for controlling display of tags in theorem pretty-printer
Lib.start_time()set a timer running
Lib.end_time namecheck a running timer, and print out how long it has been running
Lib.time functionmeasure how long a function application takes
Count.thm_count()returns the current value of the theorem counter
Count.reset_thm_count()resets the theorem counter
Count.apply functionreturns the theorem count for a function application