Nominal Rewriting. Maribel Fernández. ISR - June King s College London

Size: px
Start display at page:

Download "Nominal Rewriting. Maribel Fernández. ISR - June King s College London"

Transcription

1 King s College London ISR - June 2009

2 - Course Syllabus Introduction First-order languages Languages with binding operators Specifying binders: α-equivalence Nominal terms Nominal unification (unification modulo α-equivalence) Nominal matching (matching modulo α-equivalence) Nominal rewriting Extending first-order rewriting Examples Properties Expressive Power

3 Further reading C. Urban, A. Pitts, M.J. Gabbay. Nominal Unification. Theoretical Computer Science, 323, pages , C. Calvès, M. Fernández. Nominal Matching and Alpha-Equivalence. Proceedings of WOLLIC 2008, Edinburgh. LNAI 5110, Springer, M. Fernández, M.J. Gabbay.. Information and Computation 205, pages , M. Fernández and M.J. Gabbay. Curry style types for nominal terms. Proceedings of TYPES 2006, Lecture Notes in Computer Science 4502, Springer, 2007.

4 First-order languages vs. languages with binders Most programming languages permit the specification of first-order data structures and first-order operators. Examples of first-order data structures: numbers, lists, trees, etc. Example of first-order operator on lists: append(nil, x) x append(cons(x, z), y) cons(x, append(z, y)) Very few programming or specification languages give programmers tools to specify data structures that include binding operators. However, in many situations, we need to manipulate data with bound names. Well-known examples can be found in software that deals with programs (e.g. in compilers, and in software used to analyse programs, type them, optimise them, etc).

5 Binding operators: Examples Some concrete examples of binding operators (informally): Operational semantics: let a = N in M (fun a.m)n

6 Binding operators: Examples Some concrete examples of binding operators (informally): Operational semantics: let a = N in M (fun a.m)n β and η-reductions in the λ-calculus: (λx.m)n M[x/N] (λx.mx) M (x fv(m))

7 Binding operators: Examples Some concrete examples of binding operators (informally): Operational semantics: let a = N in M (fun a.m)n β and η-reductions in the λ-calculus: π-calculus: (λx.m)n M[x/N] (λx.mx) M (x fv(m)) P νa.q νa.(p Q) (a fv(p))

8 Binding operators: Examples Some concrete examples of binding operators (informally): Operational semantics: let a = N in M (fun a.m)n β and η-reductions in the λ-calculus: π-calculus: (λx.m)n M[x/N] (λx.mx) M (x fv(m)) P νa.q νa.(p Q) (a fv(p)) Logic equivalences: P and ( x.q) x(p and Q) (x fv(p))

9 Binding operators - α-equivalence Binding operators are defined modulo renaming of bound variables, i.e., α-equivalence. Example: In x.p the variable x can be renamed. Take any fresh variable y, then x.p = α y.p{x y} Substitution of a bound name by a term has to avoid capture of other bound names. How can we formally define (or program) binding operators? There are several alternatives.

10 First-order frameworks We can encode α-equivalence in a first-order specification or programming language. We have a simple notion of substitution (first-order). (+)

11 First-order frameworks We can encode α-equivalence in a first-order specification or programming language. We have a simple notion of substitution (first-order). (+) Efficient matching and unification algorithms. (+)

12 First-order frameworks We can encode α-equivalence in a first-order specification or programming language. We have a simple notion of substitution (first-order). (+) Efficient matching and unification algorithms. (+) No binders. (-)

13 First-order frameworks We can encode α-equivalence in a first-order specification or programming language. We have a simple notion of substitution (first-order). (+) Efficient matching and unification algorithms. (+) No binders. (-) We need to implement α-equivalence and non-capturing substitution from scratch. (-)

14 First-order frameworks We can encode α-equivalence in a first-order specification or programming language. We have a simple notion of substitution (first-order). (+) Efficient matching and unification algorithms. (+) No binders. (-) We need to implement α-equivalence and non-capturing substitution from scratch. (-) For example, we can encode a system with binders such as the lambda-calculus using numbers to represent bound variables and operators such as lift and shift to encode non-capturing substitution (cf. De Bruijn s notation).

15 Higher-order frameworks Higher-order rewrite systems (CRS, HRS, etc.) include a general binding construct and terms are defined modulo α-equivalence. Example: β-rule One step of rewriting: app(lam([a]z(a)), Z ) Z(Z ) app(lam([a]f (a, g(a)), b) f (b, g(b)) using (a restriction of) higher-order matching.

16 Higher-order frameworks Higher-order rewrite systems (CRS, HRS, etc.) include a general binding construct and terms are defined modulo α-equivalence. Example: β-rule One step of rewriting: app(lam([a]z(a)), Z ) Z(Z ) app(lam([a]f (a, g(a)), b) f (b, g(b)) using (a restriction of) higher-order matching. Logical frameworks based on Higher-Order Abstract Syntax also work modulo α-equivalence. let a = N in M(a) (fun a M(a))N

17 Higher-order frameworks The syntax includes binders. (+)

18 Higher-order frameworks The syntax includes binders. (+) Implicit α-equivalence. (+)

19 Higher-order frameworks The syntax includes binders. (+) Implicit α-equivalence. (+) We targeted α but now we have to deal with β too. (-)

20 Higher-order frameworks The syntax includes binders. (+) Implicit α-equivalence. (+) We targeted α but now we have to deal with β too. (-) Substitution is a meta-operation using β. (-)

21 Higher-order frameworks The syntax includes binders. (+) Implicit α-equivalence. (+) We targeted α but now we have to deal with β too. (-) Substitution is a meta-operation using β. (-) Unification is undecidable in general. (-)

22 Higher-order frameworks The syntax includes binders. (+) Implicit α-equivalence. (+) We targeted α but now we have to deal with β too. (-) Substitution is a meta-operation using β. (-) Unification is undecidable in general. (-) Leaving name dependencies implicit is convenient, e.g. let a = N in M vs. let a = N in M(a) app(lambda[a]z, Z ) vs. app(lam([a]z(a)), Z ).

23 Nominal Approach Inspired by the work on Nominal Logic (Pitts et al.) Key ideas: Freshness conditions a#t, name swapping (a b) t. Example: β and η rules as NRS: app(lam([a]z), Z ) subst([a]z, Z ) a#m (λ([a]app(m, a)) M Terms with binders.

24 Nominal Approach Inspired by the work on Nominal Logic (Pitts et al.) Key ideas: Freshness conditions a#t, name swapping (a b) t. Example: β and η rules as NRS: app(lam([a]z), Z ) subst([a]z, Z ) a#m (λ([a]app(m, a)) M Terms with binders. Built-in α-equivalence.

25 Nominal Approach Inspired by the work on Nominal Logic (Pitts et al.) Key ideas: Freshness conditions a#t, name swapping (a b) t. Example: β and η rules as NRS: app(lam([a]z), Z ) subst([a]z, Z ) a#m (λ([a]app(m, a)) M Terms with binders. Built-in α-equivalence. Simple notion of substitution (first order).

26 Nominal Approach Inspired by the work on Nominal Logic (Pitts et al.) Key ideas: Freshness conditions a#t, name swapping (a b) t. Example: β and η rules as NRS: app(lam([a]z), Z ) subst([a]z, Z ) a#m (λ([a]app(m, a)) M Terms with binders. Built-in α-equivalence. Simple notion of substitution (first order). Efficient matching and unification algorithms.

27 Nominal Approach Inspired by the work on Nominal Logic (Pitts et al.) Key ideas: Freshness conditions a#t, name swapping (a b) t. Example: β and η rules as NRS: app(lam([a]z), Z ) subst([a]z, Z ) a#m (λ([a]app(m, a)) M Terms with binders. Built-in α-equivalence. Simple notion of substitution (first order). Efficient matching and unification algorithms. Dependencies of terms on names are implicit.

28 Nominal Approach Inspired by the work on Nominal Logic (Pitts et al.) Key ideas: Freshness conditions a#t, name swapping (a b) t. Example: β and η rules as NRS: app(lam([a]z), Z ) subst([a]z, Z ) a#m (λ([a]app(m, a)) M Terms with binders. Built-in α-equivalence. Simple notion of substitution (first order). Efficient matching and unification algorithms. Dependencies of terms on names are implicit. Easy to express conditions such as a fv(m)

29 Nominal Approach Inspired by the work on Nominal Logic (Pitts et al.) Key ideas: Freshness conditions a#t, name swapping (a b) t. Example: β and η rules as NRS: app(lam([a]z), Z ) subst([a]z, Z ) a#m (λ([a]app(m, a)) M Terms with binders. Built-in α-equivalence. Simple notion of substitution (first order). Efficient matching and unification algorithms. Dependencies of terms on names are implicit. Easy to express conditions such as a fv(m) Can be easily generalised to express more general constraints.

30 Nominal Syntax Function symbols: f, g... Variables: M, N, X, Y,... Atoms: a, b,... Swappings: (a b) Def. (a b)a = b, (a b)b = a, (a b)c = c Permutations: lists of swappings, denoted π (Id empty).

31 Nominal Syntax Function symbols: f, g... Variables: M, N, X, Y,... Atoms: a, b,... Swappings: (a b) Def. (a b)a = b, (a b)b = a, (a b)c = c Permutations: lists of swappings, denoted π (Id empty). Nominal Terms: s, t ::= a π X [a]t f t (t 1,..., t n ) Id X written as X.

32 Nominal Syntax Function symbols: f, g... Variables: M, N, X, Y,... Atoms: a, b,... Swappings: (a b) Def. (a b)a = b, (a b)b = a, (a b)c = c Permutations: lists of swappings, denoted π (Id empty). Nominal Terms: s, t ::= a π X [a]t f t (t 1,..., t n ) Id X written as X. Example (ML): var(a), app(t, t ), lam([a]t), let(t, [a]t ), letrec[f ]([a]t, t ), subst([a]t, t ) Syntactic sugar: a, (tt ), λa.t, let a = t in t, letrec fa = t in t, t[a t ]

33 α-equivalence We use freshness to avoid name capture. a#x means a fv(x ) when X is instantiated. where ds(π, π )#X a α a π X α π X s 1 α t 1 s n α t n s α t (s 1,..., s n ) α (t 1,..., t n ) fs α ft s α t a#t [a]s α [a]t s α (a b) t [a]s α [b]t ds(π, π ) = {n π(n) π (n)} a#x, b#x (a b) X α X

34 α-equivalence We use freshness to avoid name capture. a#x means a fv(x ) when X is instantiated. a α a ds(π, π )#X π X α π X where s 1 α t 1 s n α t n s α t (s 1,..., s n ) α (t 1,..., t n ) fs α ft s α t a#t [a]s α [a]t s α (a b) t [a]s α [b]t ds(π, π ) = {n π(n) π (n)} a#x, b#x (a b) X α X b#x λ[a]x α λ[b](a b) X

35 Freshness Also defined by induction: a#b a#[a]s π 1 (a)#x a#π X a#s 1 a#s n a#(s 1,..., s n ) a#s a#fs a#s a#[b]s

36 Nominal rewriting is rewriting with nominal terms. Rewrite rules can be used to define equational theories, and theorem provers; algebraic specifications of operators and data structures; operational semantics of programs; a theory of functions; a theory of processes; etc. Nominal terms can naturally express binding operators, and have been used as a basis for the definition of specification and programming languages. Nominal terms have good computational properties: Efficient algorithms to check α-equivalence, efficient matching and unification.

37 Revision: First-order unification, Matching Unification has been a popular research field in the last years, motivated by the need to obtain efficient implementations for use in logic programming languages and theorem provers. Unification algorithms play a central role in the implementation of resolution. Prolog is one of the most popular logic programming languages. Logic programming languages use logic to express knowledge, describe a problem; use inference to compute a solution to a problem. Prolog = Clausal Logic + Resolution + Control Strategy

38 Unification Algorithms Domain of computation: Herbrand Universe: set of terms over a universal alphabet of variables: X, Y,... and function symbols (f, g, h,...) with fixed arities (the arity of a symbol is the number of arguments associated with it). A term is either a variable, or has the form f (t 1,..., t n ) where f is a function symbol of arity n and t 1,..., t n are terms. Example: f (f (X, g(a)), Y ) where a is a constant, f a binary function, and g a unary function.

39 Values: Values are also terms, that are associated to variables by means of automatically generated substitutions, called most general unifiers. Definition: A substitution is a partial mapping from variables to terms, with a finite domain. We denote a substitution σ by: {X 1 t 1,..., X n t n }. dom(σ) = {X 1,..., X n }. A substitution σ is applied to a term t or a literal l by simultaneously replacing each variable occurring in dom(σ) by the corresponding term. The resulting term is denoted tσ. Example: Let σ = {X g(y ), Y a} and t = f (f (X, g(a)), Y ). Then tσ = f (f (g(y ), g(a)), a)

40 Solving Queries in Prolog - Example append([],l,l). append([x L],Y,[X Z]) :- append(l,y,z). To solve the query :- append([0],[1,2],u) we use the second clause. The substitution {X 0, L [], Y [1,2], U [0 Z]} unifies append([x L],Y,[X Z]) with the query append([0],[1,2],u), and then we have to prove that append([],[1,2],z) holds. Since we have a fact append([],l,l) in the program, it is sufficient to take {Z [1,2]}. Thus, {U [0,1,2]} is an answer substitution. This method is based on the Principle of Resolution.

41 Operational Semantics of Prolog Unification is a key step in the Principle of Resolution. History: The unification algorithm was first sketched by Jacques Herbrand in his thesis (in 1930). In 1965 Alan Robinson introduced the Principle of Resolution and gave a unification algorithm. Around 1974 Robert Kowalski, Alain Colmerauer and Philippe Roussel defined and implemented a logic programming language based on these ideas (Prolog). The version of the unification algorithm that we present is based on work by Martelli and Montanari (1982).

42 Unification A unification problem U is a set of equations between terms containing variables. {s 1 = t 1,..., s n = t n } A solution to U, also called a unifier, is a substitution σ such that when we apply σ to all the terms in the equations in U we obtain syntactical identities: for each equation s i = t i, the terms s i σ and t i σ coincide. The most general unifier of U is a unifier σ such that any other unifier ρ is an instance of σ.

43 Unification Algorithm Martelli and Montanari s algorithm finds the most general unifier for a unification problem if a solution exists, otherwise it fails, indicating that there are no solutions. To find the most general unifier for a unification problem, the algorithm simplifies the set of equations until a substitution is generated. The way equations are simplified is specified by a set of transformation rules, which apply to sets of equations and produce new sets of equations or a failure.

44 Unification Algorithm Input: A finite set of equations: {s 1 = t 1,..., s n = t n } Output: A substitution (mgu for these terms), or failure. Transformation Rules: Rules are applied non-deterministically, until no rule can be applied or a failure arises. (1) f (s 1,..., s n ) = f (t 1,..., t n ), E s 1 = t 1,..., s n = t n, E (2) f (s 1,..., s n ) = g(t 1,..., t m ), E failure (3) X = X, E E (4) t = X, E X = t, E if t is not a variable (5) X = t, E X = t, E{X t} if X not in t and X in E (6) X = t, E failure if X in t and X t

45 Remarks We are working with sets of equations, therefore their order in the unification problem is not important. The test in case (6) is called occur-check, e.g. X = f (X ) fails. This test is time consuming, and for this reason in some systems it is not implemented. In case of success, by changing in the final set of equations the = by we obtain a substitution, which is the most general unifier (mgu) of the initial set of terms. Cases (1) and (2) apply also to constants: in the first case the equation is deleted and in the second there is a failure.

46 Examples: In the example with append, we solved the unification problem: {[X L] = [0], Y = [1,2], [X Z] = U} Recall that the notation [ ] represents a binary list constructor (the arguments are the head and the tail of the list). [0] is a shorthand for [0 []], and [] is a constant. We now apply the unification algorithm to this set of the equations: using rule (1) in the first equation, we get: {X = 0, L = [], Y = [1,2], [X Z] = U} using rule (5) and the first equation we get: {X = 0, L = [], Y = [1,2], [0 Z] = U} using rule (4) and the last equation we get: {X = 0, L = [], Y = [1,2], U = [0 Z]} and the algorithm stops. Therefore the most general unifier is: {X 0, L [],Y [1,2], U [0 Z]}

47 Unification/Matching To implement rewriting, or to implement a functional/logic programming language, we need a matching/unification algorithm. For first order terms, there are very efficient algorithms (linear time complexity). For terms with binders, we need more powerful algorithms that take into account α-equivalence. Higher-order unification is undecidable. Nominal unification is decidable (polynomial). A solvable problem Pr has a unique most general solution. Nominal matching is linear. In this course we will use nominal matching to define nominal rewriting.

48 Back to nominal terms: checking α-equivalence The syntax-directed derivation rules that define α-equivalence of nominal terms suggest an algorithm to check α-equivalence, using transformation rules in the style of Martelli and Montanari s. a#b, Pr = Pr a#fs, Pr = a#s, Pr a#(s 1,..., s n ), Pr = a#s 1,..., a#s n, Pr a#[b]s, Pr = a#s, Pr a#[a]s, Pr = Pr a#π X, Pr = π -1 a#x, Pr π Id a α a, Pr = Pr (l 1,..., l n ) α (s 1,..., s n ), Pr = l 1 α s 1,..., l n α s n, Pr fl α fs, Pr = l α s, Pr [a]l α [a]s, Pr = l α s, Pr [b]l α [a]s, Pr = (a b) l α s, a#l, Pr π X α π X, Pr = ds(π, π )#X, Pr

49 Checking α-equivalence of terms The relation = is confluent and strongly normalising; i.e. the simplification process terminates and the result is unique: Pr nf. Pr nf is of the form Contr Eq where: contains consistent freshness constraints (a#x ) Contr contains inconsistent freshness constraints (a#a) Eq contains reduced α constraints. Lemma: Γ Pr if and only if Γ Pr nf. Let Pr nf = Contr Eq. Then Pr if and only if Contr and Eq are empty.

50 Solving Equations [Urban, Pitts, Gabbay 2003] Nominal Unification: l?? t has solution (, θ) if lθ α tθ

51 Solving Equations [Urban, Pitts, Gabbay 2003] Nominal Unification: l?? t has solution (, θ) if lθ α tθ Nominal Matching: s = t has solution (, θ) if sθ α t

52 Solving Equations [Urban, Pitts, Gabbay 2003] Nominal Unification: l?? t has solution (, θ) if lθ α tθ Nominal Matching: s = t has solution (, θ) if Examples: λ([a]x ) = λ([b]b)?? λ([a]x ) = λ([b]x )?? sθ α t

53 Solving Equations [Urban, Pitts, Gabbay 2003] Nominal Unification: l?? t has solution (, θ) if lθ α tθ Nominal Matching: s = t has solution (, θ) if Examples: λ([a]x ) = λ([b]b)?? λ([a]x ) = λ([b]x )?? sθ α t Solutions: (, [X a]) and ({a#x, b#x }, Id) resp.

54 Nominal Matching To define the reduction relation generated by nominal rewriting rules we will use nominal matching.

55 Nominal Matching To define the reduction relation generated by nominal rewriting rules we will use nominal matching. Recall: l α t where V (l) V (t) = has solution (, θ) if lθ α t

56 Nominal Matching To define the reduction relation generated by nominal rewriting rules we will use nominal matching. Recall: l α t where V (l) V (t) = has solution (, θ) if lθ α t Nominal matching is decidable [Urban, Pitts, Gabbay 2003]

57 Nominal Matching To define the reduction relation generated by nominal rewriting rules we will use nominal matching. Recall: l α t where V (l) V (t) = has solution (, θ) if lθ α t Nominal matching is decidable [Urban, Pitts, Gabbay 2003] A solvable problem Pr has a unique most general solution: (Γ, θ) such that Γ Prθ.

58 Nominal Matching To define the reduction relation generated by nominal rewriting rules we will use nominal matching. Recall: l α t where V (l) V (t) = has solution (, θ) if lθ α t Nominal matching is decidable [Urban, Pitts, Gabbay 2003] A solvable problem Pr has a unique most general solution: (Γ, θ) such that Γ Prθ. A nominal matching algorithm can be obtained by adding an instantiation rule to the previous set: π X α u, Pr = X π-1 u Pr[X π -1 u] No occur-checks needed (left-hand side variables distinct from right-hand side variables).

59 Rules: l r V (r) V ( ) V (l) Examples: (λ[a]x )Y X [a Y ] a[a Y ] Y (XX )[a Y ] X [a Y ]X [a Y ] a#y Y [a X ] Y b#y (λ[b]x )[a Y ] λ[b](x [a Y ]) Equivariance: Rules are defined modulo permutative renamings of atoms. Next questions: What is the complexity of Nominal Matching? Is nominal matching sufficient (complete) for nominal rewriting?

60 A Linear-Time Algorithm The transformation rules create permutations. In polynomial implementations of nominal unification permutations are lazy: only pushed down a term when needed.

61 A Linear-Time Algorithm The transformation rules create permutations. In polynomial implementations of nominal unification permutations are lazy: only pushed down a term when needed. Problem: lazy permutations may grow (they accumulate).

62 A Linear-Time Algorithm The transformation rules create permutations. In polynomial implementations of nominal unification permutations are lazy: only pushed down a term when needed. Problem: lazy permutations may grow (they accumulate). To obtain an efficient algorithm, work with a single current permutation, represented by an environment.

63 A Linear-Time Algorithm An environment ξ is a pair (ξ π, ξ A ) of a permutation and a set of atoms. Notation: s α ξ t represents s α ξ π t, ξ A # t. An environment problem Pr is either or s 1 α ξ 1 t 1,..., s n α ξ n t n. It is easy to translate a standard problem into an environment problem and vice-versa.

64 A Linear-Time Algorithm The algorithms to check α-equivalence constraints and to solve matching problems are modular. The core module is common to both algorithms, and has four phases: Phase 1 reduces environment constraints, by propagating ξ i over t i. Phase 2 eliminates permutations on the left-hand side. Phase 3 reduces freshness constraints. Phase 4 computes the standard form of the resulting problem. Pr c denotes the result of applying the core algorithm on Pr.

65 Core module Phase 1 - Input: Pr = (s i α ξ i t i ) n i Pr, a α ξ t = Pr, (s 1,..., s n ) α ξ t = Pr, f s α ξ t = Pr, [a]s α ξ t = { Pr if a = ξ π t and t ξ A { otherwise Pr, (s i α ξ u i ) n 1 if t = (u 1,..., u n ) { Pr, s α ξ u { Pr, s α ξ u otherwise if t = f u otherwise if t = [b]u otherwise where ξ = ((a ξ π b) ξ π, (ξ A {ξπ 1 a}) \ {b}) in the last rule, and a, b could be the same atom. The normal forms for phase 1 rules are either or (π i X i α ξ i s i ) n 1 where s i are nominal terms.

66 Core module Phase 2 - Input: A Phase 1 normal form. π X α ξ t = X α (π 1 ξ) t where π 1 ξ = (π 1 ξ π, ξ A ). (π Id) Above, π 1 applies only to ξ π, because π X α ξ t represents π X α ξ π t, ξ A #t. Phase 2 normal forms are either or (X i α ξ i t i ) n 1, where the terms t i are standard nominal terms.

67 Core module Phase 3 - Input: A Phase 2 normal form (X i α ξ i t i ) n 1. { ξ π a a ξ A ξ a = a ξ A ξ f t = f (ξ t) ξ (t 1,..., t j ) = (ξ t i ) j 1 ξ [a]s = [ξ π a]((ξ \ {a}) s) ξ (π X ) = (ξ π) X Pr[ ] = where ξ \ {a} = (ξ π, ξ A \ {a}) and ξ π = ((ξ π π), π 1 (ξ A )). The normal forms are either or (X i α t i ) n 1 where t i T ξ. T ξ = a f T ξ (T ξ,..., T ξ ) [a]t ξ ξ X

68 Core module Phase 4: X α C[ξ X ] = X α C[ξ π X ], ξ A # X Normal forms are either or (X i α u i ) i I, (A j # X j ) j J where u i are nominal terms and I, J may be empty. Correctness: The core algorithm terminates, and preserves the set of solutions.

69 Checking α-equivalence constraints To check that a set Pr of α-equivalence constraints is valid: Run the core algorithm on Pr

70 Checking α-equivalence constraints To check that a set Pr of α-equivalence constraints is valid: Run the core algorithm on Pr If left-hand sides of α -constraints in Pr are ground, stop otherwise reduce the result Pr c using: { Pr, supp(π) # X if t = π X (α) Pr, X α t = otherwise where supp(π) = {a π a a}

71 Checking α-equivalence constraints To check that a set Pr of α-equivalence constraints is valid: Run the core algorithm on Pr If left-hand sides of α -constraints in Pr are ground, stop otherwise reduce the result Pr c using: { Pr, supp(π) # X if t = π X (α) Pr, X α t = otherwise where supp(π) = {a π a a} Normal forms: or (A i # X i ) n 1.

72 Checking α-equivalence constraints To check that a set Pr of α-equivalence constraints is valid: Run the core algorithm on Pr If left-hand sides of α -constraints in Pr are ground, stop otherwise reduce the result Pr c using: { Pr, supp(π) # X if t = π X (α) Pr, X α t = otherwise where supp(π) = {a π a a} Normal forms: or (A i # X i ) n 1. Correctness: If the normal form is then Pr is not valid. If the normal form of Pr is (A i # X i ) n 1 then (A i # X i ) n 1 Pr.

73 Solving Matching Problems To solve a matching problem Pr: Run the core algorithm on Pr

74 Solving Matching Problems To solve a matching problem Pr: Run the core algorithm on Pr If the problem is non-linear, normalise the result Pr c by: Pr, X α s, { X α t = Pr, X α s, s α t α if s α t α otherwise

75 Solving Matching Problems To solve a matching problem Pr: Run the core algorithm on Pr If the problem is non-linear, normalise the result Pr c by: Pr, X α s, { X α t = Pr, X α s, s α t α if s α t α otherwise Normal forms: or a pair of a substitution and a freshness context.

76 Solving Matching Problems To solve a matching problem Pr: Run the core algorithm on Pr If the problem is non-linear, normalise the result Pr c by: Pr, X α s, { X α t = Pr, X α s, s α t α if s α t α otherwise Normal forms: or a pair of a substitution and a freshness context. Correctness: The result is a most general solution of the matching problem Pr.

77 Solving Matching Problems To solve a matching problem Pr: Run the core algorithm on Pr If the problem is non-linear, normalise the result Pr c by: Pr, X α s, { X α t = Pr, X α s, s α t α if s α t α otherwise Normal forms: or a pair of a substitution and a freshness context. Correctness: The result is a most general solution of the matching problem Pr. Remark: If variables occur linearly in patterns then the core algorithm is sufficient.

78 Complexity Core algorithm: linear in the size of the initial problem in the ground case, using mutable arrays. In the non-ground case, log-linear using functional maps. Alpha-equivalence check: linear if right-hand sides of constraints are ground (core algorithm). Otherwise, log-linear using functional maps. Matching: quadratic in the non-ground case (traversal of every term in the output of the core algorithm). Worst case complexity: when phase 4 suspends permutations on all variables. If variables in the input problem are saturated with permutations, then linear (permutations cannot grow).

79 Complexity Summary: Case Alpha-equivalence Matching Ground linear linear Non-ground and linear log-linear log-linear Non-ground and non-linear log-linear quadratic Remark: The representation using higher-order abstract syntax does saturate the variables (they have to be applied to the set of atoms they can capture). Conjecture: the algorithms are linear wrt HOAS also in the non-ground case.

80 Benchmarks OCAML implementation, available from CANS webpage. 0.5 alpha match Time Size

81 Nominal Matching vs. Equivariant Matching Nominal matching is efficient.

82 Nominal Matching vs. Equivariant Matching Nominal matching is efficient. Equivariant nominal matching is exponential... BUT

83 Nominal Matching vs. Equivariant Matching Nominal matching is efficient. Equivariant nominal matching is exponential... BUT if rules are CLOSED then nominal matching is sufficient. Intuitively, closed means no free atoms. The nominal rewriting system in the example above is closed.

84 Closed Rules R l r is closed when ( (l, r ))? (, A(R )#V (R) (l, r)) has a solution σ (where R is freshened with respect to R). Given R l r and s a term-in-context we write s R c t when, A(R )#V (, s) s R t and call this closed rewriting.

85 Examples The following rules are not closed: g(a) a [a]x X Why?

86 Examples The following rule is closed: Why? a#x [a]x X

87 Examples The following rules are closed, they define capture-avoiding substitution operation of the lambda calculus. We introduce a term-former for (explicit) substitutions subst which we sugar to t[a t ]. (Beta) (λ[a]x )X X [a X ] (σ App ) (XX )[a Y ] X [a Y ]X [a Y ] (σ var ) a[a X ] X (σ ɛ ) a#y Y [a X ] Y (σ f n) b#y (λ[b]x )[a Y ] λ[b](x [a Y ])

88 Properties of Closed Rewriting Closed : works uniformly in α equivalence classes of terms.

89 Properties of Closed Rewriting Closed : works uniformly in α equivalence classes of terms. is expressive: can encode Combinatory Reduction Systems.

90 Properties of Closed Rewriting Closed : works uniformly in α equivalence classes of terms. is expressive: can encode Combinatory Reduction Systems. is efficient: polynomial equivariant matching.

91 Properties of Closed Rewriting Closed : works uniformly in α equivalence classes of terms. is expressive: can encode Combinatory Reduction Systems. is efficient: polynomial equivariant matching. inherits confluence conditions from first order rewriting.

92 Confluence Suppose 1 R i = i l i r i for i = 1, 2 are copies of two rules in R such that V (R 1 ) V (R 2 ) = (R 1 and R 2 could be copies of the same rule). 2 l 1 L[l 1 ] such that 1, 2, l 1?? l 2 has a principal solution (Γ, θ), so that Γ l 1 θ α l 2 θ and Γ i θ for i = 1, 2. Then Γ (r 1 θ, Lθ[r 2 θ]) is a critical pair. If L = [-] and R 1, R 2 are copies of the same rule, or if l 1 is a variable, then we say the critical pair is trivial. Critical Pair Lemma: A closed nominal rewrite system where all non-trivial critical pairs are joinable, is locally confluent. Orthogonality: If all the rules are closed, left-linear, and without superpositions nominal rewriting is confluent.

93 If there is time... So far, we have discussed untyped nominal terms. There exist many-sorted versions of nominal syntax, and also type assingment systems à la Curry for nominal terms.

94 Types for Nominal Terms Types built from a set of base data sorts δ (e.g. Nat, Bool, Exp,... ) type variables α, and type constructors C (e.g.,, List,... ) Types and type schemes: τ ::= δ α (τ 1... τ n ) C τ [τ]τ σ ::= α.τ Type declarations (arity): ρ ::= (τ )τ E.g. succ: (Nat)Nat Instantiation: σ τ E.g. α.α Nat, (α)α (Nat)Nat

95 Typing Rules Typing judgement: Γ; s : τ where Γ is a typing context, a freshness context, s a term and τ a type. σ τ Γ, a : σ; a : τ Γ, a : τ; t : τ σ τ Γ; π X : Γ, X : σ; π X : τ Γ; [a]t : [τ]τ Γ; t i : τ i (1 i n) Γ; (t 1,..., t n ) : τ 1... τ n Γ; t : τ f : ρ (τ )τ Γ; ft : τ Γ; π X : holds if for any a such that π a a, a#x or for some σ, a: σ, π a: σ Γ.

96 Examples a : α.α, X : β (a, X ) : β β [a]a : [α]α a : β [a]a : [α]α a : α, b : α, X : τ (a b) X : τ X : τ; a#x, b#x (a b) X : τ X : τ, a : α, b : α [a]((a b) X, b) : [α](τ α) Generalisation of Hindley-Milner s type system: atoms (can be abstracted or unabstracted), variables (cannot be abstracted but can be instantiated, with non-capture-avoiding substitutions), suspended permutations.

97 Principal Types Every term has a principal type, and type inference is decidable. Principal types are obtained using a function pt(γ; s). pt is sound and complete. pt(γ, a: ατ; a) = (Id, τ), where α α are fresh. pt(γ, X : ατ; π X ) = (S, τs) (α α fresh) provided that for each a in π such that a π a, a#x, or a: σ, π a: σ Γ for some σ, σ that are unifiable. S is the mgu of those pairs, or Id if all such a are fresh for X. pt(γ; (t 1,..., t n )) = (S 1... S n, φ 1 S 2... S n... φ n 1 S n φ n ) where pt(γ; t 1 ) = (S 1, φ 1 ), pt(γs 1 ; t 2 ) = (S 2, φ 2 ),..., pt(γs 1... S n 1 ; t n ) = (S n, φ n ). pt(γ; ft) = (SS, φs ) where pt(γ; t) = (S, τ), f : ρ = (φ )φ (type variables in ρ are fresh), S = mgu(τ, φ ). pt(γ; [a]s) = (S Γ, [τ ]τ) where pt(γ, a:α; s) = (S, τ), α is fresh, αs = τ.

98 α-equivalence preserves types α-equivalence preserves types: s α t and Γ; s : τ imply Γ; t : τ.

99 Conclusion Nominal Terms: first-order syntax with binders. Nominal unification is polynomial (unknown lower bound). Nominal unification is used in the language α-prolog [Cheney and Urban] Nominal matching is linear, equivariant matching is linear with closed rules. Variants of nominal matching are used in functional languages with nominal features (eg. FreshML).

100 Conclusion NRSs are first-order systems with built-in α-equivalence: first-order substitutions, matching modulo α. Closed NRSs have the expressive power of higher-order rewriting. Higher-order substitutions are easy to define using freshness. Closed NRSs have the properties of first-order rewriting (critical pair lemma, orthogonality). Types can be added to give semantics to terms and to obtain sufficient conditions for termination. Hindley-Milner style types: Typing is decidable and there are principal types, α-equivalence preserves types.

Nominal Completion for Rewrite Systems with Binders

Nominal Completion for Rewrite Systems with Binders Nominal Completion for Rewrite Systems with Binders Maribel Fernández King s College London July 2012 Joint work with Albert Rubio Summary Motivations Nominal Rewriting Closed nominal rules Confluence

More information

Nominal Matching and Alpha-Equivalence (Extended Abstract)

Nominal Matching and Alpha-Equivalence (Extended Abstract) Nominal Matching and Alpha-Equivalence (Extended Abstract) Christophe Calvès and Maribel Fernández King s College London, Department of Computer Science, Strand, London WC2R 2LS, UK Christophe.Calves@kcl.ac.uk

More information

Nominal Unification. Key words: Abstract Syntax, Alpha-Conversion, Binding Operations, Unification

Nominal Unification. Key words: Abstract Syntax, Alpha-Conversion, Binding Operations, Unification Nominal Unification Christian Urban a Andrew M. Pitts a Murdoch J. Gabbay b a University of Cambridge, Cambridge, UK b INRIA, Paris, France Abstract We present a generalisation of first-order unification

More information

Most General Unifiers in Generalized Nominal Unification

Most General Unifiers in Generalized Nominal Unification Most General Unifiers in Generalized Nominal Unification Yunus D K Kutz 1 and Manfred Schmidt-Schauß 2 1 Goethe-University Frankfurt am Main, Germany, kutz@kiinformatikuni-frankfurtde 2 Goethe-University

More information

Introduction to lambda calculus Part 6

Introduction to lambda calculus Part 6 Introduction to lambda calculus Part 6 Antti-Juhani Kaijanaho 2017-02-16 1 Untyped lambda calculus 2 Typed lambda calculi 2.1 Dynamically typed lambda calculus with integers 2.2 A model of Lisp 2.3 Simply

More information

Relating Nominal and Higher-Order Pattern Unification

Relating Nominal and Higher-Order Pattern Unification Relating Nominal and Higher-Order Pattern Unification James Cheney University of Edinburgh UNIF 2005 April 22, 2005 1 Motivation Higher-order unification: studied since ca. 1970 Undecidable, infinitary,

More information

Introduction to Logic in Computer Science: Autumn 2006

Introduction to Logic in Computer Science: Autumn 2006 Introduction to Logic in Computer Science: Autumn 2006 Ulle Endriss Institute for Logic, Language and Computation University of Amsterdam Ulle Endriss 1 Plan for Today Today s class will be an introduction

More information

Relating Nominal and Higher-Order Pattern Unification

Relating Nominal and Higher-Order Pattern Unification Relating Nominal and Higher-Order Pattern Unification James Cheney University of Edinburgh jcheney@inf.ed.ac.uk Abstract. Higher-order pattern unification and nominal unification are two approaches to

More information

The non-logical symbols determine a specific F OL language and consists of the following sets. Σ = {Σ n } n<ω

The non-logical symbols determine a specific F OL language and consists of the following sets. Σ = {Σ n } n<ω 1 Preliminaries In this chapter we first give a summary of the basic notations, terminology and results which will be used in this thesis. The treatment here is reduced to a list of definitions. For the

More information

Mathematical Synthesis of Equational Deduction Systems. Marcelo Fiore. Computer Laboratory University of Cambridge

Mathematical Synthesis of Equational Deduction Systems. Marcelo Fiore. Computer Laboratory University of Cambridge Mathematical Synthesis of Equational Deduction Systems Marcelo Fiore Computer Laboratory University of Cambridge TLCA 2009 3.VII.2009 Context concrete theories meta-theories Context concrete theories meta-theories

More information

Rewriting, Explicit Substitutions and Normalisation

Rewriting, Explicit Substitutions and Normalisation Rewriting, Explicit Substitutions and Normalisation XXXVI Escola de Verão do MAT Universidade de Brasilia Part 1/3 Eduardo Bonelli LIFIA (Fac. de Informática, UNLP, Arg.) and CONICET eduardo@lifia.info.unlp.edu.ar

More information

Nominal Dependent Types as a Logical Framework

Nominal Dependent Types as a Logical Framework ominal Dependent Types as a Logical Framework Elliot Fairweather, Maribel Fernández, ora Szasz, Alvaro Tasistro King s College London University ORT Uruguay July 20, 2011 Abstract We present a logical

More information

07 Equational Logic and Algebraic Reasoning

07 Equational Logic and Algebraic Reasoning CAS 701 Fall 2004 07 Equational Logic and Algebraic Reasoning Instructor: W. M. Farmer Revised: 17 November 2004 1 What is Equational Logic? Equational logic is first-order logic restricted to languages

More information

Type Inference Algorithms

Type Inference Algorithms Type Inference Algorithms February 19, 2009 S. Saeidi Mobarakeh ( 0559938 ) Abstract In this paper we are going to describe the Wand s type inference algorithm and we ll try to extend this algorithm with

More information

Nominal Unification with Atom-Variables

Nominal Unification with Atom-Variables Nominal Unification with Atom-Variables Manfred Schmidt-Schauß Goethe-University Frankfurt am Main, Germany David Sabel Goethe-University Frankfurt am Main, Germany Yunus D. K. Kutz Goethe-University Frankfurt

More information

Theoretical Computer Science 323 (2004) Nominal unication. Cambridge CB3 OFD, UK b INRIA, Paris, France

Theoretical Computer Science 323 (2004) Nominal unication. Cambridge CB3 OFD, UK b INRIA, Paris, France Theoretical Computer Science 323 (2004) 473 497 www.elsevier.com/locate/tcs Nominal unication Christian Urban a, Andrew M. Pitts a;, Murdoch J. Gabbay b a University of Cambridge, Marconi Laboratory, William

More information

Outline. Logic. Definition. Theorem (Gödel s Completeness Theorem) Summary of Previous Week. Undecidability. Unification

Outline. Logic. Definition. Theorem (Gödel s Completeness Theorem) Summary of Previous Week. Undecidability. Unification Logic Aart Middeldorp Vincent van Oostrom Franziska Rapp Christian Sternagel Department of Computer Science University of Innsbruck WS 2017/2018 AM (DCS @ UIBK) week 11 2/38 Definitions elimination x φ

More information

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications NICTA Advanced Course Theorem Proving Principles, Techniques, Applications λ 1 CONTENT Intro & motivation, getting started with Isabelle Foundations & Principles Lambda Calculus Higher Order Logic, natural

More information

The Curry-Howard Isomorphism

The Curry-Howard Isomorphism The Curry-Howard Isomorphism Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) The Curry-Howard Isomorphism MFES 2008/09

More information

CS522 - Programming Language Semantics

CS522 - Programming Language Semantics 1 CS522 - Programming Language Semantics Simply Typed Lambda Calculus Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 We now discuss a non-trivial extension of

More information

Names and Symmetry in Computer Science

Names and Symmetry in Computer Science 1/27 Names and Symmetry in Computer Science Andrew Pitts Computer Laboratory LICS 2015 Tutorial 2/27 An introduction to nominal techniques motivated by Programming language semantics Automata theory Constructive

More information

Binding in Nominal Equational Logic

Binding in Nominal Equational Logic MFPS 2010 Binding in Nominal Equational Logic Ranald Clouston 1,2 Computer Laboratory, University of Cambridge, Cambridge CB3 0DF, United Kingdom Abstract Many formal systems, particularly in computer

More information

INF3170 / INF4171 Notes on Resolution

INF3170 / INF4171 Notes on Resolution INF3170 / INF4171 Notes on Resolution Andreas Nakkerud Autumn 2015 1 Introduction This is a short description of the Resolution calculus for propositional logic, and for first order logic. We will only

More information

Introduction to Logic in Computer Science: Autumn 2007

Introduction to Logic in Computer Science: Autumn 2007 Introduction to Logic in Computer Science: Autumn 2007 Ulle Endriss Institute for Logic, Language and Computation University of Amsterdam Ulle Endriss 1 Tableaux for First-order Logic The next part of

More information

Syntax of FOL. Introduction to Logic in Computer Science: Autumn Tableaux for First-order Logic. Syntax of FOL (2)

Syntax of FOL. Introduction to Logic in Computer Science: Autumn Tableaux for First-order Logic. Syntax of FOL (2) Syntax of FOL Introduction to Logic in Computer Science: Autumn 2007 Ulle Endriss Institute for Logic, Language and Computation University of Amsterdam The syntax of a language defines the way in which

More information

Equational Logic. Chapter 4

Equational Logic. Chapter 4 Chapter 4 Equational Logic From now on First-order Logic is considered with equality. In this chapter, I investigate properties of a set of unit equations. For a set of unit equations I write E. Full first-order

More information

Capture-Avoiding Substitution as a Nominal Algebra

Capture-Avoiding Substitution as a Nominal Algebra Under consideration for publication in Formal Aspects of Computing Capture-Avoiding Substitution as a Nominal Algebra Murdoch J. Gabbay 1 and Aad Mathijssen 2 Abstract. Substitution is fundamental to the

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem

More information

Clausal Presentation of Theories in Deduction Modulo

Clausal Presentation of Theories in Deduction Modulo Gao JH. Clausal presentation of theories in deduction modulo. JOURNAL OF COMPUTER SCIENCE AND TECHNOL- OGY 28(6): 1085 1096 Nov. 2013. DOI 10.1007/s11390-013-1399-0 Clausal Presentation of Theories in

More information

Denotational semantics: proofs

Denotational semantics: proofs APPENDIX A Denotational semantics: proofs We show that every closed term M has a computable functional [[M ] as its denotation. A.1. Unification We show that for any two constructor terms one can decide

More information

Jacques Fleuriot. Automated Reasoning Rewrite Rules

Jacques Fleuriot. Automated Reasoning Rewrite Rules Automated Reasoning Rewrite Rules Jacques Fleuriot Lecture 8, page 1 Term Rewriting Rewriting is a technique for replacing terms in an expression with equivalent terms useful for simplification, e.g. given

More information

HORSes: format, termination and confluence

HORSes: format, termination and confluence HORSes: format, termination and confluence Jean-Pierre Jouannaud INRIA-LIAMA and singhua Software Chair Joint on-going work with Jianqi Li School of Software, singhua University Project CoqLF NList Cross-discipline

More information

Nominal Lawvere Theories: A Category Theoretic Account of Equational Theories with Names

Nominal Lawvere Theories: A Category Theoretic Account of Equational Theories with Names Nominal Lawvere Theories: A Category Theoretic Account of Equational Theories with Names Ranald Clouston 1 Logic and Computation Group, Research School of Computer Science, The Australian National University,

More information

Dependent Types and Explicit Substitutions

Dependent Types and Explicit Substitutions NASA/CR-1999-209722 ICASE Report No. 99-43 Dependent Types and Explicit Substitutions César Muñoz ICASE, Hampton, Virginia Institute for Computer Applications in Science and Engineering NASA Langley Research

More information

ON FIRST-ORDER CONS-FREE TERM REWRITING AND PTIME

ON FIRST-ORDER CONS-FREE TERM REWRITING AND PTIME ON FIRST-ORDER CONS-FREE TERM REWRITING AND PTIME CYNTHIA KOP Department of Computer Science, Copenhagen University e-mail address: kop@diku.dk Abstract. In this paper, we prove that (first-order) cons-free

More information

2.5.2 Basic CNF/DNF Transformation

2.5.2 Basic CNF/DNF Transformation 2.5. NORMAL FORMS 39 On the other hand, checking the unsatisfiability of CNF formulas or the validity of DNF formulas is conp-complete. For any propositional formula φ there is an equivalent formula in

More information

Intelligent Agents. Formal Characteristics of Planning. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University

Intelligent Agents. Formal Characteristics of Planning. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University Intelligent Agents Formal Characteristics of Planning Ute Schmid Cognitive Systems, Applied Computer Science, Bamberg University Extensions to the slides for chapter 3 of Dana Nau with contributions by

More information

CONSTRAINT SOLVING IN NON-PERMUTATIVE NOMINAL ABSTRACT SYNTAX

CONSTRAINT SOLVING IN NON-PERMUTATIVE NOMINAL ABSTRACT SYNTAX Logical Methods in Computer Science Vol. 7 (3:06) 2011, pp. 1 31 www.lmcs-online.org Submitted Jan. 3, 2011 Published Aug. 25, 2011 CONSTRAINT SOLVING IN NON-PERMUTATIVE NOMINAL ABSTRACT SYNTAX MATTHEW

More information

A Tableau Calculus for Minimal Modal Model Generation

A Tableau Calculus for Minimal Modal Model Generation M4M 2011 A Tableau Calculus for Minimal Modal Model Generation Fabio Papacchini 1 and Renate A. Schmidt 2 School of Computer Science, University of Manchester Abstract Model generation and minimal model

More information

Sequent Combinators: A Hilbert System for the Lambda Calculus

Sequent Combinators: A Hilbert System for the Lambda Calculus Sequent Combinators: A Hilbert System for the Lambda Calculus Healfdene Goguen Department of Computer Science, University of Edinburgh The King s Buildings, Edinburgh, EH9 3JZ, United Kingdom Fax: (+44)

More information

A Recursion Combinator for Nominal Datatypes Implemented in Isabelle/HOL

A Recursion Combinator for Nominal Datatypes Implemented in Isabelle/HOL A Recursion Combinator for Nominal Datatypes Implemented in Isabelle/HOL Christian Urban and Stefan Berghofer Technische Universität München {urbanc,berghofe}@in.tum.de Abstract. The nominal datatype package

More information

Predicate Logic. Xinyu Feng 09/26/2011. University of Science and Technology of China (USTC)

Predicate Logic. Xinyu Feng 09/26/2011. University of Science and Technology of China (USTC) University of Science and Technology of China (USTC) 09/26/2011 Overview Predicate logic over integer expressions: a language of logical assertions, for example x. x + 0 = x Why discuss predicate logic?

More information

The Lambda-Calculus Reduction System

The Lambda-Calculus Reduction System 2 The Lambda-Calculus Reduction System 2.1 Reduction Systems In this section we present basic notions on reduction systems. For a more detailed study see [Klop, 1992, Dershowitz and Jouannaud, 1990]. Definition

More information

Beyond First-Order Logic

Beyond First-Order Logic Beyond First-Order Logic Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) Beyond First-Order Logic MFES 2008/09 1 / 37 FOL

More information

From Operational Semantics to Abstract Machines

From Operational Semantics to Abstract Machines From Operational Semantics to Abstract Machines John Hannan Department of Computer Science, University of Copenhagen, Universitetsparken 1, DK-2100 Copenhagen East, Denmark. hannan@diku.dk Dale Miller

More information

King s Research Portal

King s Research Portal King s Research Portal DOI: 10.1016/j.entcs.2016.06.004 Document Version Publisher's PDF, also known as Version of record Link to publication record in King's Research Portal Citation for published version

More information

Normalization by Evaluation

Normalization by Evaluation Normalization by Evaluation Andreas Abel Department of Computer Science and Engineering Chalmers and Gothenburg University PhD Seminar in Mathematical Engineering EAFIT University, Medellin, Colombia 9

More information

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw Applied Logic Lecture 1 - Propositional logic Marcin Szczuka Institute of Informatics, The University of Warsaw Monographic lecture, Spring semester 2017/2018 Marcin Szczuka (MIMUW) Applied Logic 2018

More information

Type Inference. For the Simply-Typed Lambda Calculus. Peter Thiemann, Manuel Geffken. Albert-Ludwigs-Universität Freiburg. University of Freiburg

Type Inference. For the Simply-Typed Lambda Calculus. Peter Thiemann, Manuel Geffken. Albert-Ludwigs-Universität Freiburg. University of Freiburg Type Inference For the Simply-Typed Lambda Calculus Albert-Ludwigs-Universität Freiburg Peter Thiemann, Manuel Geffken University of Freiburg 24. Januar 2013 Outline 1 Introduction 2 Applied Lambda Calculus

More information

Advanced Topics in LP and FP

Advanced Topics in LP and FP Lecture 1: Prolog and Summary of this lecture 1 Introduction to Prolog 2 3 Truth value evaluation 4 Prolog Logic programming language Introduction to Prolog Introduced in the 1970s Program = collection

More information

a-logic with arrows Murdoch J. Gabbay 1 Michael J. Gabbay 2 1 Introduction

a-logic with arrows Murdoch J. Gabbay 1 Michael J. Gabbay 2 1 Introduction a-logic with arrows Murdoch J. Gabbay 1 Michael J. Gabbay 2 Abstract We present an extension of first-order predicate logic with a novel predicate at t meaning intuitively this term is a variable symbol.

More information

Nominal Syntax and Semantics

Nominal Syntax and Semantics Nominal Syntax and Semantics Andrew Pitts University of Cambridge Computer Laboratory APPSEM 2005, 1 - p. 1 How best to reconcile Mathematics of syntax syntactical issues to do with name-binding and α-conversion

More information

7 RC Simulates RA. Lemma: For every RA expression E(A 1... A k ) there exists a DRC formula F with F V (F ) = {A 1,..., A k } and

7 RC Simulates RA. Lemma: For every RA expression E(A 1... A k ) there exists a DRC formula F with F V (F ) = {A 1,..., A k } and 7 RC Simulates RA. We now show that DRC (and hence TRC) is at least as expressive as RA. That is, given an RA expression E that mentions at most C, there is an equivalent DRC expression E that mentions

More information

LOGIC PROPOSITIONAL REASONING

LOGIC PROPOSITIONAL REASONING LOGIC PROPOSITIONAL REASONING WS 2017/2018 (342.208) Armin Biere Martina Seidl biere@jku.at martina.seidl@jku.at Institute for Formal Models and Verification Johannes Kepler Universität Linz Version 2018.1

More information

Translating Combinatory Reduction Systems into the Rewriting Calculus

Translating Combinatory Reduction Systems into the Rewriting Calculus Electronic Notes in Theoretical Computer Science 86 No. 2 (2003) URL: http://www.elsevier.nl/locate/entcs/volume86.html 17 pages Translating Combinatory Reduction Systems into the Rewriting Calculus Clara

More information

Mathematical Logics. 12. Soundness and Completeness of tableaux reasoning in first order logic. Luciano Serafini

Mathematical Logics. 12. Soundness and Completeness of tableaux reasoning in first order logic. Luciano Serafini 12. Soundness and Completeness of tableaux reasoning in first order logic Fondazione Bruno Kessler, Trento, Italy November 14, 2013 Example of tableaux Example Consider the following formulas: (a) xyz(p(x,

More information

A Canonical 1 Locally Named Representation of Binding. α -equivalence is identity. Randy Pollack. Masahiko Sato. LFCS, University of Edinburgh

A Canonical 1 Locally Named Representation of Binding. α -equivalence is identity. Randy Pollack. Masahiko Sato. LFCS, University of Edinburgh A Canonical 1 Locally Named Representation of Binding Randy Pollack LFCS, University of Edinburgh Masahiko Sato Graduate School of Informatics, Kyoto University Version of September 3, 2009 1 α -equivalence

More information

Lazy Strong Normalization

Lazy Strong Normalization Lazy Strong Normalization Luca Paolini 1,2 Dipartimento di Informatica Università di Torino (ITALIA) Elaine Pimentel 1,2 Departamento de Matemática Universidade Federal de Minas Gerais (BRASIL) Dipartimento

More information

Automated Reasoning (in First Order Logic) Andrei Voronkov. University of Manchester

Automated Reasoning (in First Order Logic) Andrei Voronkov. University of Manchester Automated Reasoning (in First Order Logic) Andrei Voronkov University of Manchester 1 Overview Automated reasoning in first-order logic. Completeness. Theory of Resolution and Redundancy. From Theory to

More information

Example. Lemma. Proof Sketch. 1 let A be a formula that expresses that node t is reachable from s

Example. Lemma. Proof Sketch. 1 let A be a formula that expresses that node t is reachable from s Summary Summary Last Lecture Computational Logic Π 1 Γ, x : σ M : τ Γ λxm : σ τ Γ (λxm)n : τ Π 2 Γ N : τ = Π 1 [x\π 2 ] Γ M[x := N] Georg Moser Institute of Computer Science @ UIBK Winter 2012 the proof

More information

Gluing Nominal Theories

Gluing Nominal Theories École ormale Supérieure de Lyon Master d Informatique Fondamentale, 1 re année Gluing ominal Theories Florian Hatat with Roy L. Crole University of Leicester June August 2007 Contents 1 Introduction 2

More information

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms First-Order Logic 1 Syntax Domain of Discourse The domain of discourse for first order logic is FO structures or models. A FO structure contains Relations Functions Constants (functions of arity 0) FO

More information

First-Order Theorem Proving and Vampire

First-Order Theorem Proving and Vampire First-Order Theorem Proving and Vampire Laura Kovács 1,2 and Martin Suda 2 1 TU Wien 2 Chalmers Outline Introduction First-Order Logic and TPTP Inference Systems Saturation Algorithms Redundancy Elimination

More information

Automated Synthesis of Tableau Calculi

Automated Synthesis of Tableau Calculi Automated Synthesis of Tableau Calculi Renate A. Schmidt 1 and Dmitry Tishkovsky 1 School of Computer Science, The University of Manchester Abstract This paper presents a method for synthesising sound

More information

Equational Reasoning in Algebraic Structures: a Complete Tactic

Equational Reasoning in Algebraic Structures: a Complete Tactic Equational Reasoning in Algebraic Structures: a Complete Tactic Luís Cruz-Filipe 1,2 and Freek Wiedijk 1 1 NIII, University of Nijmegen, Netherlands and 2 CLC, Lisbon, Portugal Abstract We present rational,

More information

Model Evolution with Equality Revised and Implemented

Model Evolution with Equality Revised and Implemented Model Evolution with Equality Revised and Implemented Peter Baumgartner 1 NICTA and The Australian National University, Canberra, Australia Björn Pelzer Institute for Computer Science, Universität Koblenz-Landau,

More information

Universal Algebra for Termination of Higher-Order Rewriting. Makoto Hamana

Universal Algebra for Termination of Higher-Order Rewriting. Makoto Hamana Universal Algebra for Termination of Higher-Order Rewriting Makoto Hamana Department of Computer Science, Gunma University, Japan RTA 05 2005, April 1 Intro: First-Order Term Rewriting System (TRS) Terms

More information

First-Order Theorem Proving and Vampire. Laura Kovács (Chalmers University of Technology) Andrei Voronkov (The University of Manchester)

First-Order Theorem Proving and Vampire. Laura Kovács (Chalmers University of Technology) Andrei Voronkov (The University of Manchester) First-Order Theorem Proving and Vampire Laura Kovács (Chalmers University of Technology) Andrei Voronkov (The University of Manchester) Outline Introduction First-Order Logic and TPTP Inference Systems

More information

COMP6463: λ-calculus

COMP6463: λ-calculus COMP6463: λ-calculus 1. Basics Michael Norrish Michael.Norrish@nicta.com.au Canberra Research Lab., NICTA Semester 2, 2015 Outline Introduction Lambda Calculus Terms Alpha Equivalence Substitution Dynamics

More information

On the Complexity of the Reflected Logic of Proofs

On the Complexity of the Reflected Logic of Proofs On the Complexity of the Reflected Logic of Proofs Nikolai V. Krupski Department of Math. Logic and the Theory of Algorithms, Faculty of Mechanics and Mathematics, Moscow State University, Moscow 119899,

More information

Depending on equations

Depending on equations Depending on equations A proof-relevant framework for unification in dependent type theory Jesper Cockx DistriNet KU Leuven 3 September 2017 Unification for dependent types Unification is used for many

More information

1 Introduction to Predicate Resolution

1 Introduction to Predicate Resolution 1 Introduction to Predicate Resolution The resolution proof system for Predicate Logic operates, as in propositional case on sets of clauses and uses a resolution rule as the only rule of inference. The

More information

On rigid NL Lambek grammars inference from generalized functor-argument data

On rigid NL Lambek grammars inference from generalized functor-argument data 7 On rigid NL Lambek grammars inference from generalized functor-argument data Denis Béchet and Annie Foret Abstract This paper is concerned with the inference of categorial grammars, a context-free grammar

More information

Formal SOS-Proofs for the Lambda-Calculus

Formal SOS-Proofs for the Lambda-Calculus LSFA 8 Formal SOS-Proofs for the Lambda-Calculus Christian Urban 1 and Julien Narboux TU Munich, Germany University of Strasbourg, France Abstract We describe in this paper formalisations for the properties

More information

Categories, Proofs and Programs

Categories, Proofs and Programs Categories, Proofs and Programs Samson Abramsky and Nikos Tzevelekos Lecture 4: Curry-Howard Correspondence and Cartesian Closed Categories In A Nutshell Logic Computation 555555555555555555 5 Categories

More information

A Complete Narrowing Calculus for Higher-Order Functional Logic Programming

A Complete Narrowing Calculus for Higher-Order Functional Logic Programming A Complete Narrowing Calculus for Higher-Order Functional Logic Programming Koichi Nakahara, 1 Aart Middeldorp, 2 Tetsuo Ida 2 1 Canon Inc. Shimomaruko, Ohta-ku, Tokyo 146, Japan 2 Institute of Information

More information

Type inference in context

Type inference in context Type inference in context Adam Gundry University of Strathclyde Microsoft Research PhD Scholar Conor McBride University of Strathclyde James McKinna Radboud University Nijmegen MSFP 25 September 2010 Two

More information

Third-Order Matching via Explicit Substitutions

Third-Order Matching via Explicit Substitutions Third-Order Matching via Explicit Substitutions Flávio L. C. de Moura 1 and Mauricio Ayala-Rincón 1 and Fairouz Kamareddine 2 1 Departamento de Matemática, Universidade de Brasília, Brasília D.F., Brasil.

More information

Complete Selection Functions for a Lazy Conditional Narrowing Calculus

Complete Selection Functions for a Lazy Conditional Narrowing Calculus Complete Selection Functions for a Lazy Conditional Narrowing Calculus Aart Middeldorp Institute of Information Sciences and Electronics University of Tsukuba, Tsukuba 305-8573, Japan ami@is.tsukuba.ac.jp

More information

Automated Reasoning Lecture 5: First-Order Logic

Automated Reasoning Lecture 5: First-Order Logic Automated Reasoning Lecture 5: First-Order Logic Jacques Fleuriot jdf@inf.ac.uk Recap Over the last three lectures, we have looked at: Propositional logic, semantics and proof systems Doing propositional

More information

This work was partially supported by CAPES PVE 146/2012 and CNPq UNIVERSAL /

This work was partially supported by CAPES PVE 146/2012 and CNPq UNIVERSAL / ominal arrowing Mauricio Ayala-Rincón 1, Maribel Fernández 2, and Daniele antes-sobrinho 3 1 Departamentos de Ciência da Computação e Matemática, Universidade de Brasília, Brasília, Brazil ayala@unb.br

More information

Superposition for Fixed Domains. Matthias Horbach and Christoph Weidenbach

Superposition for Fixed Domains. Matthias Horbach and Christoph Weidenbach Superposition for Fixed Domains Matthias Horbach and Christoph Weidenbach MPI I 2009 RG1 005 Oct. 2009 Authors Addresses Matthias Horbach and Christoph Weidenbach Max Planck Institute for Informatics Campus

More information

Cheat Sheet Equational Logic (Spring 2013) Terms. Inductive Construction. Positions: Denoting Subterms TERMS

Cheat Sheet Equational Logic (Spring 2013) Terms. Inductive Construction. Positions: Denoting Subterms TERMS TERMS Cheat Sheet Equational Logic (Spring 2013) The material given here summarizes those notions from the course s textbook [1] that occur frequently. The goal is to have them at hand, as a quick reminder

More information

Lecture Notes on Logic Programming

Lecture Notes on Logic Programming Lecture Notes on Logic Programming 15-317: Constructive Logic Frank Pfenning Lecture 13 October 13, 2009 1 Computation vs Deduction Logic programming is a particular way to approach programming Other paradigms

More information

The Lifting Lemma. Ralf Hinze

The Lifting Lemma. Ralf Hinze The Lifting Lemma Ralf Hinze Computing Laboratory, University of Oxford Wolfson Building, Parks Road, Oxford, OX1 3QD, England ralf.hinze@comlab.ox.ac.uk http://www.comlab.ox.ac.uk/ralf.hinze/ June 2009

More information

Alpha-Structural Recursion and Induction

Alpha-Structural Recursion and Induction Alpha-Structural Recursion and Induction ANDREW M. PITTS Cambridge University, Cambridge, UK Abstract. The nominal approach to abstract syntax deals with the issues of bound names and α-equivalence by

More information

One Context Unification Problems Solvable in Polynomial Time

One Context Unification Problems Solvable in Polynomial Time One Context Unification Problems Solvable in Polynomial Time Adrià Gascón and Ashish Tiwari SRI International, Menlo Park, USA adriagascon@gmailcom, tiwari@cslsricom Manfred Schmidt-Schauss Goethe-Universität,

More information

Murdoch J. Gabbay and Michael J. Gabbay

Murdoch J. Gabbay and Michael J. Gabbay a-logic Murdoch J. Gabbay and Michael J. Gabbay 1 Introduction Mathematics and computer science pervasively use logics formal languages for reasoning in. One of the most common is classical First-Order

More information

A Machine Checked Model of Idempotent MGU Axioms For a List of Equational Constraints

A Machine Checked Model of Idempotent MGU Axioms For a List of Equational Constraints A Machine Checked Model of Idempotent MGU Axioms For a List of Equational Constraints Sunil Kothari, James Caldwell Department of Computer Science, University of Wyoming, USA Machine checked proofs of

More information

λ Slide 1 Content Exercises from last time λ-calculus COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification

λ Slide 1 Content Exercises from last time λ-calculus COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Content COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ Slide 1 Intro & motivation, getting started [1] Foundations & Principles Lambda

More information

Towards Correctness of Program Transformations Through Unification and Critical Pair Computation

Towards Correctness of Program Transformations Through Unification and Critical Pair Computation Towards Correctness of Program Transformations Through Unification and Critical Pair Computation Conrad Rau and Manfred Schmidt-Schauß Institut für Informatik Johann Wolfgang Goethe-Universität Postfach

More information

Type Theory and Constructive Mathematics. Type Theory and Constructive Mathematics Thierry Coquand. University of Gothenburg

Type Theory and Constructive Mathematics. Type Theory and Constructive Mathematics Thierry Coquand. University of Gothenburg Type Theory and Constructive Mathematics Type Theory and Constructive Mathematics Thierry Coquand University of Gothenburg Content An introduction to Voevodsky s Univalent Foundations of Mathematics The

More information

Lecture Notes on Unification

Lecture Notes on Unification Lecture Notes on Unification 15-317: Constructive Logic Frank Pfenning Lecture 17 November 5, 2015 In this lecture we investigate unification further to see that the algorithm from the previous lecture

More information

Lecture Notes on Data Abstraction

Lecture Notes on Data Abstraction Lecture Notes on Data Abstraction 15-814: Types and Programming Languages Frank Pfenning Lecture 14 October 23, 2018 1 Introduction Since we have moved from the pure λ-calculus to functional programming

More information

Limitations of OCAML records

Limitations of OCAML records Limitations of OCAML records The record types must be declared before they are used; a label e can belong to only one record type (otherwise fun x x.e) would have several incompatible types; we cannot

More information

Logic & Computation. Autonomous Systems. Sistemi Autonomi. Andrea Omicini

Logic & Computation. Autonomous Systems. Sistemi Autonomi. Andrea Omicini Logic & Computation Autonomous Systems Sistemi Autonomi Andrea Omicini andrea.omicini@unibo.it Dipartimento di Informatica Scienza e Ingegneria (DISI) Alma Mater Studiorum Università di Bologna Academic

More information

Simply Typed λ-calculus

Simply Typed λ-calculus Simply Typed λ-calculus Lecture 1 Jeremy Dawson The Australian National University Semester 2, 2017 Jeremy Dawson (ANU) COMP4630,Lecture 1 Semester 2, 2017 1 / 23 A Brief History of Type Theory First developed

More information

Nominal Unification from a Higher-Order Perspective

Nominal Unification from a Higher-Order Perspective Nominal Unification from a Higher-Order Perspective Jordi Levy 1 and Mateu Villaret 2 1 Artificial Intelligence Research Institute (IIIA), Spanish Council for Scientific Research (CSIC), Barcelona, Spain

More information

Evaluation Driven Proof-Search in Natural Deduction Calculi for Intuitionistic Propositional Logic

Evaluation Driven Proof-Search in Natural Deduction Calculi for Intuitionistic Propositional Logic Evaluation Driven Proof-Search in Natural Deduction Calculi for Intuitionistic Propositional Logic Mauro Ferrari 1, Camillo Fiorentini 2 1 DiSTA, Univ. degli Studi dell Insubria, Varese, Italy 2 DI, Univ.

More information