Two Variables And the Magic Wand St´ ephane Demri Joint work with Morgan Deters CNRS – Marie Curie Fellow Nancy, September 2014
Heaps • Heap h : N ⇀ N with finite domain. h 4111 411 411 41 4 2 3 31 311 42 1 421 422 11 12 121 122 2
Disjoint heaps • Disjoint heaps: dom ( h 1 ) ∩ dom ( h 2 ) = ∅ (noted h 1 ⊥ h 2 ). • When h 1 ⊥ h 2 , disjoint heap h 1 ⊎ h 2 . = ⊎ 3
Logic 1SL • Quantified variables FVAR = { u 1 , u 2 , u 3 , . . . } . • Atomic formulae: π ::= u i = u j | u i ֒ → u j | emp |⊥ • Formulae φ ::= π | φ ∧ ψ | ¬ φ | φ ∗ ψ | φ − ∗ ψ | ∃ u φ 4
Logic 1SL • Quantified variables FVAR = { u 1 , u 2 , u 3 , . . . } . • Atomic formulae: π ::= u i = u j | u i ֒ → u j | emp |⊥ • Formulae φ ::= π | φ ∧ ψ | ¬ φ | φ ∗ ψ | φ − ∗ ψ | ∃ u φ def • h | = f emp ⇔ dom ( h ) = ∅ . def • h | = f u i = u j ⇔ f ( u i ) = f ( u j ) . def • h | = f u i ֒ → u j ⇔ f ( u i ) ∈ dom ( h ) and h ( f ( u i )) = f ( u j ) . 4
Separating conjunction h | = f φ 1 ∗ φ 2 def ⇔ for some h 1 , h 2 such that h = h 1 ⊎ h 2 , h 1 | = f φ 1 and h 2 | = f φ 2 5
Satisfiability problem ⇔ for all h ′ , if h ⊥ h ′ and h ′ | def • h | = f φ 1 − ∗ φ 2 = f φ 1 , then h ⊎ h ′ | = f φ 2 . def ⇔ there is l ∈ N such that h | • h | = f ∃ u φ = f [ u �→ l ] φ where f [ u �→ l ] is the assignment equal to f except that u takes the value l . 6
Satisfiability problem ⇔ for all h ′ , if h ⊥ h ′ and h ′ | def • h | = f φ 1 − ∗ φ 2 = f φ 1 , then h ⊎ h ′ | = f φ 2 . def ⇔ there is l ∈ N such that h | • h | = f ∃ u φ = f [ u �→ l ] φ where f [ u �→ l ] is the assignment equal to f except that u takes the value l . • Satisfiability problem: input: formula φ in 1SL question: are there h and f such that h | = f φ ? • Each sentence (closed formula) defines a class of heaps. 6
Helpful macro: septraction • Septraction ¬ − ∗ : existential version of − ∗ . ¬ def − ∗ φ 2 = ¬ ( φ 1 − ∗ ¬ φ 2 ) φ 1 ¬ h | − ∗ φ 2 = f φ 1 iff there is h ′ ⊥ h such that h ′ | = f φ 1 and h ′ ⊎ h | = f φ 2 . 7
Simple properties stated in 1SL • The value of u is in the domain of the heap: def alloc ( u ) = ∃ u u ֒ → u (variant of ( u ֒ → u ) − ∗ ⊥ ) • The heap has a unique cell u 1 �→ u 2 : → u 2 ∧ ¬∃ u ′ ( u ′ � = u 1 ∧ alloc ( u ′ )) def u 1 �→ u 2 = u 1 ֒ def • The domain of the heap is empty: emp = ¬∃ u alloc ( u ) • u has at least k predecessors: k � � ∃ u 1 , . . . , u k u i � = u j ∧ → u u i ֒ i � = j i = 1 k times � �� � ( ∃ u ( u ֒ → u )) ∗ · · · ∗ ( ∃ u ( u ֒ → u )) • Formulae ♯ u ∼ k with k ∈ N . 8
Reachability predicate in 1SL2( ∗ ) • Non-empty path from u to u and nothing else except loops: reach ′ ( u , u ) def ♯ u = 0 ∧ alloc ( u ) ∧ ¬ alloc ( u ) ∧ = ∀ u (( alloc ( u ) ∧ ♯ u = 0 ) ⇒ u = u ) ∧ ∀ u (( ♯ u � = 0 ∧ u � = u ) ⇒ ( ♯ u = 1 ∧ alloc ( u ))) • There is a path from u to u : def = u = u ∨ ( ⊤ ∗ reach ′ ( u , u )) reach ( u , u ) 9
Finite binary trees • The heap is a forest of (possibly incomplete) binary trees: ∀ u ( ♯ u ≤ 2 ∧ ∃ u ( reach ( u , u ) ∧ ¬ alloc ( u ))) • The heap has a single tree: ∃ u ¬ alloc ( u ) ∧ ( ∀ u ( alloc ( u ) ⇒ reach ( u , u ))) 10
What is the expressive power of 1SL ? • Is there a sentence stating that there is l such that � ♯ l > 2 and � ♯ l is prime? • Is there a sentence stating that there are l 1 and l 2 such that � ♯ l 1 = � ♯ l 2 + 6 ? • Is there a sentence stating that there are l 1 , l 2 , l 3 such that � ♯ l 1 = � ♯ l 2 × � ♯ l 3 and � ♯ l 1 , � ♯ l 2 , � ♯ l 3 ≥ 1 ? 11
Expressive power / Decidability / Complexity 1SL ≡ DSOL ≡ WSOL ≡ 1SL( − ∗ ), undec. 1SL( ∗ ), dec., non-elem. 1SL2, undec. 1SL1 + PV, PSPACE -C 1SL2( − ∗ ) ≡ DSOL, undec. 1SL2( ∗ ), non-elem. 1SL0 + PV, PSPACE -C • [Calcagno & Yang & O’Hearn, APLAS’01] 1SL0 • [Brochenin & Demri & Lozes, IC 12] 1SL( − ∗ ) • [Demri & Galmiche & Larchey-Wendling & Mery, CSR’14] 1SL1 • [Demri & Deters, LICS’14] 1SL2( − ∗ ) 12
Weak second-order logic WSOL • Formulae: φ ::= u i = u j | u i ֒ → u j | φ ∧ φ | ¬ φ | ∃ u i φ | ∃ P φ | P ( u 1 , . . . , u n ) = V ∃ P φ iff there is a finite R ⊆ N n such that • h | h | = V [ P �→ R ] φ . • h | = V P ( u 1 , . . . , u n ) iff ( V ( u 1 ) , . . . , V ( u n )) ∈ V ( P ) . • DSOL: Dyadic fragment of WSOL. 13
How to express � ♯ f ( u 1 ) = � ♯ f ( u 2 ) × � ♯ f ( u 3 ) ∃ P 1 , P 2 , P 3 ( 3 � ( ( ∀ u ( u ֒ → u i ) ⇔ P i ( u ))) ∧ i = 1 ( ∃ Q ( ∀ u , u ( Q ( u , u ) ⇔ ( P 2 ( u ) ∧ P 3 ( u ))) ∧ ( ∃ Q ′ (( ∀ u 1 P 1 ( u 1 ) ⇒ ( ∃ u 2 , u 3 Q ′ ( u 1 , u 2 , u 3 ) ∧ Q ( u 2 , u 3 ))) ∧ ( ∀ u 1 , u 2 , u 3 Q ′ ( u 1 , u 2 , u 3 ) ⇒ ( P 1 ( u 1 ) ∧ Q ( u 2 , u 3 ))) ∧ ( ∀ u 1 , . . . , u 5 ( Q ′ ( u 1 , u 2 , u 3 ) ∧ Q ′ ( u 1 , u 4 , u 5 ) ⇒ (( u 4 = u 2 ) ∧ ( u 5 = u 3 ))) ∧ ( Q ′ ( u 1 , u 2 , u 3 ) ∧ Q ′ ( u 4 , u 2 , u 3 ) ⇒ u 4 = u 1 ) ∧ ( Q ( u 2 , u 3 ) ⇒ ∃ u 6 Q ′ ( u 6 , u 2 , u 3 )))))))) 14
From 1SL to DSOL (internalization of 1SL semantics) = ∀ u , u ′ , u ′′ ( P ( u , u ′ ) ∧ P ( u , u ′′ )) ⇒ u ′ = u ′′ def hp ( P ) = ∀ u , u ′ ( P ( u , u ′ ) ⇔ ( Q ( u , u ′ ) ∨ R ( u , u ′ )) ∧ ¬ ( Q ( u , u ′ ) ∧ R ( u , u ′ )) def P = Q ∗ R • Translation ∃ P ( ∀ u , u ′ P ( u , u ′ ) ⇔ u ֒ → u ′ ) ∧ t P ( φ ) : def → u ′ ) P ( u , u ′ ) t P ( u ֒ = ∃ Q , Q ′ P = Q ∗ Q ′ ∧ t Q ( ψ ) ∧ t Q ′ ( ϕ ) def t P ( ψ ∗ ϕ ) = ∀ Q (( ∃ Q ′ hp ( Q ′ ) ∧ Q ′ = Q ∗ P ) ∧ hp ( Q ) ∧ t Q ( ψ )) def t P ( ψ − ∗ ϕ ) = ⇒ ( ∃ Q ′ hp ( Q ′ ) ∧ Q ′ = Q ∗ P ∧ t Q ′ ( ϕ )) 15
From WSOL to DSOL • For every sentence φ in WSOL, there is a sentence φ ′ in DSOL (computable in logspace) such that for all heaps h , = φ ′ . h | = φ iff h | • P ( u ) �→ P new ( u , u ) . • P ( u 1 , . . . , u n ) �→ ∃ u � n i = 1 P new ( u , u i ) . i • So, it remains to show how to encode DSOL into 1SL2( − ∗ ). 16
Structure of the proof DSOL into 1SL( − ∗ ) Principles from [Brochenin & Demri & Lozes, IC 12] (1) To express ♯ u i + k ∼ ♯ u j + k ′ in 1SL( − ∗ ). (2) To encode the second-order valuation as a disjoint subheap by using arithmetical constraints to identify patterns. 17
Structure of the proof DSOL into 1SL( − ∗ ) Principles from [Brochenin & Demri & Lozes, IC 12] (1) To express ♯ u i + k ∼ ♯ u j + k ′ in 1SL( − ∗ ). (2) To encode the second-order valuation as a disjoint subheap by using arithmetical constraints to identify patterns. – Both steps require an unbounded amount of variables. – Even easy steps such as expressing ♯ u ≥ k become problematic with only two variables and no separating conjunction. k times k � �� � � � ∃ u 1 , . . . , u k u i � = u j ∧ → u or ( ∃ u ( u ֒ → u )) ∗ · · · ∗ ( ∃ u ( u ֒ → u )) u i ֒ i � = j i = 1 17
Structure of the proof DSOL into 1SL( − ∗ ) Principles from [Brochenin & Demri & Lozes, IC 12] (1) To express ♯ u i + k ∼ ♯ u j + k ′ in 1SL( − ∗ ). (2) To encode the second-order valuation as a disjoint subheap by using arithmetical constraints to identify patterns. – Both steps require an unbounded amount of variables. – Even easy steps such as expressing ♯ u ≥ k become problematic with only two variables and no separating conjunction. k times k � �� � � � ∃ u 1 , . . . , u k u i � = u j ∧ → u or ( ∃ u ( u ֒ → u )) ∗ · · · ∗ ( ∃ u ( u ֒ → u )) u i ֒ i � = j i = 1 – Even more embarassing: how to express ♯ u = 1 in 1SL2( − ∗ )? 17
Structure of the proof DSOL into 1SL2( − ∗ ) • Step I: To express ♯ u ≥ k in 1SL2( − ∗ ). • Step II: To express ♯ u + k ∼ ♯ u + k ′ in 1SL2( − ∗ ). • Step III: To encode the second-order valuation as a disjoint subheap by using arithmetical constraints to identify new patterns and to use only two variables. 18
A principle behing Step I Instead of chopping the heap in k disjoint subheaps, we add O ( k ) new patterns so that the combined heap satisfies properties witnessing k patterns in the original heap. 19
Formula for ♯ u = 1 def • ♯ u ≥ 1 = ∃ u ( u ֒ → u ) . def • ♯ u ≥ 2 = ∃ u 1 , u 2 ( u 1 � = u 2 ) ∧ ( u 1 ֒ → u ) ∧ ( u 2 ֒ → u ) . (easy with three variables) def • ♯ u ≥ 2 = ( ∃ u ( u ֒ → u )) ∗ ( ∃ u ( u ֒ → u )) (easy with separating conjunction) 20
Formula for ♯ u = 1 def • ♯ u ≥ 1 = ∃ u ( u ֒ → u ) . def • ♯ u ≥ 2 = ∃ u 1 , u 2 ( u 1 � = u 2 ) ∧ ( u 1 ֒ → u ) ∧ ( u 2 ֒ → u ) . (easy with three variables) def • ♯ u ≥ 2 = ( ∃ u ( u ֒ → u )) ∗ ( ∃ u ( u ֒ → u )) (easy with separating conjunction) • When the forks enter into the play. fork endpoints forky 20
Recommend
More recommend