SMT-LIB 3: Bringing higher-order logic to SMT Clark Barrett Pascal - - PowerPoint PPT Presentation

smt lib 3 bringing higher order logic to smt
SMART_READER_LITE
LIVE PREVIEW

SMT-LIB 3: Bringing higher-order logic to SMT Clark Barrett Pascal - - PowerPoint PPT Presentation

SMT-LIB 3: Bringing higher-order logic to SMT Clark Barrett Pascal Fontaine Cesare Tinelli Stanford University, USA The University of Iowa, USA Universit e de Lorraine, CNRS, Inria, LORIA, France 1/22 Disclaimer Many things here are


slide-1
SLIDE 1

1/22

SMT-LIB 3: Bringing higher-order logic to SMT

Clark Barrett Pascal Fontaine Cesare Tinelli

Stanford University, USA The University of Iowa, USA Universit´ e de Lorraine, CNRS, Inria, LORIA, France

slide-2
SLIDE 2

2/22

Disclaimer

Many things here

◮ are early work in progress ◮ are inconsistent with each other ◮ need to be concretely applied to reveal flaws ◮ have not been properly discussed with the SMT community ◮ will evolve

slide-3
SLIDE 3

3/22

Credits

Based on inputs from Nikolaj Bjørner, Jasmin Blanchette, Koen Claessen, Tobias Nipkow, . . . , [your name here!]

slide-4
SLIDE 4

4/22

SMT-LIB 2 Standard

◮ Widely adopted I/O language for SMT solvers

slide-5
SLIDE 5

4/22

SMT-LIB 2 Standard

◮ Widely adopted I/O language for SMT solvers ◮ around 300,000 benchmarks

slide-6
SLIDE 6

4/22

SMT-LIB 2 Standard

◮ Widely adopted I/O language for SMT solvers ◮ around 300,000 benchmarks ◮ Command language

◮ Stack-based, tell-and-ask execution model ◮ Benchmarks are command scripts ◮ Same online and offline behavior

slide-7
SLIDE 7

4/22

SMT-LIB 2 Standard

◮ Widely adopted I/O language for SMT solvers ◮ around 300,000 benchmarks ◮ Command language

◮ Stack-based, tell-and-ask execution model ◮ Benchmarks are command scripts ◮ Same online and offline behavior

◮ Simple syntax

◮ Sublanguage of Common Lisp S-expressions ◮ Easy to parse ◮ Few syntactic categories

slide-8
SLIDE 8

4/22

SMT-LIB 2 Standard

◮ Widely adopted I/O language for SMT solvers ◮ around 300,000 benchmarks ◮ Command language

◮ Stack-based, tell-and-ask execution model ◮ Benchmarks are command scripts ◮ Same online and offline behavior

◮ Simple syntax

◮ Sublanguage of Common Lisp S-expressions ◮ Easy to parse ◮ Few syntactic categories

◮ Powerful underlying logic

◮ Many sorted FOL with (pseudo-)parametric types ◮ Schematic theory declarations ◮ Semantic definition of theories

slide-9
SLIDE 9

5/22

SMT-LIB 2 Concrete Syntax

Strict subset of Common Lisp S-expressions: spec constant ::= numeral | decimal | hexadecimal | binary | string s expr ::= spec constant | symbol | ( s expr∗ )

slide-10
SLIDE 10

6/22

Example: Concrete Syntax

( declare−datatype L i s t ( par (X) ( ( n i l ) ( cons ( head X) ( t a i l ( L i s t X) ) ) ) ) ) ( declare−fun append (( L i s t I n t ) ( L i s t I n t ) ( L i s t I n t ) ) ) ( declare−const a I n t ) ( a s s e r t ( f o r a l l (( x ( L i s t I n t )) ( y ( L i s t I n t ) ) ) (= ( append x y ) ( i t e (= x ( as n i l ( L i s t I n t ) ) ) y ( l e t (( h ( head x )) ( t ( t a i l x ) ) ) ( cons h ( append t y )) ) ) ) ) ) ( a s s e r t (= ( append ( cons a ( as n i l ( L i s t I n t ) ) ) ( append ( cons 2 ( as n i l ( L i s t I n t ) ) ) n i l ) ) ) ( check−sat )

slide-11
SLIDE 11

7/22

Example: TIP vs. SMT-LIB

( declare−datatypes () (( Nat ( Zero ) ( Succ ( pred Nat ) ) ) ) ) ( define−fun−rec p l u s (( x Nat ) ( y Nat )) Nat ( match x ( case Zero y ) ( case ( Succ n ) ( Succ ( p l u s n y ) ) ) ) ) ( assert−not ( f o r a l l (( n Nat ) (m Nat )) (= ( p l u s n m) ( p l u s m n ) ) ) ) ( check−sat )

slide-12
SLIDE 12

8/22

Example: TIP vs. SMT-LIB

( declare−datatype Nat (( Zero ) ( Succ ( Pred Nat ) ) ) ) ( define−fun−rec p l u s (( x Nat ) ( y Nat )) Nat ( match x ( Zero y ) (( Succ n ) ( Succ ( p l u s n y ) ) ) ) ) ( a s s e r t ( not ( f o r a l l (( n Nat ) (m Nat )) (= ( p l u s n m) ( p l u s m n ) ) ) ) ) ( check−sat )

slide-13
SLIDE 13

9/22

SMT-LIB vs. TIP

Many TIP features have been integrated into the SMT-LIB

◮ declare-datatypes: similar semantics, simplified syntax ◮ match (Section 3.5.1)

◮ No case keyword ◮ No default keyword: use variable (usable inside term)

◮ define-fun-rec was already in SMT-LIB 2.5 (Section 4.2.3) ◮ assert-not: Tagging a goal can be done with :named annotation ◮ par: parametric functions are not yet supported

TIP

This document does not yet cover mutual recursion (over data types or

  • ver functions), or partial branches and partiality.

◮ SMT-LIB does cover mutual recursion, over functions and

data-types: define-funs-rec and declare-datatypes

◮ partiality is not covered

slide-14
SLIDE 14

10/22

From Many-sorted FOL to HOL

Motivation:

◮ Several hammers for ITP systems use SMT solvers ◮ New communities are extending SMT-LIB with HOL features

(for synthesis, inductive reasoning, symbolic computation, . . . ) Goals:

◮ Serve these new users and other non-traditional users ◮ Maintain backward compatibility as much as possible

slide-15
SLIDE 15

11/22

From Many-sorted FOL to HOL

Plan:

◮ Adopt (Gordon’s) HOL with parametric types, rank-1

polymorphism, and extensional equality

◮ Extend syntax by introducing → type, λ and ε binders ◮ Make all function symbols Curried ◮ Enable higher-order quantification ◮ Keep SMT-LIB 2 constructs/notions but define them

in terms of HOL

slide-16
SLIDE 16

12/22

SMT-LIB 3: Basic Concrete Syntax for Sorts (Types)

indentifier ::= symbol | ( symbol label+ ) σ sort ::= identifier | ( -> sort+ sort ) | ( identifier sort+ ) τ par sort ::= sort | ( par ( symbol+ ) sort )

  • > predefined right-associative type constructor
slide-17
SLIDE 17

13/22

SMT-LIB 3: Basic Concrete Syntax for Terms

sorted var ::= ( symbol sort ) term ::= spec constant | identifier | ( term term ) | ( lambda ( sorted var ) term ) | ( choose ( sorted var ) term ) | ( ! term attribute+ )

slide-18
SLIDE 18

14/22

SMT-LIB 3: Extended Concrete Syntax for Terms

◮ (t1 t2 t3 · · · tn) := ((t1 t2) t3 · · · tn)

slide-19
SLIDE 19

14/22

SMT-LIB 3: Extended Concrete Syntax for Terms

◮ (t1 t2 t3 · · · tn) := ((t1 t2) t3 · · · tn) ◮ (lambda ((x σ) (x1 σ1) · · · (xn σn)) ϕ) :=

(lambda ((x σ)) (lambda ((y1 σ1) · · · (yn σn)) ϕ[yi/xi])) with yi fresh

slide-20
SLIDE 20

14/22

SMT-LIB 3: Extended Concrete Syntax for Terms

◮ (t1 t2 t3 · · · tn) := ((t1 t2) t3 · · · tn) ◮ (lambda ((x σ) (x1 σ1) · · · (xn σn)) ϕ) :=

(lambda ((x σ)) (lambda ((y1 σ1) · · · (yn σn)) ϕ[yi/xi])) with yi fresh

◮ (let ((x1 t1) · · · (xn tn)) t) :=

((lambda ((x1 σ1) · · · (xn σn)) t) t1 · · · tn) where σi is the sort of ti

slide-21
SLIDE 21

14/22

SMT-LIB 3: Extended Concrete Syntax for Terms

◮ (t1 t2 t3 · · · tn) := ((t1 t2) t3 · · · tn) ◮ (lambda ((x σ) (x1 σ1) · · · (xn σn)) ϕ) :=

(lambda ((x σ)) (lambda ((y1 σ1) · · · (yn σn)) ϕ[yi/xi])) with yi fresh

◮ (let ((x1 t1) · · · (xn tn)) t) :=

((lambda ((x1 σ1) · · · (xn σn)) t) t1 · · · tn) where σi is the sort of ti

◮ (forall ((x σ)) ϕ) :=

(= (lambda ((x σ)) ϕ) (lambda ((x σ)) true)) (forall ((x1 σ1) (x2 σ2) · · · (xn σn)) ϕ) := (forall ((x1 σ1)) (forall ((x2 σ2) · · · (xn σn)) ϕ))

slide-22
SLIDE 22

14/22

SMT-LIB 3: Extended Concrete Syntax for Terms

◮ (t1 t2 t3 · · · tn) := ((t1 t2) t3 · · · tn) ◮ (lambda ((x σ) (x1 σ1) · · · (xn σn)) ϕ) :=

(lambda ((x σ)) (lambda ((y1 σ1) · · · (yn σn)) ϕ[yi/xi])) with yi fresh

◮ (let ((x1 t1) · · · (xn tn)) t) :=

((lambda ((x1 σ1) · · · (xn σn)) t) t1 · · · tn) where σi is the sort of ti

◮ (forall ((x σ)) ϕ) :=

(= (lambda ((x σ)) ϕ) (lambda ((x σ)) true)) (forall ((x1 σ1) (x2 σ2) · · · (xn σn)) ϕ) := (forall ((x1 σ1)) (forall ((x2 σ2) · · · (xn σn)) ϕ))

◮ (choose ((x1 σ1) · · · (xn σn)) ϕ) := . . .

slide-23
SLIDE 23

14/22

SMT-LIB 3: Extended Concrete Syntax for Terms

◮ (t1 t2 t3 · · · tn) := ((t1 t2) t3 · · · tn) ◮ (lambda ((x σ) (x1 σ1) · · · (xn σn)) ϕ) :=

(lambda ((x σ)) (lambda ((y1 σ1) · · · (yn σn)) ϕ[yi/xi])) with yi fresh

◮ (let ((x1 t1) · · · (xn tn)) t) :=

((lambda ((x1 σ1) · · · (xn σn)) t) t1 · · · tn) where σi is the sort of ti

◮ (forall ((x σ)) ϕ) :=

(= (lambda ((x σ)) ϕ) (lambda ((x σ)) true)) (forall ((x1 σ1) (x2 σ2) · · · (xn σn)) ϕ) := (forall ((x1 σ1)) (forall ((x2 σ2) · · · (xn σn)) ϕ))

◮ (choose ((x1 σ1) · · · (xn σn)) ϕ) := . . . ◮ (exists ((x1 σ1) · · · (xn σn)) ϕ) := . . .

slide-24
SLIDE 24

15/22

SMT-LIB 3: Commands

◮ As in SMT-LIB 2 ◮ Fed to the solver’s standard input channel or stored in a file ◮ Look like Lisp function calls: ( comm name arg∗ ) ◮ Operate on an stack of assertion sets ◮ Cause solver to outputs an S-expression to the standard

  • utput/error channel

◮ Four categories:

◮ assertion-set commands, modify the assertion set stack ◮ post-check commands, query about the assertion sets ◮ option commands, set solver parameters ◮ diagnostic commands, get solver diagnostics

slide-25
SLIDE 25

16/22

SMT-LIB 3: Assertion-Set Commands

(declare-sort s n)

Example: (declare-sort Elem 0) (declare-sort Set 1) Effect: declares sort symbol s with arity n

(define-sort s (u1 · · · un) σ)

Example: (define-sort MyArray (u) (Array Int u)) Effect: enables the use of (MyArray Real) as a shorthand for (Array Int Real)

slide-26
SLIDE 26

17/22

SMT-LIB 3: Assertion-Set Commands

(declare-const f τ)

Example: (declare-const a (Array Int Real)) (declare-const g (-> Int Int Int)) (declare-const len (par (X) (-> (List X) Int))) Effect: declares f with type τ

(declare-fun f (σ1 · · · σn) σ)

Example: (declare-fun a () (Array Int Real)) (declare-fun g (Int Int) Int) Effect: same as (declare-const f (-> σ1 · · · σn σ))

(declare-fun f (par (u1 · · · un) (σ1 · · · σn) σ))

Example: (declare-fun len (par (X) ((List X)) Int)) Effect: same as (declare-const f (par (u1 · · · un) (-> σ1 · · · σn σ)))

slide-27
SLIDE 27

18/22

SMT-LIB 3: Assertion-Set Commands

(set-logic s) deprecated!

slide-28
SLIDE 28

19/22

SMT-LIB 3: set-logic replacements

(import-sorts T [(σ1 · · · σn)])

Example: (import-sort Arrays) (import-sort Reals Int (Real Int)) (import-sort Arrays ((par (X) (Array Int X)))) Effect: Import all instances of sorts [σ1 · · · σn] in theory T

(deport-sorts T (σ1 · · · σn))

Example: (deport-sort Reals Int (Real)) (deport-sort Arrays ((par (X Y) (Array Int (Array X Y))))) Effect: Remove for imported sort set all instances of sorts σ1 · · · σn in theory T

slide-29
SLIDE 29

20/22

SMT-LIB 3: set-logic replacements

(import-funs T [(f1 · · · fn)])

Example: (import-funs Arrays) (import-funs Reals Int (- NUMERALS (+ Int Int Int))) (import-funs Arrays ((par (X) (store Int (Array Int X) X)))) Effect: Import all instances of function symbols f1 · · · fn in theory T over imported sorts

(deport-funs T (f1 · · · fn))

Example: (deport-fun Reals Int (/ div mod *)) (deport-fun Arrays (store)) Effect: disable all instances of function symbols f1 · · · fn in theory T over imported sorts

slide-30
SLIDE 30

21/22

SMT-LIB 3: set-logic replacements

(enable (l1 · · · ln))

Example: (enable (order-1 user-declarations datatypes)) (enable (order-1 closures quantifiers)) (enable (order-2 quantifiers)) Effect: enable the listed syntactic features

(disable (l1 · · · ln))

Example: (disable (closures choice)) (disable (recursive-definitions quantifiers)))) Effect: disable the listed syntactic features

slide-31
SLIDE 31

22/22

Conclusion

◮ Most TIP features are or will be included in SMT-LIB ◮ A more modular presentation of the format (extensions) ◮ Better handling of combination of theories ◮ What next?