extracting nested relational queries from implicit
play

Extracting nested relational queries from implicit definitions - PowerPoint PPT Presentation

Extracting nested relational queries from implicit definitions Pierre Pradic (j.w.w. Michael Benedikt) University of Oxford December 4 th , 2020 1 / 1 Plan of the talk The nested relational calculus (NRC) Implicit definability, implicit


  1. Extracting nested relational queries from implicit definitions Pierre Pradic (j.w.w. Michael Benedikt) University of Oxford December 4 th , 2020 1 / 1

  2. Plan of the talk ◮ The nested relational calculus (NRC) ◮ Implicit definability, implicit → explicit for the flat case ◮ Our contribution: implicit → explicit for NRC 2 / 1

  3. Outline 3 / 1

  4. The nested relational calculus (NRC) Syntax Types: T , U ::= U | Set ( T ) | 1 | T × U Terms: Q , R ::= x | ∅ | Q ∪ R | Q \ R | { Q } | � { Q | x ∈ R } | � Q , . . . , R � | π i every variable x carries a type T Terms represent nested queries of some given type T → U ◮ Cartesian structure π i , � . . . � ◮ Monad structure on Set {−} , � ◮ Idempotent monoid Set ( T ) ∅ , ∪ ◮ Set difference Q \ R Generalizes flat relational queries with higher-order types ∼ Set ( U i 1 ) × . . . × Set ( U ik ) → Set ( U m ) flat = 4 / 1

  5. Examples A flat query The fiber of a relation f at some point x fib : U × Set ( U × U ) → Set ( U ) f − 1 ( x ) �→ ( x , f ) ◮ “concrete instance”: U contains names, f =“is the parent of” ◮ can be written as ( x , f ) �→ � { case ( π 2 ( p ) = U x , { π 1 ( p ) } , ∅ ) | p ∈ f } syntactic sugar: case , = U 5 / 1

  6. Examples A flat query The fiber of a relation f at some point x fib : U × Set ( U × U ) → Set ( U ) f − 1 ( x ) �→ ( x , f ) ◮ “concrete instance”: U contains names, f =“is the parent of” ◮ can be written as ( x , f ) �→ � { case ( π 2 ( p ) = U x , { π 1 ( p ) } , ∅ ) | p ∈ f } syntactic sugar: case , = U A genuine nested query Collect all fibers of f fibs : Set ( U × U ) → Set ( U × Set ( U )) { ( a , f − 1 ( a )) | a ∈ cod ( f ) } f �→ ◮ can be written as f �→ � {{ fib ( x , f ) } | x ∈ { π 1 ( p ) | p ∈ f }} 5 / 1

  7. Expressiveness of NRC From now on, set Bool := Set ( 1 ) . Derivable constructs: ◮ maps { Q ( x ) | x ∈ R } ◮ set intersection Q ∩ R ◮ case analyses if the output is some Set ( T ) ◮ basic predicates = T : T × T → Bool, ∈ T : T × Set ( T ) → Bool 6 / 1

  8. Expressiveness of NRC From now on, set Bool := Set ( 1 ) . Derivable constructs: ◮ maps { Q ( x ) | x ∈ R } ◮ set intersection Q ∩ R ◮ case analyses if the output is some Set ( T ) ◮ basic predicates = T : T × T → Bool, ∈ T : T × Set ( T ) → Bool Proposition NRC queries Q ( x T ) : T → Bool correspond exactly to ∆ 0 formulas ϕ ( x T ) . 6 / 1

  9. Expressiveness of NRC From now on, set Bool := Set ( 1 ) . Derivable constructs: ◮ maps { Q ( x ) | x ∈ R } ◮ set intersection Q ∩ R ◮ case analyses if the output is some Set ( T ) ◮ basic predicates = T : T × T → Bool, ∈ T : T × Set ( T ) → Bool Proposition NRC queries Q ( x T ) : T → Bool correspond exactly to ∆ 0 formulas ϕ ( x T ) . � ∆ 0 -separation is encodable in NRC { x ∈ Q | ϕ ( x ) } 6 / 1

  10. Limits to the expressiveness of NRC For practical purposes, NRC is not be too expressive ◮ NRC is conservative over idealized SQL i.e., for flat queries ◮ for finite inputs, the output has polynomial size Consequences ◮ rules out x �→ P ( x ) ◮ rules out curryfication! Consider ( x , y ) �→ tt [ T → Set ( U )] �≃ [ T × U → Bool ] [ T → Set ( U )] ֒ → [ T × U → Bool ] (For the rest of the talk: no finiteness assumptions) 7 / 1

  11. Outline 8 / 1

  12. Implicit definitions Implicit definability ϕ ( i , o ) is a functional definition of o in terms of i if ϕ ( i , o ) ∧ ϕ ( i , o ′ ) o = o ′ ⇒ Defines a partial function I → O 9 / 1

  13. Implicit definitions Implicit definability ϕ ( i , o ) is a functional definition of o in terms of i if ϕ ( i , o ) ∧ ϕ ( i , o ′ ) o = o ′ ⇒ Defines a partial function I → O Main theorem Expressible in NRC ⇐ ⇒ Has an implicit definition ◮ We call a NRC term an explicit definition ◮ Partial implicit definitions → compatible total explicit definitions ◮ (Orthogonal to C-H approaches, where totality proofs are used) ⇒ : easy to map a NRC expression to an implicit definition 9 / 1

  14. Use-case for implicit → explicit Main theorem Expressible in NRC ⇐ ⇒ Has an implicit definition Implicit definitions might arguably be more convenient for users at times. 10 / 1

  15. Use-case for implicit → explicit Main theorem Expressible in NRC ⇐ ⇒ Has an implicit definition Implicit definitions might arguably be more convenient for users at times. Use-case: inverting a query Consider an injective NRC query such as fibs Set ( U × U ) → Set ( U × Set ( U )) fibs : { ( a , f − 1 ( a )) | a ∈ cod ( f ) } �→ f 10 / 1

  16. Use-case for implicit → explicit Main theorem Expressible in NRC ⇐ ⇒ Has an implicit definition Implicit definitions might arguably be more convenient for users at times. Use-case: inverting a query Consider an injective NRC query such as fibs Set ( U × U ) → Set ( U × Set ( U )) fibs : { ( a , f − 1 ( a )) | a ∈ cod ( f ) } �→ f ◮ can be converted to an implicit ϕ ( f , F ) 10 / 1

  17. Use-case for implicit → explicit Main theorem Expressible in NRC ⇐ ⇒ Has an implicit definition Implicit definitions might arguably be more convenient for users at times. Use-case: inverting a query Consider an injective NRC query such as fibs Set ( U × U ) → Set ( U × Set ( U )) fibs : { ( a , f − 1 ( a )) | a ∈ cod ( f ) } �→ f ◮ can be converted to an implicit ϕ ( f , F ) ◮ ϕ ( f , F ) defines a partial function F �→ f 10 / 1

  18. Use-case for implicit → explicit Main theorem Expressible in NRC ⇐ ⇒ Has an implicit definition Implicit definitions might arguably be more convenient for users at times. Use-case: inverting a query Consider an injective NRC query such as fibs Set ( U × U ) → Set ( U × Set ( U )) fibs : { ( a , f − 1 ( a )) | a ∈ cod ( f ) } �→ f ◮ can be converted to an implicit ϕ ( f , F ) ◮ ϕ ( f , F ) defines a partial function F �→ f � a NRC-definable retract of fibs 10 / 1

  19. Interpolation The result was already known for the flat case. Beth definability Let ϕ ( R ) be a first-order formula. If ϕ ( R ) ∧ ϕ ( R ′ ) ⇒ R ≡ R ′ , then there is a FO ψ ( � x ) such that ϕ ( ψ ) . i.e., R first-order definable 11 / 1

  20. Interpolation The result was already known for the flat case. Beth definability Let ϕ ( R ) be a first-order formula. If ϕ ( R ) ∧ ϕ ( R ′ ) ⇒ R ≡ R ′ , then there is a FO ψ ( � x ) such that ϕ ( ψ ) . i.e., R first-order definable ◮ Model-theoretic proof using amalgamation 11 / 1

  21. Interpolation The result was already known for the flat case. Beth definability Let ϕ ( R ) be a first-order formula. If ϕ ( R ) ∧ ϕ ( R ′ ) ⇒ R ≡ R ′ , then there is a FO ψ ( � x ) such that ϕ ( ψ ) . i.e., R first-order definable ◮ Model-theoretic proof using amalgamation ◮ Proof-theoretic effective proof using interpolation 11 / 1

  22. Interpolation The result was already known for the flat case. Beth definability Let ϕ ( R ) be a first-order formula. If ϕ ( R ) ∧ ϕ ( R ′ ) ⇒ R ≡ R ′ , then there is a FO ψ ( � x ) such that ϕ ( ψ ) . i.e., R first-order definable ◮ Model-theoretic proof using amalgamation ◮ Proof-theoretic effective proof using interpolation ϕ ( C, L ) ψ ( C, R ) Craig interpolation ∃ If ϕ ⇒ ψ , there exists θ such that θ ( C ) ϕ ⇒ θ and θ ⇒ ψ and Vocabulary ( θ ) ⊆ Vocabulary ( ϕ ) ∩ Vocabulary ( ψ ) L C R 11 / 1

  23. Interpolation The result was already known for the flat case. Beth definability Let ϕ ( R ) be a first-order formula. If ϕ ( R ) ∧ ϕ ( R ′ ) ⇒ R ≡ R ′ , then there is a FO ψ ( � x ) such that ϕ ( ψ ) . i.e., R first-order definable ◮ Model-theoretic proof using amalgamation ◮ Proof-theoretic effective proof using interpolation ϕ ( C, L ) ψ ( C, R ) Craig interpolation ∃ If ϕ ⇒ ψ , there exists θ such that θ ( C ) ϕ ⇒ θ and θ ⇒ ψ and Vocabulary ( θ ) ⊆ Vocabulary ( ϕ ) ∩ Vocabulary ( ψ ) ◮ θ linear-time computable from a cut-free derivation ◮ Rather robust result L C R ∆ 0 -interpolation, intuitionistic/linear logic. . . 11 / 1

  24. Proof idea for the flat case Fix an implicit definition ϕ ( I , O ) with I : Set ( U k ) and O : Set ( U m ) . Effective proof sketch 12 / 1

  25. Proof idea for the flat case Fix an implicit definition ϕ ( I , O ) with I : Set ( U k ) and O : Set ( U m ) . Effective proof sketch 1. Apply interpolation to ϕ ( I , O ′ ) ⇒ O ′ ( � ϕ ( I , O ) ∧ O ( � x ) ⊢ x ) to obtain an explicit ∆ 0 definition θ ( I , � x ) . 12 / 1

  26. Proof idea for the flat case Fix an implicit definition ϕ ( I , O ) with I : Set ( U k ) and O : Set ( U m ) . Effective proof sketch 1. Apply interpolation to ϕ ( I , O ′ ) ⇒ O ′ ( � ϕ ( I , O ) ∧ O ( � x ) ⊢ x ) to obtain an explicit ∆ 0 definition θ ( I , � x ) . 2. There is a NRC term M : Set ( U k ) → Set ( U m ) maximal for ⊆ 12 / 1

  27. Proof idea for the flat case Fix an implicit definition ϕ ( I , O ) with I : Set ( U k ) and O : Set ( U m ) . Effective proof sketch 1. Apply interpolation to ϕ ( I , O ′ ) ⇒ O ′ ( � ϕ ( I , O ) ∧ O ( � x ) ⊢ x ) to obtain an explicit ∆ 0 definition θ ( I , � x ) . 2. There is a NRC term M : Set ( U k ) → Set ( U m ) maximal for ⊆ x ) ⇔ θ M ( I , � Additionally, θ ( I , � x ) for any θ ∈ ∆ 0 . 12 / 1

Recommend


More recommend