Constraint Orientation in CompareTypes (Theorem 10) and Bipartiteness of Call-Site Constraint Graphs (Theorems 11 & 12)
DisprovedNishtAbel2024.theorems_10_11_and_12Theorems 10, 11, and 12 (Section 6.3, pp. 52–56): (1) every constraint mentioning a polarized size variable i in CompareTypes Φ Δ ι π A C Cs is oriented according to a ≤^{π π' π''} i; (2) InferTerm and CheckTerm preserve fixpoint polarity invariants and emit no constraint from a flexible variable to a tracked variable i ∈ X; and (3) across any encoded copattern clause body, no constraint has a flexible variable on the LHS and a rigid variable on the RHS.
Superseded. This is the first formalization of Theorems 10–12 (pp. 52–56) of
the thesis. It is refuted through its Theorem 11 conjunct by the disproof
66d9f635-be98-4efa-83f1-846d677c4882. A positive rigid size variable occurs twice in the
type of a variable , inside a least fixpoint and
also at the outer greatest fixpoint. The statement's hypotheses check only one
occurrence and accept this. Inferring the projection then emits a
constraint with a fresh flexible variable , which Theorem 11 forbids.
The thesis requires that, for positive polarity, all occurrences of a rigid
variable lie in least fixpoints (§6.3.4), so this is a missing hypothesis, not a
counterexample to the thesis. Corrected statement:
NishtAbel2024V2.theorems_10_11_and_12. It concerns the instrumented judgments
GuardedCompareTypes, SafeInferTerm and SafeCheckTerm, which track size
occurrences explicitly.
import Definitions.Def_NishtAbel2024_Syntax import Definitions.Def_NishtAbel2024_Inference
namespace NishtAbel2024
/-- Theorem 10 (Polarities in type comparison, pp. 52–53),
Theorem 11 (Nature of rigid variables, pp. 53–54), and
Theorem 12 (Rigid variables in constraints, pp. 55–56):
1. (**Theorem 10**) Under `FlexPolHygiene`, if `(i, π') ∈ Φ` (`π' ∈ {+, −}`) occurs in `C` only
with polarity `π'' ∈ {+, −}` (and not in `A`), then in `Φ; Δ; ι ⊢_{SCT} A ≤^π C ⇒ Cs`, every
constraint in `Cs` mentioning `i` has the polarized form `a ≤^{π π' π''} i`.
2. (**Theorem 11**) Under `RigidVarHypotheses π X Φ₀ Γ Δ A`, neither call-site inference nor
call-site checking generates a constraint `(j R i) ∈ Cs` with flexible `j ∈ Φ \ X` and rigid
`i ∈ X`; in inference mode, every `i ∈ X` either occurs in the inferred type `C` with polarity
`π` or does not occur in `C`.
3. (**Theorem 12**) For any clause body checked after signature encoding and copattern-spine
matching, no constraint `(k R j) ∈ Cs` has a flexible variable `k ∈ Φ \ (Ψ₁ ++ Ψ₂)` on the LHS
and a rigid variable `j ∈ Ψ₁ ++ Ψ₂` on the RHS. -/
theorem theorems_10_11_and_12 :
(∀ (Φ : FlexVars) (Δ : KindingCtx) (ι : SKind) (π π' π'' : Polarity)
(A C : TypeExpr) (Cs : List SizeConstraint) (i : SizeVar),
FlexPolHygiene Φ Δ A C →
Φ.lookupPol i = some π' →
(π' = .pos ∨ π' = .neg) →
(π'' = .pos ∨ π'' = .neg) →
¬ SizeOccursIn i A →
(∀ fk π₀, SizeOccursFixPol Δ fk i π₀ C →
π₀ = π'' ∧ ((fk = .mu ∧ π' = .pos) ∨ (fk = .nu ∧ π' = .neg))) →
CompareTypes Φ Δ ι π A C Cs →
∀ c ∈ Cs, c.mentions i = true →
∃ a : SizeExp,
c ∈ SizeConstraint.ofPol (Polarity.comp (Polarity.comp π π') π'') a (.var i 0)) ∧
(∀ (sig : GlobalSig) (Ξ : MutualBlock) (π : Polarity) (X : List SizeVar)
(Φ₀ Φ : FlexVars) (Γ : TermCtx) (Δ : KindingCtx) (A C : TypeExpr)
(t t' : Term) (Cs : List SizeConstraint) (T : List SizeVar),
RigidVarHypotheses π X Φ₀ Γ Δ A →
((InferTerm sig Ξ Φ₀ Γ Δ t C Φ Cs T t' →
(∀ i ∈ X, ∀ j ∈ Φ.dom, j ∉ X →
∀ c ∈ Cs, ¬ (c.lhs = .var j 0 ∧ c.rhs = .var i 0)) ∧
(∀ i ∈ X,
SizeOccursFixPol Δ (if π == .pos then .mu else .nu) i π C ∨ ¬ SizeOccursIn i C)) ∧
(CheckTerm sig Ξ Φ₀ Γ Δ A t Φ Cs T t' →
∀ i ∈ X, ∀ j ∈ Φ.dom, j ∉ X →
∀ c ∈ Cs, ¬ (c.lhs = .var j 0 ∧ c.rhs = .var i 0)))) ∧
(∀ (sig : GlobalSig) (Ξ : MutualBlock) (Δ₀ : KindingCtx)
(Ψ₁ Ψ₂ : SizeCtx) (A A₀ A'' : TypeExpr) (qs qs' : PatSpine)
(Γ : TermCtx) (Δ : List TyDecl) (t t' : Term)
(Φ : FlexVars) (Cs : List SizeConstraint) (T : List SizeVar),
EncodeType .neg .pos Δ₀ A Ψ₁ A₀ →
SignatureFixpointHygiene (Δ₀.extSizes Ψ₁) A₀ →
InferSpine (Δ₀.extSizes Ψ₁) qs A₀ A'' Γ Δ Ψ₂ qs' →
CheckTerm sig Ξ ((Ψ₁ ++ Ψ₂).map (fun d => (d.var, d.pol)))
Γ ((Δ₀.extSizes Ψ₁).append ⟨Ψ₂, Δ⟩) A'' t Φ Cs T t' →
∀ k ∈ Φ.dom, k ∉ (Ψ₁ ++ Ψ₂).dom →
∀ j ∈ (Ψ₁ ++ Ψ₂).dom,
∀ c ∈ Cs, ¬ (c.lhs = .var k 0 ∧ c.rhs = .var j 0)) := by
sorry
end NishtAbel2024Read-back
What the Lean code literally says, in plain math · Gemini 3.1 Pro (Independent Blind Auditor)
Independent Mathematical Read-Back: Thm_NishtAbel2024_theorems_10_11_and_12.lean
The declaration theorems_10_11_and_12 asserts the conjunction of three universally quantified implications concerning the direction of size constraints generated during subtype comparison (CompareTypes) and bidirectional term inference/checking (InferTerm, CheckTerm).
Underlying data and judgments unfolded across the three conjuncts:
- Flexible variables (
FlexVars) and size constraints (SizeConstraint): A flexible variable context is an association list of pairs with domain . Lookup returns the polarity of the first entry with variable . Size-expression polarity lookup returns if , returns if (unshifted singleton variable), and returns otherwise. ASizeConstraintis a triple (lhs,rel,rhs) with . Polarity-directed constraint generationSizeConstraint.ofPol π a byields if , if , if , and if . The boolean predicatec.mentions iis true iff . - Type comparison (
CompareTypes Φ Δ ι π A C Cs): Inductively compares types and at simple kind and polarity in :- Identical atoms
.atom Kproduce . - Applications and at require
KindInfer Δ F' (.arr π₁ (ofSKind ι₁) (ofSKind ι₂)), compare at and polarity in giving , compare at and polarity in giving , and return . - At arrow kind , rule
lampicks a type variable and compares and at and polarity in . - Fixpoints and (resp. and ) at require and (resp. using default for ), compare branches pairwise at and polarity in giving , and return , where is the join on with bottom and top .
- Identical atoms
- Bidirectional constraint generation (
InferTerm,CheckTerm,CheckClauseInfer,CheckClausesInfer): Takes global signaturesig, mutual block , initial flexible variables , term context , kinding context , and term (plus target type forCheckTerm), producing output flexible variables , constraint list , tracked size variables , and elaborated term (plus inferred type forInferTerm):- Projections from pick a fresh , prepend to , and emit .
- Constructors at pick a fresh , check under , and emit .
- Type applications, ascriptions, and existential packs encode their type arguments/annotations via
EncodeType .mixed .mixed Δ G Ψ G'with disjoint from the current flexible variable domain, and prepend to the flexible variables. - Function calls
funRef decl.name []for pick fresh duplicate-freeflexVarsof length with polarities in respecting and in , prependflexVarsto , and emit no constraints. - Subsumption (
CheckTerm.sub) infers at giving , requiresFlexPolHygiene Φ' Δ A Cty, runsCompareTypes Φ' Δ .star .pos A Cty C₂, and outputs . - Clauses
Clause.mk qs trunInferSpine Δ qs C C' Γ' Δ' Ψ qs', replace any bound in with by (trivializeCtx Φ Ψ), and check under .
The three conjuncts literally state:
- Constraint orientation in
CompareTypes(Conjunct 1): For all flexible variable contexts , kinding contexts , simple kinds , polarities , types , constraint lists , and size variables , if:FlexPolHygiene Φ Δ A Cholds (meaning for every , if , any or fixpoint occurrence of in or forces , and any or fixpoint occurrence of in or forces ),- , with and ,
- (
¬ SizeOccursIn i A), - for every and ,
SizeOccursFixPol Δ fk i π₀ Cimplies and , and CompareTypes Φ Δ ι π A C Csholds, then for every constraint withc.mentions i = true, there exists a size expression such that
-
Absence of flexible-to-rigid constraints and polarity preservation in
InferTermandCheckTerm(Conjunct 2): For allsig, , polarities , size variable lists , flexible variable contexts , term contexts , kinding contexts , types , terms , constraint lists , and size variable lists , supposeRigidVarHypotheses π X Φ₀ Γ Δ Aholds — meaning and, setting if and if , every satisfies:- ,
- for all , , and
- . Then:
- If
InferTerm sig Ξ Φ₀ Γ Δ t C Φ Cs T t'holds, then (a) for all , all with , and all , it is not the case that ; and (b) for all , either or . - If
CheckTerm sig Ξ Φ₀ Γ Δ A t Φ Cs T t'holds, then for all , all with , and all , it is not the case that .
-
Absence of flexible-to-rigid constraints across an encoded clause body (Conjunct 3): For all
sig, , , , , , , , , , , , if:EncodeType .neg .pos Δ₀ A Ψ₁ A₀,SignatureFixpointHygiene (Δ₀.extSizes Ψ₁) A₀,InferSpine (Δ₀.extSizes Ψ₁) qs A₀ A'' Γ Δ Ψ₂ qs', andCheckTerm sig Ξ ((Ψ₁ ++ Ψ₂).map (fun d => (d.var, d.pol))) Γ ((Δ₀.extSizes Ψ₁).append ⟨Ψ₂, Δ⟩) A'' t Φ Cs T t', then for every with , every , and every , it is not the case that .
Degenerate cases, vacuous hypotheses, and anomalies:
- Unreferenced universal variable in the
InferTermhalf of Conjunct 2: In Conjunct 2, is universally quantified outside the conjunction of theInferTermandCheckTermimplications and appears inRigidVarHypotheses π X Φ₀ Γ Δ A, even thoughInferTerm sig Ξ Φ₀ Γ Δ t C Φ Cs T t'does not mention (instantiating always satisfies the -condition inRigidVarHypotheses). - Exact syntactic inequality in Conjuncts 2 and 3: The conclusion only rules out constraints whose left-hand side is literally the unshifted singleton variable and whose right-hand side is literally ; it makes no assertion about shifted variables with or formal minima with non-empty tails.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.