IDP2ASP

Ingmar Dasseville

20/03/2018

Full Language

Desugaring

Core

ASP

Type Check

Translation

Optimiser

- Push Negations

- Topological let-reordering

- Inliner

-Beta Reduction

Core

Basic Lambda Calculus:

  • Variables (x)
  • Application (f x)
  • Lambda (\x -> x)
  • Let (let x := 2 in x +8)

Values:

  • Injected values (8)
  • Builtins (or)
  • Herbrand Constructors (S(S(Nil)))
  • Set Expression ( {x || x <- set} )

Deconstructing values:

  • Case (case x of (a,b) -> a + b)

Full Language

Desugaring

Core

! dom (\x -> p x | q x)

Desugaring

Ap(
        Ap(Builtin(Forall),

                 Var(dom)),

                  Lambda(x, Ap(

                                         Ap(Builtin(Or), Ap(Var(p),Var(x)),

                                                                   Ap(Var(q),Var(x))

                                         )    

 ) 

Core

Type Check

Vanilla Hindley-Milner (unfinished for constructors)

\x -> x+1

Int -> Int

  • Primitive Type (Set, Int)
  • Type Variable (a)
  • Type Application (Set String)
  • Implicit Universal Quantification (forall a b: (a,b) -> a)

\x -> x

a -> a

\x -> 1 x

Type Error

Core

Optimiser

Inline Let

let f x := 1 in f c + 5

(\x -> 1) c + 5

Beta Reduction

1 + 5

Math simplification

(not implemented yet)

6

Core

ASP

Translation

ASPTerm  (X)

+ Safety:  ({p(X), q(Y)})

Expression

Extra properties in helper predicates:

bool(t,()) boolean t is true
member(t,2) 2 is a member of set t
lamDom(t,5) 5 is in the relevant domain of function t
lamInter(t,4,6) the function t maps 4 to 6
result(t) t is the top symbol of the theory
member((s0,()),1..5).
{member((s1,()),X0):member((s0,()),X0)}==1.
bool((b0,()),()):-(X1+1)=3,member((s1,()),X1).
result((b0,())).
:-not bool(X,()),result(X).
c :: element of {1..5}. 
c + 1 = 3.

Translation

Desugaring

{1..5} (s0,()) {}
c X0 {member((s1,()),X0}
c+1 X0+1 {member((s1,()),X0}
c+1=3 (b0,()) {}

Full Language

Desugaring

Core

ASP

Type Check

Translation

Optimiser

- Push Negations

- Topological let-reordering

- Inliner

-Beta Reduction

Made with Slides.com