Mixed-Strategies for Linear Tabling in Prolog

Similar documents
Linear Tabling Strategies and Optimization Techniques

ProbLog Technology for Inference in a Probabilistic First Order Logic

Chapter 8: Recursion

Paris International Model United Nations

ETH Model United Nations

Title: Local Search Required reading: AIMA, Chapter 4 LWH: Chapters 6, 10, 13 and 14.

WUENIC A Case Study in Rule-based Knowledge Representation and Reasoning

ECE250: Algorithms and Data Structures Trees

Temple Student Government Parliamentary Bylaws

NEW YORK CITY COLLEGE OF TECHNOLOGY The City University of New York

- Secondary Speaker s list

City of Stockton. Legislation Details (With Text)

Lecture 8: Verification and Validation


P olaris Solutions Enterprise

Comparison Sorts. EECS 2011 Prof. J. Elder - 1 -

REGULATION SOMERSET HILLS BOARD OF EDUCATION. TEACHING STAFF MEMBERS R 3144/Page 1 of 8 CERTIFICATION OF TENURE CHARGES

Procedure for the nomination and election of judges, the Prosecutor and Deputy Prosecutors of the International Criminal Court (ICC-ASP/3/Res.

C/40/15 Annex II / Annexe II / Anlage II page 4 / Seite 4 DRAFT LAW FOR THE PROTECTION OF NEW VARIETIES OF PLANTS TITLE I PURPOSE AND SCOPE OF THE LAW

Rules of Procedure of the European Parliament

EXPLANATORY NOTES B I L L. No. 97. An Act to amend The Arbitration Act, 1992

Optimization Strategies

THE FORMER YUGOSLAV REPUBLIC OF MACEDONIA 5

Graph Structurings. 16. How to Structure Large Models - Obligatory Reading. Ø T. Fischer, Jörg Niere, L. Torunski, and Albert Zündorf, 'Story

INTERNATIONAL CONVENTION FOR THE PROTECTION OF NEW VARIETIES OF PLANTS

A New Paradigm for the Study of Corruption in Different Cultures

RULES OF PARLIAMENTARY PROCEDURE OF GENEVA PEACE TALKS ON SYRIA

MEMORANDUM TABLE OF SECTIONS

PLS 540 Environmental Policy and Management Mark T. Imperial. Topic: The Policy Process

GAME THEORY. Analysis of Conflict ROGER B. MYERSON. HARVARD UNIVERSITY PRESS Cambridge, Massachusetts London, England

The Consolidate Patents Act

The Rules of Parliamentary Procedure Model United Nations Turkey Conference Antalya, March 2015

Regional Dialogue and Consultations on Nuclear Non-Proliferation Treaty: Towards the PrepCom Panel I: The NPT State of Play

Tie Breaking in STV. 1 Introduction. 3 The special case of ties with the Meek algorithm. 2 Ties in practice

Search Trees. Chapter 10. CSE 2011 Prof. J. Elder Last Updated: :51 PM

Multilateral Bargaining: Veto Power PS132

17th Annual Southeast Model African Union Columbus State University, November 14-15, 2013

Uninformed search. Lirong Xia

Utility Models Act. Passed RT I 1994, 25, 407 Entry into force

INVESTMENT COMMITTEE CHARTER

PEACE CORPS OPERATIONS PLAN IN THE ABSENCE OF CURRENT YEAR APPROPRIATIONS

RESOLUTION. Resolution No. 1/2000 INTERNATIONAL CIVIL AND COMMERCIAL LITIGATION

Peer-reviewed scientific periodical, focusing on legal and economic issues of antitrust and regulation.

HOUSE OF LORDS GUIDE FOR DEPUTY SPEAKERS AND DEPUTY CHAIRMEN

16. How to Structure Large Models and Programs with Graph Structurings

STUDY GUIDE FOR TEST 2

UNA-USA Rules of Procedures

The character of the crisis: Seeking a way-out for the social majority

IDENTIFYING FAULT-PRONE MODULES IN SOFTWARE FOR DIAGNOSIS AND TREATMENT USING EEPORTERS CLASSIFICATION TREE

UNIVERSITY OF BALTIMORE Discipline Procedures

R 3144 CERTIFICATION OF TENURE CHARGES. B. Filing of Written Charges and Certificate of Determination N.J.A.C. 6A:3-5.1

Section 112 of the HGCR Act is set out below, with the amendments which will be introduced under the LDEDC Act shown in bold:

In the Supreme Court of the United States

Investigations and Compliance Policy and Procedures

Constitution of The Australian National University Computer Science Students Association

External Relations of the European Union

BYLAWS. As amended by the 2018 Annual Convention

Speech by Commissioner Phil Hogan at AVEC General Assembly

Captive generation by CTU under the Electricity Act, contextually prohibited?

NUCLEAR LAWS OF THE REPUBLIC OF KOREA. 1 Nuclear Safety Act. Korea Institute of Nuclear Safety

Decomposition and Complexity of Hereditary History Preserving Bisimulation on BPP

Kiriya Kulkolkarn. Abstract This study provides a picture of immigrant employment in manufacturing of Thailand.

CONSOLIDATED DISCIPLINARY CODE

Patents and Cold Fusion

SUPREME COURT SECOND DIVISION

13. Procedure for the nomination and election of judges, the Prosecutor and Deputy Prosecutors of the International Criminal Court (ICC-ASP/3/Res.

DRAFT RULES FOR SPOKANE COUNTY CONVENTION AND LEGISLATIVE DISTRICT CAUCUSES/SUB-CAUCUSES

Rules of Parliamentary Procedure

Hoboken Public Schools. College Algebra Curriculum

R U L E S of the Court of Arbitration at the Centre for Mediation and Arbitration of Transport Sp. z o.o. (ltd) in Warsaw

Voting Criteria: Majority Criterion Condorcet Criterion Monotonicity Criterion Independence of Irrelevant Alternatives Criterion

STATEMENT OF THE COUNCIL'S REASONS

Council conclusions Iran

China and WTO. Negotiation for WTO membership in a changing environment. Dr. Ma Xiaoye Academy for World Watch, Shanghai

Disciplinary and Dismissal Procedure

DATED [ ] 201[ ] NATIONAL GRID ELECTRICITY TRANSMISSION PLC (1) and [ ] (2) FIRM FREQUENCY RESPONSE AGREEMENT

Political statement from the Socialist parties of the European Community (Brussels, 24 June 1978)

TRADE MARKS ACT, Decision

SEC. 11. FEES FOR PATENT SERVICES.

TENNIS AUSTRALIA DISCIPLINARY POLICY

Procedure for the nomination and election of judges, the Prosecutor and Deputy Prosecutors of the International Criminal Court

THE LOUISIANA SURVEY 2018

RESTRICTED STOCK PROGRAM

Nursing and Midwifery Council: Fitness to Practise Committee. Substantive Hearing 17 December 2018

North Atlantic Treaty Organization. Handbook

University of Houston Student Government Association Election Code. Updated February 17, rd Admnistration. Page 1 of 22

Social work and its public mandate Walter Lorenz Charles University Prague (Free University of Bozen)

Meta Programming (8A) Young W. Lim 3/10/14

INTRODUCTION TO READING & BRIEFING CASES AND OUTLINING

SUSPENSION AND EXPULSION

Learning and Visualizing Political Issues from Voting Records Erik Goldman, Evan Cox, Mikhail Kerzhner. Abstract

Australian Meat and Live-stock Industry Act 1997

SERVICE CONTRACT NOTICE Provision of court reporting and transcription services to the Kosovo Specialist Chambers (KSC) The Hague The Netherlands

POLI 359 Public Policy Making

The Consolidate Utility Models Act 1)

CITY OF PENSACOLA CITY COUNCIL RULES AND PROCEDURES

Course: Economic Policy with an Emphasis on Tax Policy

Logic-based Argumentation Systems: An overview

Extended Abstract: The Swing Voter s Curse in Social Networks

Unit 2 Learning Objectives

Transcription:

Mixed-Strategies for Linear Tabling in Prolog CRACS & INESC-Porto LA Faculty of Sciences, University of Porto, Portugal miguel-areias@dcc.fc.up.pt ricroc@dcc.fc.up.pt INForum-CoRTA 2010, Braga, Portugal, September 2010

Prolog and SLD Resolution Prolog systems are known to have good performances and flexibility, but they are based on SLD resolution, which limits the potential of the Logic Programing paradigm. SLD resolution cannot deal properly with the following situations: Positive Infinite Cycles (insufficient expressiveness) Negative Infinite Cycles (inconsistence) Redundant Computations (inefficiency) INForum-CoRTA 2010, Braga, Portugal, September 2010 1

SLD Resolution: Infinite Cycles path(x,z) :- path(x,y), edge(y,z). path(x,z) :- edge(x,z). edge(1,2). edge(2,1). path(1,z)

SLD Resolution: Infinite Cycles path(x,z) :- path(x,y), edge(y,z). path(x,z) :- edge(x,z). edge(1,2). edge(2,1). path(1,z) path(1,y), edge(y,z) Infinite Cycle

SLD Resolution: Infinite Cycles path(x,z) :- path(x,y), edge(x,y), edge(y,z). path(y,z). path(x,z) :- edge(x,z). edge(1,2). edge(2,1). path(1,z) path(1,y), edge(y,z) Infinite Cycle

SLD Resolution: Infinite Cycles path(x,z) :- path(x,y), edge(x,y), edge(y,z). path(y,z). path(x,z) :- edge(x,z). edge(1,2). edge(2,1). path(1,z) path(1,y), edge(1,y), edge(y,z) path(y,z) Infinite path(2,z) Cycle edge(2,y), path(y,z) path(1,z) Infinite Cycle INForum-CoRTA 2010, Braga, Portugal, September 2010 2

Tabling in Logic Programming Tabling is an implementation technique that overcomes some of the limitations of SLD resolution. Implementations of tabling are currently available in systems like XSB Prolog, Yap Prolog, B-Prolog, ALS-Prolog, Mercury and more recently Ciao Prolog.

Tabling in Logic Programming Tabling is an implementation technique that overcomes some of the limitations of SLD resolution. Implementations of tabling are currently available in systems like XSB Prolog, Yap Prolog, B-Prolog, ALS-Prolog, Mercury and more recently Ciao Prolog. In these implementations, we can distinguish two main categories of tabling mechanisms: Suspension-Based Tabling: can be seen as a sequence of sub-computations that can be suspended and later resumed, when necessary, to compute fixpoints (XSB Prolog, Yap Prolog, Mercury and Ciao Prolog). Linear Tabling: can be seen as a single execution tree where tabled subgoals use iterative computations, without requiring suspension and resumption, to compute fix-points (B-Prolog and ALS Prolog). INForum-CoRTA 2010, Braga, Portugal, September 2010 3

Linear Tabling Arguably, the two most well-known linear tabling strategies are: DRE (Dynamic Reordering of Execution): repeated calls, the followers, execute from the backtracking point of the former call. A follower is then repeatedly re-executed, until all the available answers and clauses have been exhausted, that is, until a fix-point is reached (B-Prolog). DRA (Dynamic Reordering of Alternatives): tables not only the answers to tabled subgoals, but also the alternatives leading to repeated calls, the looping alternatives. It then uses the looping alternatives to repeatedly recompute them until reaching a fix-point (ALS Prolog).

Linear Tabling Arguably, the two most well-known linear tabling strategies are: DRE (Dynamic Reordering of Execution): repeated calls, the followers, execute from the backtracking point of the former call. A follower is then repeatedly re-executed, until all the available answers and clauses have been exhausted, that is, until a fix-point is reached (B-Prolog). DRA (Dynamic Reordering of Alternatives): tables not only the answers to tabled subgoals, but also the alternatives leading to repeated calls, the looping alternatives. It then uses the looping alternatives to repeatedly recompute them until reaching a fix-point (ALS Prolog). In this work, we propose a new linear tabling strategy: DRS (Dynamic Reordering of Solutions): it can be seen as a variant of the DRA strategy, but applied to the consumption of solutions. The key idea is to memorize the solutions leading to consumer calls, the looping solutions, and use them as the DRA strategy uses the looping alternatives (Yap Prolog). INForum-CoRTA 2010, Braga, Portugal, September 2010 4

Our Goal Implement a framework on top of the Yap Prolog system, that supports the combination of the three strategies. Analyze the advantages and weaknesses of each strategy, when used solely or combined with the others. INForum-CoRTA 2010, Braga, Portugal, September 2010 5

Standard Evaluation Example :- table a/1, b/1. a(x):- b(x). a(2). b(x):- a(x). b(1). (c1) (c2) (c3) (c4) Call 1: a(x) Solutions 6: X=1 7: X=2 4: X=1 12: X=2 6: X=1 c1 c2 7: X=2 15: X=1 1: a(x) c1 9: b(x) c2 16: X=2 8,18,28: fix-point check 17: X=2 19-27:... 5: fix-point check 9: b(x) 14: fix-point check c3 c4 c3 c4 3: a(x) 4: X=1 10: a(x) 13: X=1 11: X=1 12: X=2 INForum-CoRTA 2010, Braga, Portugal, September 2010 6

DRA Evaluation Example :- table a/1, b/1. Call Solutions Looping Alternatives a(x):- b(x). a(2). b(x):- a(x). b(1). (c1) (c2) (c3) (c4) 1: a(x) 6: X=1 7: X=2 4: X=1 12: X=2 3: c1 3: c3 6: X=1 c1 c2 7: X=2 14: X=1 1: a(x) c1 9: b(x) c2 15: X=2 8,16,24: fix-point check 17-23:... 5: fix-point check 9: b(x) 13: fix-point check c3 c4 c3 c4 3: a(x) 4: X=1 10: a(x) 11: X=1 12: X=2 INForum-CoRTA 2010, Braga, Portugal, September 2010 7

DRS Evaluation Example :- table a/1, b/1. a(x):- b(x). a(2). b(x):- a(x). b(1). (c1) (c2) (c3) (c4) Call 1: a(x) Solutions 6: X=1 7: X=2 4: X=1 12: X=2 Looping Solutions c1 c2 1: a(x) c1 c2 8,17,25: fix-point check 7: X=2 9: b(x) 16: X=2 18-24:... 6: X=1 15: X=2 5: fix-point check 9: b(x) 14: fix-point check c3 c4 c3 c4 3: a(x) 4: X=1 10: a(x) 13: X=1 11: X=1 12: X=2 INForum-CoRTA 2010, Braga, Portugal, September 2010 8

DRE Evaluation Example :- table a/1, b/1. Call Solutions a(x):- b(x). a(2). b(x):- a(x). b(1). (c1) (c2) (c3) (c4) 1: a(x) 4: X=2 9: X=1 5: X=2 6: X=1 1: a(x) 10,19: fix-point check 3: a(x) c1 c2 11-18:... 4: X=2 8: X=2 9: X=1 7: fix-point check c3 c4 3: a(x) 6: X=1 5: X=2 INForum-CoRTA 2010, Braga, Portugal, September 2010 9

Experimental Results Strategy Pyramid Cycle Grid 1000 2000 3000 1000 2000 3000 20 30 40 Path Recursive Clause First DRE 1.06 0.99 0.99 0.99 0.97 1.01 1.26 1.02 1.17 DRA 1.61 1.60 1.61 1.28 1.22 1.25 1.55 1.15 1.20 DRS 0.99 0.99 1.02 1.26 1.17 1.27 1.67 1.27 1.38 DRE+DRA 1.66 1.62 1.59 1.29 1.28 1.27 1.25 1.15 1.25 DRE+DRS 1.03 1.00 1.00 1.30 1.17 1.28 1.44 1.28 1.37 DRA+DRS 1.63 1.59 1.55 1.72 1.64 1.64 1.94 1.45 1.51 DRE+DRA+DRS 1.65 1.57 1.55 1.70 1.65 1.62 1.61 1.26 1.44 Path Recursive Clause Last DRE 0.98 1.00 0.88 0.94 0.95 1.04 0.83 0.99 0.99 DRA 1.60 1.59 1.58 1.18 1.20 1.22 1.08 1.09 1.07 DRS 0.99 0.98 0.99 1.14 1.18 1.25 1.20 1.20 1.21 DRE+DRA 1.58 1.66 1.63 1.22 1.24 1.22 1.12 1.10 1.07 DRE+DRS 1.00 1.01 1.01 1.22 1.23 1.23 0.95 1.14 1.14 DRA+DRS 1.63 1.64 1.62 1.56 1.59 1.69 1.40 1.32 1.32 DRE+DRA+DRS 1.59 1.57 1.56 1.61 1.55 1.60 1.36 1.33 1.30 INForum-CoRTA 2010, Braga, Portugal, September 2010 10

Conclusions and Further Work We have presented a new framework that integrates all possible combinations of the already existent linear tabling strategies DRA and DRE and the new strategy DRS. Our experiments for DRS strategy showed that the strategy of avoiding the consumption of non-looping solutions in re-evaluation rounds can be quite effective for programs that can benefit from it, with insignificant costs for the other programs. Further work will include exploring the impact of applying our strategies to more complex problems, seeking real-world experimental results allowing us to improve and consolidate our current implementation. INForum-CoRTA 2010, Braga, Portugal, September 2010 11