August 13, 2019 [Aalto University, Helsinki] Improving Constraint Logic Programming and BIM-Spatial Reasoning using CLP ın Arias 1 , 2 Joaqu´ 1 IMDEA Software Institute, 2 Universidad Polit´ ecnica de Madrid madrid institute for advanced studies in software development technologies
www.software.imdea.org Outline. • About me. • Introduction to (Constraint) Logic Programming (CLP). • Improving CLP: • TCLP = tabling + Constraints. • Incremental evaluation of aggregates. • Implementation of an Abstract Interpreter Algorithm. • s(CAPS) = ASP + Constraints - Grounding. • Modelling and reasoning in Event Calculus. • Spatial reasoning in Building Information Modelling (BIM) using CLP . madrid institute for advanced studies in software development technologies 1 / 17
www.software.imdea.org About me. Founded 1971 Founded 2006 Founded 2008 Faculty members 2887 Faculty members 19 Partners 195 Research groups 200 Postdoctoral researchers 16 Start-ups supported 280 I&E students 1 PhD students 1900 Programmers 3 170 Master students 1 Grade/Master students 26738 Research assistants 26 1700 Sport groups 18 Interns 29 1 since its beginning madrid institute for advanced studies in software development technologies 2 / 17
www.software.imdea.org About me. 1993-2002 Architect 2013-2014 Intern 2015- I&E student 2014- Research Assistant 1999-2000 RWTH-Aachen Summer’19 VisuaLynk Oy 2011-2015 Computer Science Advisor: Dr. Manuel Carro 2015- PhD Student in DSSC Summer’17 UTD-Dallas Summer’19 A!-Helsinki madrid institute for advanced studies in software development technologies 2 / 17
www.software.imdea.org About me. 1993-2002 Architect 2013-2014 Intern 2015- I&E student 2014- Research Assistant 1999-2000 RWTH-Aachen Summer’19 VisuaLynk Oy 2011-2015 Computer Science Advisor: Dr. Manuel Carro 2015- PhD Student in DSSC 2010 & 2015 Summer’17 UTD-Dallas I love biking Summer’19 A!-Helsinki madrid institute for advanced studies in software development technologies 2 / 17
www.software.imdea.org (Constraint) Logic Programming? madrid institute for advanced studies in software development technologies 3 / 17
www.software.imdea.org (Constraint) Logic Programming? madrid institute for advanced studies in software development technologies 3 / 17
www.software.imdea.org (Constraint) Logic Programming? • Is based on 1 st order logic. ∀ x . man ( x ) → mortal ( x ) madrid institute for advanced studies in software development technologies 3 / 17
www.software.imdea.org (Constraint) Logic Programming? • Is based on 1 st order logic. ∀ x . man ( x ) → mortal ( x ) • You write logical specifications of searches and get them executed. mortal(X) :- man(X). % X is mortal if X is a man. 1 man(socrates). % Socrates is a man. 2 ?- mortal(socrates). % Is Socrates mortal? madrid institute for advanced studies in software development technologies 3 / 17
www.software.imdea.org (Constraint) Logic Programming? • Is based on 1 st order logic. ∀ x . man ( x ) → mortal ( x ) • You write logical specifications of searches and get them executed. mortal(X) :- man(X). % X is mortal if X is a man. 1 man(socrates). % Socrates is a man. 2 ?- mortal(socrates). % Is Socrates mortal? • Passive vs Active Constraints % Search and filter % Prune the search ?- age(X,A), A > 18. ?- A #> 18, age(X,A). madrid institute for advanced studies in software development technologies 3 / 17
www.software.imdea.org (Constraint) Logic Programming? % append(X,Y,Z) true if X concatenated with Y is Z 1 append([X | Xs], Ys, [X | Zs]) :- append(Xs, Ys, Zs). 2 append( [], Ys, Ys). 3 ?- append([1],[2,3], X). X = [1,2,3] ? madrid institute for advanced studies in software development technologies 4 / 17
www.software.imdea.org (Constraint) Logic Programming? % append(X,Y,Z) true if X concatenated with Y is Z ?- append(X, Y, [1,2,3]). 1 append([X | Xs], Ys, [X | Zs]) :- append(Xs, Ys, Zs). 2 append( [], Ys, Ys). 3 ?- append([1],[2,3], X). X = [1,2,3] ? madrid institute for advanced studies in software development technologies 4 / 17
www.software.imdea.org (Constraint) Logic Programming? % append(X,Y,Z) true if X concatenated with Y is Z ?- append(X, Y, [1,2,3]). 1 append([X | Xs], Ys, [X | Zs]) :- append(Xs, Ys, Zs). X = [], Y = [1,2,3] ?; 2 append( [], Ys, Ys). X = [1], Y = [2,3] ?; 3 X = [1,2], Y = [3] ?; ?- append([1],[2,3], X). X = [1,2,3], Y = [] ? X = [1,2,3] ? madrid institute for advanced studies in software development technologies 4 / 17
www.software.imdea.org (Constraint) Logic Programming? % append(X,Y,Z) true if X concatenated with Y is Z ?- append(X, Y, [1,2,3]). 1 append([X | Xs], Ys, [X | Zs]) :- append(Xs, Ys, Zs). X = [], Y = [1,2,3] ?; 2 append( [], Ys, Ys). X = [1], Y = [2,3] ?; 3 X = [1,2], Y = [3] ?; ?- append([1],[2,3], X). X = [1,2,3], Y = [] ? X = [1,2,3] ? When the Top-Down execution loops due to: • Left recursion: path(A,B) :- path(A,Z), edge(Z,B). 1 path(A,B) :- edge(A,B). 2 • Non-stratified negation: p(X) :- not q(X). 1 q(X) :- not p(X). 2 madrid institute for advanced studies in software development technologies 4 / 17
www.software.imdea.org (Constraint) Logic Programming? % append(X,Y,Z) true if X concatenated with Y is Z ?- append(X, Y, [1,2,3]). 1 append([X | Xs], Ys, [X | Zs]) :- append(Xs, Ys, Zs). X = [], Y = [1,2,3] ?; 2 append( [], Ys, Ys). X = [1], Y = [2,3] ?; 3 X = [1,2], Y = [3] ?; ?- append([1],[2,3], X). X = [1,2,3], Y = [] ? X = [1,2,3] ? When the Top-Down execution loops due to: Solution: • Tabling [17; 15; 21] • Left recursion: path(A,B) :- path(A,Z), edge(Z,B). • Suspends repeated calls & reuses answers. 1 path(A,B) :- edge(A,B). 2 • Improves termination and efficiency. • Non-stratified negation: • s(ASP) [12; 13] p(X) :- not q(X). 1 • Goal directed (without grounding). q(X) :- not p(X). 2 • Stable model semantics & constructive negation. madrid institute for advanced studies in software development technologies 4 / 17
www.software.imdea.org Mod TCLP . Modular TCLP : Modular integration of tabling + Constraints [Arias and Carro 2016, 2019a] . • Adding constraint variant check is extended with entailment check. p(X) :- X #> Y, p(Y). 1 p(0). 2 ?- p(A). • Also more particular calls suspend p(Y){Y < X} entails p(X) . • Termination guaranteed for compact constraint domains [18] . • Previous proposals not fully use entailment [16; 9] or not modular [8] . madrid institute for advanced studies in software development technologies 5 / 17
www.software.imdea.org Mod TCLP . Modular TCLP : Modular integration of tabling + Constraints [Arias and Carro 2016, 2019a] . • Adding constraint variant check is extended with entailment check. p(X) :- X #> Y, p(Y). 1 p(0). 2 ?- p(A). • Also more particular calls suspend p(Y){Y < X} entails p(X) . • Termination guaranteed for compact constraint domains [18] . • Previous proposals not fully use entailment [16; 9] or not modular [8] . Additionally: • Answers checked for entailment: only more general answers kept. • Less resumptions: speedup. madrid institute for advanced studies in software development technologies 5 / 17
www.software.imdea.org Mod TCLP . Modular TCLP : Modular integration of tabling + Constraints [Arias and Carro 2016, 2019a] . • Adding constraint variant check is extended with entailment check. p(X) :- X #> Y, p(Y). 1 p(0). 2 ?- p(A). • Also more particular calls suspend p(Y){Y < X} entails p(X) . • Termination guaranteed for compact constraint domains [18] . • Previous proposals not fully use entailment [16; 9] or not modular [8] . Additionally: • Answers checked for entailment: only more general answers kept. • Less resumptions: speedup. • Termination guaranteed for programs that generate compact constraint stores [Arias & Carro] . madrid institute for advanced studies in software development technologies 5 / 17
www.software.imdea.org Mod TCLP . Modular TCLP : Modular integration of tabling + Constraints [Arias and Carro 2016, 2019a] . • Adding constraint variant check is extended with entailment check. p(X) :- X #> Y, p(Y). 1 p(0). 2 ?- p(A). • Also more particular calls suspend p(Y){Y < X} entails p(X) . • Termination guaranteed for compact constraint domains [18] . • Previous proposals not fully use entailment [16; 9] or not modular [8] . Additionally: • Answers checked for entailment: only more general answers kept. • Less resumptions: speedup. • Termination guaranteed for programs that generate compact constraint stores [Arias & Carro] . • (Involved) implementation available in Ciao Prolog. http://www.ciao-lang.org madrid institute for advanced studies in software development technologies 5 / 17
www.software.imdea.org Mod TCLP . Termination comparison: Find nodes in a weighted graph within a distance K from each other. (using comparable –very similar– programs). n 1 dist(A,B,D) :- D1 #> 0, D2 #> 0, D #= D1+D2, 1 dist(A,Z,D1), edge(Z,B,D2). 2 dist(A,B,D) :- edge(A,B,D). 3 ?- D #< K, dist(a,b,D). 2 Graph LP CLP TAB TCLP Without cycles Left recursion x x � � 3 Right recursion � � � � With cycles Left recursion x x x � Right recursion x � x � 4 madrid institute for advanced studies in software development technologies 6 / 17
Recommend
More recommend