Proving decidability of Intuitionistic Propositional Calculus
on Coq
Masaki Hara (qnighy)
University of Tokyo, first grade
Logic Zoo 2013 γ«γ¦
1. Task & Known results
2. Brief methodology of the proof
1. Cut elimination
2. Contraction elimination
3. βπΏ elimination
4. Proof of strictly-decreasingness
3. Implementation detail
4. Further implementation plan
Task
β’ Proposition: π΄π‘ππ π , β§, β¨, β, β₯
β’ Task: Is given propositional formula P provable in LJ?
β Itβs known to be decidable. [Dyckhoff]
β’ This talk: how to prove this decidability on Coq
Known results
β’ Decision problem on IPC is PSPACE complete [Statman]
β Especially, O(N log N) space decision procedure is known [Hudelmaier]
β’ These approaches are backtracking on LJ syntax.
Known results
β’ cf. classical counterpart of this problem is co-NP complete.
β Proof: find counterexample in boolean-valued semantics (SAT).
methodology
β’ To prove decidability, all rules should be strictly decreasing on some measuring.
β’ More formally, for all rules π1,π2,β¦,ππ
π0ππ’ππ
and all number π (1 β€ π β€ π), ππ < π0
on certain well-founded relation <.
methodology
1. Eliminate cut rule of LJ
2. Eliminate contraction rule
3. Split βπ³ rule into 4 pieces
4. Prove that every rule is strictly decreasing
Sequent Calculus LJ
β’Ξβ’πΊ
π΄,Ξβ’πΊπ€πππ
π΄,π΄,Ξβ’πΊ
π΄,Ξβ’πΊππππ‘π
Ξβ’π΄ π΄,Ξβ’πΊ
Ξ,Ξβ’πΊ(ππ’π‘)
β’
π΄β’π΄ππ₯πππ
β₯β’πΊ(ππ₯ππππ π)
β’Ξβ’π΄ π΅,Ξβ’πΊ
π΄βπ΅,Ξβ’πΊβπΏ
π΄,Ξβ’π΅
Ξβ’π΄βπ΅(βπ )
β’π΄,π΅,Ξβ’πΊ
π΄β§π΅,Ξβ’πΊβ§πΏ
Ξβ’π΄ Ξβ’π΅
Ξβ’π΄β§π΅(β§π )
β’π΄,Ξβ’πΊ π΅,Ξβ’πΊ
π΄β¨π΅,Ξβ’πΊβ¨πΏ
Ξβ’π΄
Ξβ’π΄β¨π΅β¨π 1
Ξβ’π΅
Ξβ’π΄β¨π΅β¨π 2
β’
Sequent Calculus LJ
β’Ξβ’πΊ
π΄,Ξβ’πΊπ€πππ
π΄,π΄,Ξβ’πΊ
π΄,Ξβ’πΊππππ‘π
Ξβ’π΄ π΄,Ξβ’πΊ
Ξ,Ξβ’πΊ(ππ’π‘)
β’
π΄β’π΄ππ₯πππ
β₯β’πΊ(ππ₯ππππ π)
β’Ξβ’π΄ π΅,Ξβ’πΊ
π΄βπ΅,Ξβ’πΊβπΏ
π΄,Ξβ’π΅
Ξβ’π΄βπ΅(βπ )
β’π΄,π΅,Ξβ’πΊ
π΄β§π΅,Ξβ’πΊβ§πΏ
Ξβ’π΄ Ξβ’π΅
Ξβ’π΄β§π΅(β§π )
β’π΄,Ξβ’πΊ π΅,Ξβ’πΊ
π΄β¨π΅,Ξβ’πΊβ¨πΏ
Ξβ’π΄
Ξβ’π΄β¨π΅β¨π 1
Ξβ’π΅
Ξβ’π΄β¨π΅β¨π 2
β’ We eliminate cut rule first.
Cut elimination
β’ 1. Prove these rule by induction on proof structure.
β’Ξβ’πΊ
Ξ,Ξβ’πΊπ€ππππΊ
Ξ,Ξ,Ξβ’πΊ
Ξ,Ξβ’πΊππππ‘ππΊ
β’Ξβ’β₯
Ξβ’πΊβ₯π πΈ
β’Ξβ’π΄β§π΅
Ξβ’π΄β§π πΈ1
Ξβ’π΄β§π΅
Ξβ’π΅β§π πΈ2
β’Ξβ’π΄βπ΅
π΄,Ξβ’π΅βπ πΈ
β’ If Ξ1β’π΄ π΄,Ξ1β’πΊ1
Ξ1,Ξ1β’πΊ1(ππ’π‘π΄) and
Ξ2β’π΅ π΅,Ξ2β’πΊ2
Ξ2,Ξ2β’πΊ2(ππ’π‘π΅) for all
Ξ1, Ξ2, Ξ1, Ξ2, πΊ1, πΊ2 , then Ξβ’π΄β¨π΅ A,Ξβ’πΊ π΅,Ξβ’πΊ
Ξ,Ξβ’πΊ(β¨π πΈ)
Cut elimination
β’ 2. Prove the general cut rule Ξ β’ π΄γπ΄π, Ξ β’ πΊ
Ξ, Ξ β’ πΊππ’π‘πΊ
by induction on the size of π΄ and proof structure of the right hand.
β’ 3. specialize ππ’π‘πΊ (n = 1) β
Cut-free LJ
β’Ξβ’πΊ
π΄,Ξβ’πΊπ€πππ
π΄,π΄,Ξβ’πΊ
π΄,Ξβ’πΊππππ‘π
β’
π΄β’π΄ππ₯πππ
β₯β’πΊ(ππ₯ππππ π)
β’Ξβ’π΄ π΅,Ξβ’πΊ
π΄βπ΅,Ξβ’πΊβπΏ
π΄,Ξβ’π΅
Ξβ’π΄βπ΅(βπ )
β’π΄,π΅,Ξβ’πΊ
π΄β§π΅,Ξβ’πΊβ§πΏ
Ξβ’π΄ Ξβ’π΅
Ξβ’π΄β§π΅(β§π )
β’π΄,Ξβ’πΊ π΅,Ξβ’πΊ
π΄β¨π΅,Ξβ’πΊβ¨πΏ
Ξβ’π΄
Ξβ’π΄β¨π΅β¨π 1
Ξβ’π΅
Ξβ’π΄β¨π΅β¨π 2
β’
Cut-free LJ
β’Ξβ’πΊ
π΄,Ξβ’πΊπ€πππ
π΄,π΄,Ξβ’πΊ
π΄,Ξβ’πΊππππ‘π
β’
π΄β’π΄ππ₯πππ
β₯β’πΊ(ππ₯ππππ π)
β’Ξβ’π΄ π΅,Ξβ’πΊ
π΄βπ΅,Ξβ’πΊβπΏ
π΄,Ξβ’π΅
Ξβ’π΄βπ΅(βπ )
β’π΄,π΅,Ξβ’πΊ
π΄β§π΅,Ξβ’πΊβ§πΏ
Ξβ’π΄ Ξβ’π΅
Ξβ’π΄β§π΅(β§π )
β’π΄,Ξβ’πΊ π΅,Ξβ’πΊ
π΄β¨π΅,Ξβ’πΊβ¨πΏ
Ξβ’π΄
Ξβ’π΄β¨π΅β¨π 1
Ξβ’π΅
Ξβ’π΄β¨π΅β¨π 2
β’ Contraction rule is not strictly decreasing
Contraction-free LJ
β’
π΄,Ξβ’π΄ππ₯πππ
β₯,Ξβ’πΊ(ππ₯ππππ π)
β’π΄βπ΅,Ξβ’π΄ π΅,Ξβ’πΊ
π΄βπ΅,Ξβ’πΊβπΏ
π΄,Ξβ’π΅
Ξβ’π΄βπ΅(βπ )
β’π΄,π΅,Ξβ’πΊ
π΄β§π΅,Ξβ’πΊβ§πΏ
Ξβ’π΄ Ξβ’π΅
Ξβ’π΄β§π΅(β§π )
β’π΄,Ξβ’πΊ π΅,Ξβ’πΊ
π΄β¨π΅,Ξβ’πΊβ¨πΏ
Ξβ’π΄
Ξβ’π΄β¨π΅β¨π 1
Ξβ’π΅
Ξβ’π΄β¨π΅β¨π 2
Contraction-free LJ
β’ Implicit weak
β
π΄,Ξβ’π΄ππ₯πππ
β₯,Ξβ’πΊ(ππ₯ππππ π)
β’ Implicit contraction
βπ΄βπ΅,Ξβ’π΄ π΅,Ξβ’πΊ
π΄βπ΅,Ξβ’πΊβπΏ
βΞβ’π΄ Ξβ’π΅
Ξβ’π΄β§π΅(β§π )
βπ΄,Ξβ’πΊ π΅,Ξβ’πΊ
π΄β¨π΅,Ξβ’πΊβ¨πΏ
Contraction-free LJ
β’ Implicit weak
β
π΄,Ξβ’π΄ππ₯πππ
β₯,Ξβ’πΊ(ππ₯ππππ π)
β’ Implicit contraction
βπ΄βπ΅,Ξβ’π΄ π΅,Ξβ’πΊ
π΄βπ΅,Ξβ’πΊβπΏ
βΞβ’π΄ Ξβ’π΅
Ξβ’π΄β§π΅(β§π )
βπ΄,Ξβ’πΊ π΅,Ξβ’πΊ
π΄β¨π΅,Ξβ’πΊβ¨πΏ
Proof of weak rule
β’ Easily done by induction β
Proof of contr rule
β’ 1. prove these rules by induction on proof structure.
βπ΄β§π΅,Ξβ’πΊ
π΄,π΅,Ξβ’πΊβ§πΏπΈ
π΄β¨π΅,Ξβ’πΊ
π΄,Ξβ’πΊβ¨πΏπΈ1
π΄β¨π΅,Ξβ’πΊ
π΅,Ξβ’πΊ(β¨πΏπΈ2)
βπ΄βπ΅,Ξβ’πΊ
π΅,Ξβ’πΊ(βπ€πππ)
β’ 2. prove contr rule by induction on proof structure.β
Contraction-free LJ
β’
π΄,Ξβ’π΄ππ₯πππ
β₯,Ξβ’πΊ(ππ₯ππππ π)
β’π΄βπ΅,Ξβ’π΄ π΅,Ξβ’πΊ
π΄βπ΅,Ξβ’πΊβπΏ
π΄,Ξβ’π΅
Ξβ’π΄βπ΅(βπ )
β’π΄,π΅,Ξβ’πΊ
π΄β§π΅,Ξβ’πΊβ§πΏ
Ξβ’π΄ Ξβ’π΅
Ξβ’π΄β§π΅(β§π )
β’π΄,Ξβ’πΊ π΅,Ξβ’πΊ
π΄β¨π΅,Ξβ’πΊβ¨πΏ
Ξβ’π΄
Ξβ’π΄β¨π΅β¨π 1
Ξβ’π΅
Ξβ’π΄β¨π΅β¨π 2
Contraction-free LJ
β’
π΄,Ξβ’π΄ππ₯πππ
β₯,Ξβ’πΊ(ππ₯ππππ π)
β’π΄βπ΅,Ξβ’π΄ π΅,Ξβ’πΊ
π΄βπ΅,Ξβ’πΊβπΏ
π΄,Ξβ’π΅
Ξβ’π΄βπ΅(βπ )
β’π΄,π΅,Ξβ’πΊ
π΄β§π΅,Ξβ’πΊβ§πΏ
Ξβ’π΄ Ξβ’π΅
Ξβ’π΄β§π΅(β§π )
β’π΄,Ξβ’πΊ π΅,Ξβ’πΊ
π΄β¨π΅,Ξβ’πΊβ¨πΏ
Ξβ’π΄
Ξβ’π΄β¨π΅β¨π 1
Ξβ’π΅
Ξβ’π΄β¨π΅β¨π 2
β’ This time, βπΏ rule is not decreasing
Terminating LJ
β’ Split π΄βπ΅,Ξβ’π΄ π΅,Ξβ’πΊ
π΄βπ΅,Ξβ’πΊβπΏ into 4 pieces
1. πΆ,π΄π‘ππ π ,Ξβ’πΊ
π΄π‘ππ π βπΆ,π΄π‘ππ π ,Ξβ’πΊβπΏ1
2. π΅βπΆ,Ξβ’π΄βπ΅ C,Ξβ’πΊ
π΄βπ΅ βπΆ,Ξβ’πΊ(βπΏ2)
3. π΄β π΅βπΆ ,Ξβ’πΊ
π΄β§π΅ βπΆ,Ξβ’πΊ(βπΏ3)
4. π΄βπΆ,π΅βπΆ,Ξβ’πΊ
π΄β¨π΅ βπΆ,Ξβ’πΊ(βπΏ4)
Correctness of Terminating LJ
β’ 1. If Ξ β’ πΊ is provable in Contraction-free LJ, At least one of these is true:
β Ξ includes β₯, π΄ β§ π΅, or π΄ β¨ π΅
β Ξ includes both π΄π‘ππ(π) and π΄π‘ππ π β π΅
β Ξ β’ πΊ has a proof whose bottommost rule is not the form of π΄π‘ππ π βπ΅,π΄π‘ππ π ,Ξβ’π΄π‘ππ π π΅,π΄π‘ππ π ,Ξβ’πΊ
π΄π‘ππ π βπ΅,π΄π‘ππ(π),Ξβ’πΊ(βπΏ)
β’ Proof: induction on proof structure
Correctness of Terminating LJ
β’ 2. every sequent provable in Contraction-free LJ is also provable in Terminating LJ.
β’ Proof: induction by size of the sequent.
β Size: we will introduce later
Terminating LJ
β’
π΄,Ξβ’π΄ππ₯πππ
β₯,Ξβ’πΊ(ππ₯ππππ π)
β’ πΆ,π΄π‘ππ π ,Ξβ’πΊ
π΄π‘ππ π βπΆ,π΄π‘ππ π ,Ξβ’πΊβπΏ1
π΅βπΆ,Ξβ’π΄βπ΅ C,Ξβ’πΊ
π΄βπ΅ βπΆ,Ξβ’πΊβπΏ2
β’π΄β π΅βπΆ ,Ξβ’πΊ
π΄β§π΅ βπΆ,Ξβ’πΊβπΏ3
π΄βπΆ,π΅βπΆ,Ξβ’πΊ
π΄β¨π΅ βπΆ,Ξβ’πΊβπΏ4
β’π΄,Ξβ’π΅
Ξβ’π΄βπ΅βπ
π΄,π΅,Ξβ’πΊ
π΄β§π΅,Ξβ’πΊβ§πΏ
Ξβ’π΄ Ξβ’π΅
Ξβ’π΄β§π΅(β§π )
β’π΄,Ξβ’πΊ π΅,Ξβ’πΊ
π΄β¨π΅,Ξβ’πΊβ¨πΏ
Ξβ’π΄
Ξβ’π΄β¨π΅β¨π 1
Ξβ’π΅
Ξβ’π΄β¨π΅β¨π 2
Proof of termination
β’ Weight of Proposition
β π€ π΄π‘ππ π = 1
β π€ β₯ = 1
β π€ π΄ β π΅ = π€ π΄ + π€ π΅ + 1
β π€ π΄ β§ π΅ = π€ π΄ + π€ π΅ + 2
β π€ π΄ β¨ π΅ = π€ π΄ + π€ π΅ + 1
β’ π΄ < π΅ β π€ π΄ < π€(π΅)
Proof of termination
β’ ordering of Proposition List
β Use Multiset ordering (Dershowitz and Manna ordering)
Multiset Ordering
β’ Multiset Ordering: a binary relation between multisets (not necessarily be ordering)
β’ π΄ > π΅ β
A
B
Not empty
Multiset Ordering
β’ If π is a well-founded binary relation, the Multiset Ordering over π is also well-founded.
β’ Well-founded: every element is accessible
β’ π΄ is accessible : every element π΅ such that π΅ < π΄ is accessible
Multiset Ordering
Proof
β’ 1. induction on list
β’ Nil β there is no π΄ such that π΄ <π Nil, therefore itβs accessible.
β’ We will prove: π΄πππ πΏ β π΄πππ(π₯ β· πΏ)
Multiset Ordering
β’ 2. duplicate assumption
β’ Using π΄ππ(π₯) and π΄πππ(πΏ), we will prove π΄πππ πΏ β π΄πππ(π₯ β· πΏ)
β’ 3. induction on π₯ and πΏ
β We can use these two inductive hypotheses.
1. βπΎ π¦, π¦ < π₯ β π΄πππ πΎ β π΄πππ(π¦ β· πΎ)
2. βπΎ, πΎ <π πΏ β π΄πππ πΎ β π΄πππ(π₯ β· πΎ)
Multiset Ordering
β’ 4. Case Analysis β’ By definition, π΄πππ(π₯ β· πΏ) is equivalent to
βπΎ, πΎ <π (π₯ β· πΏ) β π΄πππ(πΎ) β’ And there are 3 patterns:
1. πΎ includes π₯ 2. πΎ includes π¦s s.t. π¦ < π₯, and πΎ minus all such π¦ is
equal to πΏ 3. πΎ includes π¦s s.t. π¦ < π₯, and πΎ minus all such π¦ is
less than πΏ
β’ Each pattern is proved using the Inductive Hypotheses.
Decidability
β’ Now, decidability can be proved by induction on the size of sequent.
Implementation Detail
β’
IPC Proposition (Coq)
β’ Inductive PProp:Set := | PPbot : PProp | PPatom : nat -> PProp | PPimpl : PProp -> PProp -> PProp | PPconj : PProp -> PProp -> PProp | PPdisj : PProp -> PProp -> PProp.
Cut-free LJ (Coq)
β’ Inductive LJ_provable : list PProp -> PProp -> Prop := | LJ_perm P1 L1 L2 : Permutation L1 L2 -> LJ_provable L1 P1 -> LJ_provable L2 P1 | LJ_weak P1 P2 L1 : LJ_provable L1 P2 -> LJ_provable (P1::L1) P2 | LJ_contr P1 P2 L1 : LJ_provable (P1::P1::L1) P2 -> LJ_provable (P1::L1) P2 β¦
Exchange rule
β’ Exchange rule : Ξ, π΄, π΅, Ξ β’ πΊ
Ξ, π΅, π΄, Ξ β’ πΊππ₯πβ
is replaced by more useful Ξ β’ πΊ
Ξβ² β’ πΊπππππ’π‘ππ‘πππ
where Ξ, Ξβ² are permutation
Permutation Compatibility (Coq)
β’ Allows rewriting over Permutation equality
Instance LJ_provable_compat : Proper (@Permutation _==>eq==>iff) LJ_provable.
Permutation solver (Coq)
β’ Permutation should be solved automatically
Ltac perm := match goal with β¦
Further implementation plan
β’
Further implementation plan
β’ Refactoring (1) : improve Permutation-associated tactics
β A smarter auto-unifying tactics is needed
β Write tactics using Objective Caml
β’ Refactoring (2) : use Ssreflect tacticals
β This makes the proof more manageable
Further implementation plan
β’ Refactoring (3) : change proof order
β Contraction first, cut next
β It will make the proof shorter
β’ Refactoring (4) : discard Multiset Ordering
β If we choose appropriate weight function of Propositional Formula, we donβt need Multiset Ordering. (See [Hudelmaier])
β It also enables us to analyze complexity of this procedure
Further implementation plan
β’ Refactoring (5) : Proof of completeness
β Now completeness theorem depends on the decidability
β’ New Theorem (1) : Other Syntaxes
β NJ and HJ may be introduced
β’ New Theorem (2) : Other Semantics
β Heyting Algebra
Further implementation plan
β’ New Theorem (3) : Other decision procedure
β Decision procedure using semantics (if any)
β More efficient decision procedure (especially π(π log π)-space decision procedure)
β’ New Theorem (4) : Complexity
β Proof of PSPACE-completeness
Source code
β’ Source codes are:
β’ https://github.com/qnighy/IPC-Coq
γγγ
1. Task & Known results
2. Brief methodology of the proof
1. Cut elimination
2. Contraction elimination
3. βπΏ elimination
4. Proof of strictly-decreasingness
3. Implementation detail
4. Further implementation plan
References
β’ [Dyckhoff] Roy Dyckhoff, Contraction-free Sequent Calculi for Intuitionistic Logic, The Journal of Symbolic Logic, Vol. 57, No.3, 1992, pp. 795 β 807
β’ [Statman] Richard Statman, Intuitionistic Propositional Logic is Polynomial-Space Complete, Theoretical Computer Science 9, 1979, pp. 67 β 72
β’ [Hudelmaier] JΓΆrg Hudelmaier, An O(n log n)-Space Decision Procedure for Intuitionistic Propositional Logic, Journal of Logic and Computation, Vol. 3, Issue 1, pp. 63-75