Refined program extraction with free parameters (Corollary 5.3, corrected)
ProvedBBS2002.V2.corollary_5_3mathematical-logicprogram-extractionrealizabilitytype-theory
Let be definite formulas, let be a goal formula, and let the object variable be fresh for . Fix a typed closed dummy term of type . There are correctly typed formula realizers and a goal combinator , chosen before any proof . Each has free variables only from ; has free variables only from , excluding . For every derivation of with no free assumption variables and admissible translated naming, there exists a term whose raw extraction equation is exactly . The output , omitting irrelevant arguments, has type and satisfies . Free object parameters of are permitted. Successful extraction is a conclusion, with no fallback program used.
Preamble
import Definitions.Def_BBS2002_V2_Realizability
Formal statement
namespace BBS2002.V2
/-- Classical extraction for definite assumptions and one goal formula. The object terms
realizing the formulas are independent of `M`; a proof may retain free object parameters,
but must have no free assumption variables. -/
theorem corollary_5_3
(Ds : List Formula) (G : Formula) (y : Var) (dummy : Term)
(hDs : ∀ D ∈ Ds, IsDefiniteFormula D)
(hG : IsGoalFormula G)
(hyDs : ∀ D ∈ Ds, y ∉ freeVarsFormula D)
(hDummyTy : HasType dummy y.ty)
(hDummyClosed : IsClosedTerm dummy) :
∃ (ts : (j : Fin Ds.length) → Realizer (tau y.ty (substBotWithX (Ds.get j))))
(s : Term),
(∀ j, (ts j).Typed) ∧
(∀ j, ∀ t₀ ∈ (ts j).toOption, ∀ x ∈ freeVars t₀, x ∈ freeVarsFormula (Ds.get j)) ∧
HasType s
(.arr y.ty (match tau y.ty (substBotWithX G) with
| none => y.ty
| some ρ => .arr ρ y.ty)) ∧
(∀ x ∈ freeVars s, x ∈ freeVarsFormula G ∧ x ≠ y) ∧
(∀ M : ProofTerm,
Derivable SysConfig.Z0 M (Formula.impMany Ds (goalImpliesBot [y] [G])) →
freeAssumpVars M = [] →
AdmissibleForExtraction y.ty dummy (substBotProof M) →
∃ p : Term,
extractRaw y.ty dummy (substBotProof M) = some p ∧
let output := .app (applyOptTerms p (List.ofFn (fun j ↦ (ts j).toOption))) s
HasType output y.ty ∧
Provable SysConfig.Z (Formula.impMany Ds (substFormula G y output))) := by
sorry
end BBS2002.V2Source
Ulrich Berger, Wilfried Buchholz, and Helmut Schwichtenberg, Refined program extraction from classical proofs, Annals of Pure and Applied Logic 114 (2002), pp. 3–25, https://doi.org/10.1016/S0168-0072(01)00073-2; page references below use the author's preprint pagination. Corollary 5.3, preprint p. 14; Section 4's extraction and typing conventions, pp. 11–12.