├── .gitignore ├── .gitlab-ci.yml ├── ATTIC ├── WORK_IN_PROGRESS ├── max.lp ├── misc_programs │ ├── Makefile │ ├── count_asp.pl │ ├── hanoi_for_simple_minds.pl │ ├── hanoi_for_simple_minds_2.pl │ ├── hanoi_for_simple_minds_3.pl │ ├── new_hanoi_2.pl │ └── new_hanoi_3.pl ├── scripts │ ├── diseq_oracle.pl │ └── refactor.pl ├── test_findall │ ├── call.pl │ └── findall01.pl ├── test_forall │ ├── README.txt │ ├── diseq01-ok.pl │ ├── diseq02-ok.pl │ ├── output-test05-ok.txt │ ├── test01-ok.pl │ ├── test02-fail.pl │ ├── test03-fail.pl │ └── test05-ok.pl ├── test_justification │ ├── fever3.pl │ ├── fever4.html │ ├── fever4.pl │ ├── output-fever3.pl │ └── output-fever4.pl ├── test_sasp │ ├── abdbirds.pl │ ├── birds.pl │ ├── birds2.pl │ ├── classic_negation.pl │ ├── classical_neg_entail.pl │ ├── cofailure.pl │ ├── directive_test.pl │ ├── errtest.pl │ ├── family.pl │ ├── gpa.pl │ ├── graph.pl │ ├── hamcycle.pl │ ├── hamcycle2.pl │ ├── hamcycle_two.pl │ ├── hanoi.pl │ ├── hanoi_7.pl │ ├── hanoi_clp.pl │ ├── left-rec-succ_BAD.pl │ ├── left.pl │ ├── lion.pl │ ├── list.pl │ ├── loop_pos.pl │ ├── loop_succ_pos.pl │ ├── loopvar.pl │ ├── loopvar2.pl │ ├── member.pl │ ├── multitest.pl │ ├── natnum.pl │ ├── oddloop_odd.pl │ ├── paperexample.pl │ ├── path.pl │ ├── path_loop.pl │ ├── pos_loop2_simple.pl │ ├── pos_loop_pass_simple.pl │ ├── pos_loop_simple.pl │ ├── pq_asp.pl │ ├── pq_loop.pl │ ├── pq_loop_b.pl │ ├── queens.pl │ ├── queens_hide.pl │ ├── queens_hide_d0.pl │ ├── queens_old.pl │ ├── reflexive.pl │ ├── schedule.pl │ ├── simple.pl │ ├── struct.pl │ ├── succ.pl │ ├── test1.pl │ ├── test10.pl │ ├── test11.pl │ ├── test12.pl │ ├── test13.pl │ ├── test14.pl │ ├── test15.pl │ ├── test16.pl │ ├── test17.pl │ ├── test18.pl │ ├── test19.pl │ ├── test2.pl │ ├── test20.pl │ ├── test21.pl │ ├── test3.pl │ ├── test4.pl │ ├── test5.pl │ ├── test6.pl │ ├── test7.pl │ ├── test8.pl │ ├── test9.pl │ ├── varcon.pl │ └── vars_optional.pl ├── test_scasp │ ├── ball_asp.pl │ ├── ball_tclpq.pl │ ├── block_asp.pl │ ├── clingcon_example.pl │ ├── cross_train_Pontelli_97.pl │ ├── cross_train_Pontelli_97_execution.txt │ ├── ezsmt_light.pl │ ├── s.pl │ ├── weight_seq │ │ ├── instances │ │ │ ├── 01-weight_assignment_tree-654-0.asp │ │ │ ├── 02-weight_assignment_tree-687-0.asp │ │ │ ├── 03-weight_assignment_tree-742-0.asp │ │ │ ├── 04-weight_assignment_tree-612-0.asp │ │ │ ├── 05-weight_assignment_tree-579-0.asp │ │ │ ├── 06-weight_assignment_tree-560-0.asp │ │ │ ├── 07-weight_assignment_tree-547-0.asp │ │ │ ├── 08-weight_assignment_tree-806-0.asp │ │ │ ├── 09-weight_assignment_tree-778-0.asp │ │ │ ├── 10-weight_assignment_tree-938-0.asp │ │ │ ├── 11-weight_assignment_tree-934-0.asp │ │ │ ├── 12-weight_assignment_tree-918-0.asp │ │ │ ├── 13-weight_assignment_tree-901-0.asp │ │ │ ├── 14-weight_assignment_tree-1070-0.asp │ │ │ ├── 15-weight_assignment_tree-868-0.asp │ │ │ ├── 16-weight_assignment_tree-862-0.asp │ │ │ ├── 17-weight_assignment_tree-854-0.asp │ │ │ ├── 18-weight_assignment_tree-851-0.asp │ │ │ ├── 19-weight_assignment_tree-833-0.asp │ │ │ ├── 20-weight_assignment_tree-997-0.asp │ │ │ ├── 21-weight_assignment_tree-545-0.asp │ │ │ ├── 22-weight_assignment_tree-539-0.asp │ │ │ ├── 23-weight_assignment_tree-891-0.asp │ │ │ ├── 24-weight_assignment_tree-814-0.asp │ │ │ ├── 25-weight_assignment_tree-782-0.asp │ │ │ ├── 26-weight_assignment_tree-764-0.asp │ │ │ ├── 27-weight_assignment_tree-755-0.asp │ │ │ ├── 28-weight_assignment_tree-646-0.asp │ │ │ ├── 29-weight_assignment_tree-644-0.asp │ │ │ ├── 30-weight_assignment_tree-631-0.asp │ │ │ ├── 31-weight_assignment_tree-863-0.asp │ │ │ ├── 32-weight_assignment_tree-812-0.asp │ │ │ ├── 33-weight_assignment_tree-810-0.asp │ │ │ ├── 34-weight_assignment_tree-809-0.asp │ │ │ ├── 35-weight_assignment_tree-805-0.asp │ │ │ ├── 36-weight_assignment_tree-802-0.asp │ │ │ ├── 37-weight_assignment_tree-797-0.asp │ │ │ ├── 38-weight_assignment_tree-879-0.asp │ │ │ ├── 39-weight_assignment_tree-953-0.asp │ │ │ ├── 40-weight_assignment_tree-944-0.asp │ │ │ ├── 41-weight_assignment_tree-718-0.asp │ │ │ ├── 42-weight_assignment_tree-367-0.asp │ │ │ ├── 43-weight_assignment_tree-645-0.asp │ │ │ ├── 44-weight_assignment_tree-365-0.asp │ │ │ ├── 45-weight_assignment_tree-312-0.asp │ │ │ ├── 46-weight_assignment_tree-764-0.asp │ │ │ ├── 47-weight_assignment_tree-474-0.asp │ │ │ ├── 48-weight_assignment_tree-285-0.asp │ │ │ ├── 49-weight_assignment_tree-272-0.asp │ │ │ ├── 50-weight_assignment_tree-430-0.asp │ │ │ ├── 51-weight_assignment_tree-2133-0.asp │ │ │ ├── 52-weight_assignment_tree-1777-0.asp │ │ │ ├── 53-weight_assignment_tree-1685-0.asp │ │ │ ├── 54-weight_assignment_tree-1642-0.asp │ │ │ ├── 55-weight_assignment_tree-1620-0.asp │ │ │ ├── 56-weight_assignment_tree-1735-0.asp │ │ │ ├── 57-weight_assignment_tree-1694-0.asp │ │ │ ├── 58-weight_assignment_tree-1647-0.asp │ │ │ ├── 59-weight_assignment_tree-1595-0.asp │ │ │ ├── 60-weight_assignment_tree-1588-0.asp │ │ │ ├── 61-weight_assignment_tree-1542-0.asp │ │ │ └── 62-weight_assignment_tree-2102-0.asp │ │ ├── select_instance.asp │ │ ├── select_instance.pl │ │ ├── weight_seq_clp.pl │ │ ├── weight_seq_ezsmt.pl │ │ ├── weight_seq_scasp.pl │ │ └── weight_seq_tclp.pl │ └── zhou_birds.pl └── test_tabling │ ├── edge.pl │ ├── notp.pl │ ├── notpq.pl │ ├── output01.txt │ ├── p.pl │ ├── path.pl │ ├── pq.pl │ └── prop.pl ├── LICENSE ├── Makefile ├── Manifest └── Manifest.pl ├── README.md ├── VERSION ├── doc ├── SETTINGS.pl ├── Tricks.md ├── scasp_man.pl ├── user_installation.pl └── user_usage.pl ├── examples ├── benchmark_EventCalculus │ └── lopstr19 │ │ ├── README.md │ │ ├── aux-sasp │ │ ├── bec_light_sasp_discrete_0.25.pl │ │ ├── bec_light_sasp_discrete_0.5.pl │ │ ├── bec_theory_discrete.pl │ │ └── go_time_bec_light_sasp_discrete │ │ ├── event-calculus │ │ ├── bec_theory.pl │ │ ├── example-light │ │ │ ├── bec_light_01.pl │ │ │ ├── bec_light_02.pl │ │ │ ├── bec_light_03_inconsistent.pl │ │ │ └── bec_light_04_theinconsistencedonothappens.pl │ │ ├── example-tap │ │ │ ├── bec_tap_01_overflow.pl │ │ │ ├── bec_tap_02_no_overflow.pl │ │ │ ├── bec_tap_03_two_models.pl │ │ │ └── bec_tap_04_abducible_infer_event_time.pl │ │ └── scripts │ │ │ ├── go_bec_light_01 │ │ │ ├── go_bec_light_02_03_04 │ │ │ ├── go_bec_tap_01_overflow │ │ │ ├── go_bec_tap_02_no_overflow │ │ │ ├── go_bec_tap_03_two_models │ │ │ ├── go_bec_tap_04_abducible_infer_event_time │ │ │ └── go_time_bec_light_01 │ │ └── sCASP-clingo │ │ ├── bec_theory.pl │ │ ├── light │ │ ├── bec_light_01.pl │ │ ├── bec_query01.pl │ │ ├── bec_query02.pl │ │ ├── bec_query03.pl │ │ ├── bec_query0x.pl │ │ ├── light-tree.html │ │ ├── light_01.clingo │ │ ├── query00.clingo │ │ ├── query01.clingo │ │ ├── query02.clingo │ │ └── query03.clingo │ │ ├── scripts │ │ ├── go_light │ │ ├── go_vessel │ │ ├── output_light.txt │ │ └── output_vessel.txt │ │ ├── theory.clingo │ │ ├── theory.e │ │ └── vessel │ │ ├── bec_queries.pl │ │ ├── bec_query01.pl │ │ ├── bec_vessel_01.pl │ │ ├── query00.clingo │ │ ├── query01.clingo │ │ ├── query02.clingo │ │ └── vessel_01.clingo ├── benchmark_iclp18 │ ├── sasp_vs_scasp │ │ ├── BENCHMARK-sasp-scasp.txt │ │ ├── Makefile │ │ ├── hamcycle_one.pl │ │ ├── hamcycle_two.pl │ │ ├── hanoi_8.pl │ │ └── queens_4.pl │ ├── stream_data_reasoning │ │ ├── README.md │ │ ├── new_stream.pl │ │ └── stream_reasoning.pl │ ├── towers_hanoi │ │ ├── Makefile │ │ ├── README.md │ │ ├── hanoi_min.pl │ │ ├── hanoi_scasp_7.pl │ │ ├── hanoi_scasp_8.pl │ │ ├── hanoi_scasp_9.pl │ │ ├── new_hanoi.pl │ │ ├── toh_incremental_7.pl │ │ ├── toh_incremental_8.pl │ │ ├── toh_incremental_9.pl │ │ ├── toh_standard_5.pl │ │ ├── toh_standard_6.pl │ │ ├── toh_standard_7.pl │ │ ├── toh_standard_8.pl │ │ └── toh_standard_9.pl │ ├── traveling_salesman │ │ ├── README.md │ │ ├── hamiltonian_asp.pl │ │ └── hamiltonian_scasp.pl │ └── yale_shooting_scenario │ │ ├── README.md │ │ ├── yale_shooting_casp.pl │ │ ├── yale_shooting_casp_v2.pl │ │ └── yale_shooting_clingoLD.pl ├── birds.html ├── birds.pl ├── classic_negation_incostistent.pl ├── compiled │ ├── README │ ├── birds_compiled.pl │ └── birds_compiled_raw.pl ├── dyncall │ ├── birds.pl │ ├── http.pl │ ├── pas │ │ ├── PAS_case.pl │ │ ├── PAS_guide.pl │ │ ├── PAS_patient.pl │ │ ├── PAS_rules.pl │ │ ├── PAS_server.pl │ │ └── README.md │ └── solve_findall.pl ├── embed │ ├── birds.pl │ ├── pas.pl │ └── pq.pl ├── entail_loop.pl ├── family.pl ├── hamcycle.pl ├── hamcycle_two.pl ├── hanoi.pl ├── hanoi_7.pl ├── min_model.pl ├── pq.pl ├── queens.pl └── rps.pl ├── pack.pl ├── prolog ├── scasp.pl └── scasp │ ├── call_graph.pl │ ├── clp │ ├── call_stack.pl │ ├── clpq.pl │ └── disequality.pl │ ├── common.pl │ ├── comp_duals.pl │ ├── compile.pl │ ├── coverage.pl │ ├── dyncall.pl │ ├── embed.pl │ ├── html.pl │ ├── html │ ├── html_head.pl │ ├── html_tail.pl │ └── jquery_tree.pl │ ├── html_text.pl │ ├── human.pl │ ├── input.pl │ ├── json.pl │ ├── lang │ ├── en.pl │ └── nl.pl │ ├── listing.pl │ ├── load_compiled.pl │ ├── main.pl │ ├── messages.pl │ ├── model.pl │ ├── modules.pl │ ├── nmr_check.pl │ ├── ops.pl │ ├── options.pl │ ├── output.pl │ ├── pr_rules.pl │ ├── predicates.pl │ ├── program.pl │ ├── prolog.pl │ ├── solve.pl │ ├── source_ref.pl │ ├── stack.pl │ ├── swish.pl │ ├── variables.pl │ ├── verbose.pl │ └── web │ ├── css │ └── scasp.css │ └── js │ └── scasp.js ├── scripts ├── newversion └── publish └── test ├── all_programs ├── abdbirds.pl ├── bec_light.pass ├── bec_light.pl ├── bec_loan.pl ├── bec_tap_01_overflow.pl ├── bec_tap_02_no_overflow.pl ├── bec_tap_03_two_models.pl ├── bec_tap_04_abducible_infer_event_time.pl ├── bec_theory.incl ├── birds.pass ├── birds.pl ├── citizenshiptrust-scasp.pl ├── classic_negation_inconstistent.pass ├── classic_negation_inconstistent.pl ├── classic_negation_incostistent.pl ├── clpq_equality.pl ├── criminaljustice-scasp.pl ├── cross_train_Pontelli_97_execution.txt ├── dcc │ ├── hamilton_c.pass │ └── hamilton_c.pl ├── family-le-scasp.pl ├── family.pass ├── family.pl ├── forall_arity.pass ├── forall_arity.pl ├── gpa.pl ├── hamcycle.pass ├── hamcycle.pl ├── hamcycle2.pl ├── hamcycle_two.pass ├── hamcycle_two.pl ├── hanoi.pass ├── hanoi.pl ├── hanoi_7.pl ├── hanoi_scasp_7.pl ├── haplotype.pl ├── impossibleancestor-scasp.pl ├── isdapermissioncorrected-scasp.pl ├── itispermittedthat-scasp.pl ├── left-rec-succ_BAD.pl ├── lion.pl ├── list-scasp.pl ├── loanwithcure-scasp.pl ├── loop_pos.pl ├── loop_succ_pos.pl ├── loopvar.pl ├── loopvar2.pl ├── min_model.pl ├── minicontract-scasp.pl ├── natnum.pl ├── obligation-scasp.pl ├── path_loop.pl ├── pq.pass ├── pq.pl ├── queens.pass ├── queens.pl ├── queens_old.pl ├── rat.pass ├── rat.pl ├── sasp │ ├── abdbirds.pass │ ├── abdbirds.pl │ ├── gpa.pass │ ├── gpa.pl │ ├── hamcycle.pass │ ├── hamcycle.pl │ ├── hamcycle2.pass │ ├── hamcycle2.pl │ ├── hamcycle_two.pass │ ├── hamcycle_two.pl │ ├── hanoi_7.pass │ ├── hanoi_7.pl │ ├── left-rec-succ_BAD.pass │ ├── left-rec-succ_BAD.pl │ ├── lion.pass │ ├── lion.pl │ ├── loop_pos.pass │ ├── loop_pos.pl │ ├── loop_succ_pos.pass │ ├── loop_succ_pos.pl │ ├── loopvar.pass │ ├── loopvar.pl │ ├── loopvar2.pass │ ├── loopvar2.pl │ ├── natnum.pass │ ├── natnum.pl │ ├── path_loop.pass │ ├── path_loop.pl │ ├── queens_old.pass │ └── queens_old.pl ├── simpleRPS-scasp.pl ├── solve_findall.pass ├── solve_findall.pl ├── subset-scasp.pl ├── turingcomplete-scasp.pl ├── vars.pass └── vars.pl ├── bench.sh ├── diff.pl ├── le_programs ├── bec_theory.incl ├── citizenshiptrust-scasp.pl ├── criminaljustice-scasp.pl ├── escrow-scasp.jump ├── family-le-scasp.pl ├── impossibleancestor-scasp.pl ├── isdapermissioncorrected-scasp.pl ├── itispermittedthat-scasp.pl ├── list-scasp.pl ├── loanwithcure-scasp.pl ├── minicontract-scasp.pl ├── obligation-scasp.pl ├── simpleRPS-scasp.pl ├── subset-scasp.pl └── turingcomplete-scasp.pl ├── min_programs ├── bec_loan.pl ├── bec_tap_04_abducible_infer_event_time.pl ├── clpq_gt_gte_lt_lte_equal.pl ├── clpq_intercept.pl ├── ex01-dual.pl ├── ex02-member.pl ├── forall_arity.pl ├── hamiltonian_scasp.pl ├── lion.pl ├── nixon-diamond.pl ├── queens_old.pl ├── solve_call.pl ├── solve_findall_superset.pl ├── solve_forall.pl ├── solve_not_is.pl ├── solve_not_true.pl ├── stream_reasoning.pl └── yale_shooting_casp_v2.pl ├── small_programs ├── ex01-dual.pl └── solve_not_true.pl ├── test_clp_disequality.pl ├── test_just.pl ├── test_prolog.pl └── test_scasp.pl /.gitignore: -------------------------------------------------------------------------------- 1 | *.qlf 2 | *.itf 3 | *.po 4 | *~ 5 | *.cov 6 | # Exclude main executable, but keep directory 7 | scasp 8 | !prolog/scasp/ 9 | /TAGS 10 | buildenv.sh 11 | status.db 12 | -------------------------------------------------------------------------------- /ATTIC/WORK_IN_PROGRESS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWI-Prolog/sCASP/bae608edbed74ef3cdcbdd92ebeaeb27c300349d/ATTIC/WORK_IN_PROGRESS -------------------------------------------------------------------------------- /ATTIC/max.lp: -------------------------------------------------------------------------------- 1 | max(X) :- not smaller(X). 2 | smaller(X) :- num(X), num(Y), X < Y. 3 | 4 | num(1). 5 | num(2). 6 | num(3). 7 | num(5). 8 | 9 | ?- max(C). 10 | -------------------------------------------------------------------------------- /ATTIC/misc_programs/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | compile: 6 | ciaoc -o new_hanoi_3 new_hanoi_3.pl 7 | 8 | 9 | test: 10 | ./new_hanoi_3 3 11 | ./new_hanoi_3 4 12 | ./new_hanoi_3 5 13 | ./new_hanoi_3 6 14 | ./new_hanoi_3 8 15 | ./new_hanoi_3 10 16 | echo ------- -------- 17 | ./new_hanoi_3 7 18 | ./new_hanoi_3 9 19 | -------------------------------------------------------------------------------- /ATTIC/misc_programs/count_asp.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | % p :- not q. 7 | % q :- not p. 8 | % %result(S) :- S = #count{ :p}. 9 | 10 | % r:- s_result(1). 11 | % s:- r_result(1). 12 | 13 | % s_result(S) :- S = #count{ :s}. 14 | % r_result(S) :- S = #count{ :r}. 15 | 16 | 17 | 18 | 19 | % t(a) :- N = #count{X:u(X)}, N = 0. 20 | % u(a) :- N = #count{X:t(X)}, N = 0. 21 | 22 | % t(a) :- N = #count{X:u(X)}, N = 0. 23 | % u(a) :- N = #count{X:t(X)}, N = 0. 24 | 25 | 26 | 27 | % Party 28 | 29 | % coming(X) :- required(X,K), N= #count{ :kc(X,_)}, N >= K. 30 | % kc(X,Y) :- knows(X,Y), coming(Y). 31 | 32 | % %coming(a). 33 | % required(a,1). 34 | % required(b,1). 35 | % knows(a,b). 36 | % knows(b,a). 37 | 38 | 39 | % r(a).r(b). 40 | % p(b). 41 | % q(b). 42 | % p(a) :- N = #count{ r(X): q(X)}, N = 1. 43 | % q(a) :- 1 = #count{ r(X): p(X)}. 44 | 45 | 46 | p(0). 47 | p(1). 48 | p(2). 49 | 50 | r(1..2). 51 | 52 | p(0) :- N = #min {X : p(X)}, N = 0. 53 | 54 | #show p/1. 55 | -------------------------------------------------------------------------------- /ATTIC/misc_programs/hanoi_for_simple_minds_2.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | hanoi([], [], _). 4 | hanoi(A, B, C):- 5 | any_move(A, B, C, A1, B1, C1), 6 | hanoi(A1, B1, C1). 7 | 8 | any_move(A, B, C, A1, B, C1):- swap(A, C, A1, C1). 9 | any_move(A, B, C, A1, B1, C):- swap(A, B, A1, B1). 10 | any_move(A, B, C, A, B1, C1):- swap(C, B, C1, B1). 11 | 12 | swap(A, B, A1, B1):- moveto(A, B, A1, B1). 13 | swap(A, B, A1, B1):- moveto(B, A, B1, A1). 14 | 15 | moveto([A|A1], B, A1, [A|B]) :- not inverted([A|B]). 16 | 17 | inverted([A,B|_]):- A > B. 18 | 19 | 20 | ?- hanoi([1,2,3], [], []). 21 | 22 | 23 | #show hanoi/3. 24 | 25 | 26 | 27 | /* 28 | ?- ?? hanoi([1,2,3],[],[]). 29 | 30 | Answer 1 (in [23.284] ms): 31 | { hanoi([1,2,3],[],[]) , hanoi([2,3],[],[1]) , hanoi([3],[2],[1]) , hanoi([1,3],[2],[]) , hanoi([3],[1,2],[]) , hanoi([],[1,2],[3]) , hanoi([1],[2],[3]) , hanoi([],[2],[1,3]) , hanoi([2],[],[1,3]) , hanoi([1,2],[],[3]) , hanoi([2],[1],[3]) , hanoi([],[1],[2,3]) , hanoi([1],[],[2,3]) , hanoi([],[],[1,2,3]) } 32 | 33 | 34 | next ? ; 35 | 36 | Answer 2 (in [13.626] ms): 37 | { hanoi([1,2,3],[],[]) , hanoi([2,3],[],[1]) , hanoi([3],[2],[1]) , hanoi([1,3],[2],[]) , hanoi([3],[1,2],[]) , hanoi([],[1,2],[3]) , hanoi([1],[2],[3]) , hanoi([],[2],[1,3]) , hanoi([2],[],[1,3]) , hanoi([1,2],[],[3]) , hanoi([2],[1],[3]) , hanoi([],[1],[2,3]) , hanoi([],[],[1,2,3]) } 38 | 39 | 40 | next ? 41 | */ 42 | -------------------------------------------------------------------------------- /ATTIC/misc_programs/new_hanoi_2.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | query(S, T, L, U) :- 6 | T .>=. 0, hanoi(S, T,L). 7 | 8 | % size(7). 9 | % stack(S, Stack) :- gen_list(1,S,Stack). 10 | 11 | :- use_package(clpq). 12 | 13 | hanoi(S, T,List) :- 14 | gen_list(1,S,Stack), 15 | %stack(S, Stack), 16 | holds(T,st(Stack, [],[]),st([],[],Stack),[],List). 17 | 18 | % init(st(Stack,[],[])) :- 19 | % stack(Stack). 20 | 21 | holds(0,S,S,Ac,[S|Ac]):- \+ member(S, Ac). 22 | holds(T1, St1, St2, Ac, Res) :- 23 | T0 .>=. 0, 24 | T1 .=. T0 + 1, 25 | \+ member(St1, Ac), 26 | trans(St1, StX), 27 | holds(T0, StX, St2, [St1|Ac], Res). 28 | 29 | 30 | 31 | trans(st(A0,B0,C0), st(A1,B1,C1)) :- 32 | trans_(A0,A1,B0,B1,C0,C1). 33 | trans(st(A0,B0,C0), st(A1,B1,C1)) :- 34 | trans_(B0,B1,C0,C1,A0,A1). 35 | trans(st(A0,B0,C0), st(A1,B1,C1)) :- 36 | trans_(C0,C1,A0,A1,B0,B1). 37 | 38 | trans_([A|As],As,B,[A|B],C,C) :- 39 | not_invalid(A,B). 40 | trans_([A|As],As,B,B,C,[A|C]) :- 41 | not_invalid(A,C). 42 | 43 | % invalid(E,[O|_]) :- 44 | % E .>. O. 45 | 46 | not_invalid(_,[]). 47 | not_invalid(E,[O|_]) :- 48 | E .<. O. 49 | 50 | gen_list(N,N,[N]). 51 | gen_list(I,N,[I|L]) :- 52 | I < N, 53 | I1 is I + 1, 54 | gen_list(I1,N,L). 55 | -------------------------------------------------------------------------------- /ATTIC/test_findall/call.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | p(X) :- 10 | call(X). 11 | 12 | q(1). 13 | q(2). 14 | 15 | ?- p(q(X)). 16 | ?- not p(q(X)). 17 | 18 | ?- not q(X). 19 | ?- q(X). 20 | 21 | 22 | call_list([]). 23 | call_list([X|Xs]) :- 24 | call(X), 25 | call_list(Xs). 26 | 27 | ?- call_list([q(X),not q(Y)]). -------------------------------------------------------------------------------- /ATTIC/test_findall/findall01.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | p :- not q. 7 | q :- not p. 8 | 9 | 10 | s(1) :- p. 11 | s(2) :- p. 12 | s(3) :- q. 13 | 14 | l(L) :- findall(V, s(V), L). 15 | 16 | 17 | 18 | ?- l(L). 19 | ?- p, l(L). 20 | 21 | ?- not l(L). -------------------------------------------------------------------------------- /ATTIC/test_forall/README.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | To test the c_forall/2 use the following command: 5 | 6 | a) to obtain all the solutions (including redundant justifications) 7 | 8 | scasp -n0 --c_forall test05-ok.pl 9 | 10 | b) to obtain the first solution (loosing solutions) 11 | 12 | scasp -n0 --once_c_forall test05-ok.pl 13 | 14 | c) to check the complete justification tree 15 | 16 | scasp -n0 --once_c_forall --tree --long test05-ok.pl 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ATTIC/test_forall/diseq01-ok.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | p(X,aa) :- X \= a. 8 | p(X,aa) :- X = a. 9 | 10 | p(X,bb) :- X \= b. 11 | p(X,bb) :- X = b. 12 | 13 | 14 | q(Y) :- not p(X,Y). 15 | 16 | ?- not q(Y). %% Should succeed 17 | -------------------------------------------------------------------------------- /ATTIC/test_forall/diseq02-ok.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | p(X,Y) :- d(Y), X \= a. 8 | p(X,Y) :- d(Y), X = a. 9 | 10 | d(aa). 11 | d(bb). 12 | 13 | q(Y) :- not p(X,Y). 14 | 15 | ?- not q(Y). %% Should succeed 16 | -------------------------------------------------------------------------------- /ATTIC/test_forall/test01-ok.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | p(X,Y) :- X .=<. Y. 6 | p(X,Y) :- X .>. Y. 7 | 8 | q :- not p(X,Y). 9 | 10 | ?- not q. %% Should succeed 11 | -------------------------------------------------------------------------------- /ATTIC/test_forall/test02-fail.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | p(X,Y) :- X .<. Y. 6 | p(X,Y) :- X .>. Y. 7 | 8 | q :- not p(X,Y). 9 | 10 | 11 | ?- not q. %% Should fail 12 | -------------------------------------------------------------------------------- /ATTIC/test_forall/test03-fail.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | p(X,Y) :- X .<. Y. 6 | 7 | q :- not p(X,Y). 8 | 9 | 10 | ?- not q. %% Should fail 11 | -------------------------------------------------------------------------------- /ATTIC/test_forall/test05-ok.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | %p(X, Y, Z):- all_pos(X, Y), all_pos(Y, Z). 4 | 5 | % When the above works, try the one below 6 | p(X, Y, Z):- all_pos(X, Y), all_pos(Y, Z), all_pos(X, Z). 7 | 8 | all_pos(A, B):- A .>. B. 9 | all_pos(A, B):- A .=<. B. 10 | 11 | q:- not p(X, Y, Z). 12 | 13 | 14 | ?- not q. %% Should succeed 15 | -------------------------------------------------------------------------------- /ATTIC/test_justification/fever3.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | # pred diagnosis(P,T) :: 'The diagnosis for @(P) with a temperature of @(T) is that:'. 4 | diagnosis(P,T) :- fever(P,T). 5 | diagnosis(P,T) :- no_fever(P,T). 6 | 7 | # pred fever(Person,Temp) :: '@(Person) has a fever'. 8 | # pred no_fever(Person,Temp) :: '@(Person) has no fever'. 9 | fever(Person,Temp) :- 10 | temp(Person,Temp), 11 | high_temp(Temp), 12 | not no_fever(Person,Temp). 13 | 14 | no_fever(Person,Temp) :- 15 | temp(Person,Temp), 16 | not high_temp(Temp), 17 | not fever(Person,Temp). 18 | 19 | high_temp(T) :- T #> 38. 20 | 21 | temp(P,T) :- reg_temp(P,T). 22 | temp(P,T) :- not reg_person(P). 23 | 24 | # pred reg_temp(Person,Temp) :: 'The registered temperarture of @(Person) is @(Temp)'. 25 | # pred not reg_temp(Person,Temp) :: 'We do not have a registered temperature for @(Person) of @(Temp)'. 26 | reg_temp('Juan',37). 27 | reg_temp('Pedro',39). 28 | 29 | 30 | # pred not reg_person(Person) :: 'There are no registerd temperature of @(Person)'. 31 | reg_person(P) :- reg_temp(P,T). 32 | 33 | 34 | %%%%%%%% Queries %%%%%%% 35 | ?- diagnosis('Luisa',T). %% Two possible models 36 | %?- diagnosis('Juan',T). %% Juan has no fever 37 | %?- diagnosis('Pedro',T). %% Pedro has fever 38 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/abdbirds.pl: -------------------------------------------------------------------------------- 1 | % Birds with abducibles. If we observe that a bird is abnormal, we can use our 2 | % abducibles to speculate why. 3 | 4 | #abducible wounded_bird(X). 5 | #abducible penguin(X). 6 | #abducible ab(X). 7 | 8 | % Sam, Tweety and John are birds. 9 | bird(sam). 10 | bird(tweety). 11 | bird(john). 12 | 13 | % penguins and wounded birds are abnormal 14 | ab(X) :- penguin(X). 15 | ab(X) :- wounded_bird(X). 16 | 17 | % birds that are not abnormal can fly 18 | flies(X) :- bird(X), not ab(X). 19 | 20 | ?- not flies(tweety). 21 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/birds.pl: -------------------------------------------------------------------------------- 1 | % Given 3 birds, which can fly? 2 | 3 | penguin(sam). % sam is a penguin 4 | wounded_bird(john). % john is wounded 5 | bird(tweety). % tweety is just a bird 6 | 7 | % penguines and wounded birds are still birds 8 | bird(X) :- penguin(X). 9 | bird(X) :- wounded_bird(X). 10 | 11 | % penguins and wounded birds are abnormal 12 | ab(X) :- penguin(X). 13 | ab(X) :- wounded_bird(X). 14 | 15 | % birds can fly if they are not abnormal 16 | flies(X) :- bird(X), not ab(X). 17 | 18 | % explicit closed world assumptions 19 | -flies(X) :- ab(X). 20 | -flies(X) :- -bird(X). 21 | 22 | -wounded_bird(X) :- not wounded_bird(X). 23 | 24 | -bird(X) :- not bird(X). 25 | 26 | -penguin(X) :- not penguin(X). 27 | 28 | -ab(X) :- not ab(X). 29 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/birds2.pl: -------------------------------------------------------------------------------- 1 | % Given 3 birds, which can fly? 2 | 3 | penguin(sam). % sam is a penguin 4 | wounded_bird(john). % john is wounded 5 | bird(tweety). % tweety is just a bird 6 | 7 | % penguins and wounded birds are still birds 8 | bird(X) :- penguin(X). 9 | bird(X) :- wounded_bird(X). 10 | 11 | % penguins and wounded birds are abnormal 12 | ab(X) :- penguin(X). 13 | ab(X) :- wounded_bird(X). 14 | 15 | % birds can fly if they are not abnormal 16 | flies(X) :- bird(X), not ab(X). 17 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/classic_negation.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | p(1). 6 | -p(1). 7 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/classical_neg_entail.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | p(X) :- not neg_p(X). 6 | neg_p(X) :- not p(X). 7 | 8 | -p(1). 9 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/cofailure.pl: -------------------------------------------------------------------------------- 1 | d(1). 2 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/directive_test.pl: -------------------------------------------------------------------------------- 1 | % { p(_), not q(_) } 2 | #include('pq_loop.lp'). 3 | #include 'member.lp'. 4 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/errtest.pl: -------------------------------------------------------------------------------- 1 | p :- :- a. 2 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/family.pl: -------------------------------------------------------------------------------- 1 | % { ancestor(bob,sam), ancestor(jill,sam), ... } 2 | %-parent(bob,Y) :- not father(bob,Y), not mother(bob,Y), not new(bob). 3 | %-parent(ted,Z). 4 | test(X) :- not test2(X, Y). 5 | test(X). 6 | test2(X, Y) :- (Y \= 1, not test3(X)). 7 | test2(X, 1) :- not test3(X). 8 | test3(X) :- not test(X). 9 | 10 | male(bob). 11 | male(bo). 12 | male(ben). 13 | male(jeff). 14 | male(ron). 15 | male(tim). 16 | male(ray). 17 | 18 | female(may). 19 | female(joy). 20 | female(jill). 21 | female(kathy). 22 | female(ali). 23 | female(sam). 24 | female(beth). 25 | 26 | father(bob,jill). 27 | father(bob,bo). 28 | %father(bob,kathy). 29 | %father(bo,ron). 30 | father(bo,ali). 31 | father(ben,sam). 32 | %father(jeff,beth). 33 | %father(jeff,tim). 34 | %father(jeff,ray). 35 | 36 | mother(may,jill). 37 | mother(may,bo). 38 | %mother(may,kathy). 39 | %mother(joy,ron). 40 | mother(joy,ali). 41 | mother(jill,sam). 42 | %mother(kathy,beth). 43 | %mother(kathy,tim). 44 | %mother(kathy,ray). 45 | 46 | 47 | parent(X,Y) :- father(X,Y). 48 | parent(X,Y) :- mother(X,Y). 49 | 50 | grandparent(X,Y):-parent(X,Z),parent(Z,Y). 51 | 52 | ancestor(X,Y) :- parent(X,Y). 53 | ancestor(X,Y) :- parent(X,Z),ancestor(Z,Y). 54 | 55 | sibling(X,Y):-X\=Y,parent(Z,X),parent(Z,Y). 56 | 57 | sister(X,Y):-sibling(X,Y),female(X). 58 | 59 | brother(X,Y):-sibling(X,Y),male(X). 60 | 61 | cousin(X,Y):-parent(P1,X),parent(P2,Y),P1\=P2.%sibling(P1,P2). 62 | 63 | hardmath(X) :- X is A+(B*C-(D/E-F)*G)*H. 64 | 65 | #compute 1 {ancestor(bob,sam)}. 66 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/gpa.pl: -------------------------------------------------------------------------------- 1 | % From Baral Book pg 81 2 | eligible(X) :- highGPA(X). 3 | eligible(X) :- special(X), fairGPA(X). 4 | -eligible(X) :- -special(X), -highGPA(X). 5 | interview(X) :- not eligible(X), not -eligible(X). 6 | fairGPA(john). 7 | -highGPA(john). 8 | ?- interview(john). 9 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/graph.pl: -------------------------------------------------------------------------------- 1 | % Graph 2 | 3 | node(a). 4 | node(b). 5 | node(c). 6 | node(d). 7 | node(e). 8 | 9 | edge(a,b). 10 | edge(a,c). 11 | edge(b,c). 12 | edge(d,e). 13 | 14 | path(X,X). 15 | path(X,Y):-edge(X,Z),path(Z,Y). 16 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/hamcycle.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | 6 | % fact for each edge edge(U, V). 7 | edge(0, 1). 8 | edge(1, 2). 9 | edge(2, 0). 10 | 11 | reachable(V) :- chosen(U, V), reachable(U). 12 | reachable(0) :- chosen(V, 0). 13 | 14 | % Every vertex must be reachable. 15 | :- vertex(U), not reachable(U). 16 | 17 | % Choose exactly one edge from each vertex. 18 | other(U, V) :- 19 | vertex(U), vertex(V), vertex(W), 20 | edge(U, W), V \= W, chosen(U, W). 21 | chosen(U, V) :- 22 | edge(U, V), not other(U, V). 23 | 24 | % You cannot choose two edges to the same vertex 25 | :- chosen(U, W), chosen(V, W), U \= V. 26 | ?- chosen(1,2). 27 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/hamcycle2.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | 6 | % fact for each edge edge(U, V). 7 | edge(0, 1). 8 | edge(1, 2). 9 | edge(2, 0). 10 | 11 | reachable(V) :- chosen(U, V), reachable(U). 12 | reachable(0) :- chosen(V, 0). 13 | 14 | % Every vertex must be reachable. 15 | :- vertex(U), not reachable(U). 16 | 17 | % Choose exactly one edge from each vertex. 18 | other(U, V) :- 19 | vertex(U), vertex(V), vertex(W), 20 | edge(U, W), V \= W, chosen(U, W). 21 | chosen(U, V) :- 22 | edge(U, V), not other(U, V). 23 | 24 | % You cannot choose two edges to the same vertex 25 | :- chosen(U, W), chosen(V, W), U \= V. 26 | ?- chosen(1,2). 27 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/hamcycle_two.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | vertex(3). 6 | 7 | % fact for each edge edge(U, V). 8 | edge(0, 1). 9 | edge(1, 2). 10 | edge(2, 3). 11 | edge(3, 0). 12 | 13 | edge(2, 0). 14 | edge(0, 3). 15 | edge(3, 1). 16 | 17 | reachable(V) :- chosen(U, V), reachable(U). 18 | reachable(0) :- chosen(V, 0). 19 | 20 | % Every vertex must be reachable. 21 | :- vertex(U), not reachable(U). 22 | 23 | % Choose exactly one edge from each vertex. 24 | other(U, V) :- 25 | vertex(U), vertex(V), vertex(W), 26 | edge(U, W), V \= W, chosen(U, W). 27 | chosen(U, V) :- 28 | edge(U, V), not other(U, V). 29 | 30 | % You cannot choose two edges to the same vertex 31 | :- chosen(U, W), chosen(V, W), U \= V. 32 | ?- chosen(1,2). 33 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/hanoi.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | % Move N disks in T moves. 4 | hanoi(N, T) :- 5 | moven(N, 0, T, 1, 2, 3). 6 | 7 | % Move N disks from peg A to peg B using peg C. Assign move numbers. 8 | moven(N, Ti, To, A, B, C) :- 9 | N > 1, 10 | N1 is N - 1, 11 | moven(N1, Ti, T2, A, C, B), 12 | T3 is T2 + 1, 13 | move(T3, A, B), 14 | moven(N1, T3, To, C, B, A). 15 | moven(1, Ti, To, A, B, _) :- 16 | To is Ti + 1, 17 | move(To, A, B). 18 | 19 | % move T: move disk from P1 to P2. 20 | % any move may or may not be selected. 21 | move(T, P1, P2) :- 22 | not negmove(T, P1, P2). 23 | 24 | negmove(T, P1, P2) :- 25 | not move(T, P1, P2). 26 | 27 | ?- hanoi(8, T). 28 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/hanoi_7.pl: -------------------------------------------------------------------------------- 1 | % Move N disks in T moves. 2 | hanoi(N, T) :- 3 | moven(N, 0, T, 1, 2, 3). 4 | 5 | % Move N disks from peg A to peg B using peg C. Assign move numbers. 6 | moven(N, Ti, To, A, B, C) :- 7 | N > 1, 8 | N1 is N - 1, 9 | moven(N1, Ti, T2, A, C, B), 10 | T3 is T2 + 1, 11 | move(T3, A, B), 12 | moven(N1, T3, To, C, B, A). 13 | moven(1, Ti, To, A, B, _) :- 14 | To is Ti + 1, 15 | move(To, A, B). 16 | 17 | % move T: move disk from P1 to P2. 18 | % any move may or may not be selected. 19 | move(T, P1, P2) :- 20 | not negmove(T, P1, P2). 21 | 22 | negmove(T, P1, P2) :- 23 | not move(T, P1, P2). 24 | 25 | ?- hanoi(7, T). 26 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/hanoi_clp.pl: -------------------------------------------------------------------------------- 1 | :- module(hanoi_clp,_). 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | % % % Move N disks in T moves. 13 | % % hanoi(N, T) :- 14 | % % moven(N, 0, T, 1, 2, 3). 15 | 16 | % % % Move N disks from peg A to peg B using peg C. Assign move numbers. 17 | % % moven(N, Ti, To, A, B, C) :- 18 | % % N > 1, 19 | % % N1 is N - 1, 20 | % % moven(N1, Ti, T2, A, C, B), 21 | % % T3 is T2 + 1, 22 | % % move(T3, A, B), 23 | % % moven(N1, T3, To, C, B, A). 24 | % % moven(1, Ti, To, A, B, _) :- 25 | % % To is Ti + 1, 26 | % % move(To, A, B). 27 | 28 | % % % move T: move disk from P1 to P2. 29 | % % % any move may or may not be selected. 30 | % % move(T, P1, P2) :- 31 | % % not negmove(T, P1, P2). 32 | % % negmove(T, P1, P2) :- 33 | % % not move(T, P1, P2). 34 | 35 | % :- use_package(tabling). 36 | % :- use_package(t_clpq). 37 | 38 | % :- table move/5. 39 | 40 | %#table move/5. 41 | 42 | move(1,_,_,_,1). 43 | % :- 44 | % write('Move top disk from '), 45 | % write(X), 46 | % write(' to '), 47 | % write(Y), 48 | % nl. 49 | move(N,X,Y,Z,Steps) :- 50 | Steps .=. S1 + S2 + S3, 51 | N > 1, 52 | M is N - 1, 53 | move(M,X,Z,Y,S1), 54 | move(1,X,Y,_,S2), 55 | move(M,Z,Y,X,S3). 56 | 57 | % q(S,T) :- 58 | % statistics(runtime,_), move(15,l,r,c,S), statistics(runtime, [_|T]). 59 | 60 | % ?- hanoi(4, T). 61 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/left-rec-succ_BAD.pl: -------------------------------------------------------------------------------- 1 | r(X, Y) :- r(X, Z), p(Z, Y). 2 | r(X, Y) :- p(X, Y). 3 | % r(a,d) works if goals reversed. Likely r(X, Z) will never succeed with Z = c 4 | r(X, Y) :- r(X, Z), q(Z, Y). 5 | p(a, b). p(b, c). q(c, d). 6 | ?- r(a,Y). 7 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/left.pl: -------------------------------------------------------------------------------- 1 | p(X) :- p(Y). 2 | %p(0). 3 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/lion.pl: -------------------------------------------------------------------------------- 1 | animal(lion). 2 | animal(snake). 3 | animal(monkey). 4 | animal(rat). 5 | 6 | live(monkey, forest). 7 | live(snake, zoo). 8 | live(rat, apartment). 9 | 10 | live(X, forest) :- 11 | animal(X), 12 | not _ab(live_animal(X)), 13 | not -live(X, forest). 14 | 15 | -live(X, Z) :- 16 | live(X, Y), 17 | Y \= Z. 18 | 19 | % _ab(_) :- false. 20 | 21 | 22 | ?- live(lion, X). 23 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/list.pl: -------------------------------------------------------------------------------- 1 | p([]). 2 | p([X | T]) :- q(X), p(T). 3 | 4 | q(1). 5 | ?- p([1 | T]). 6 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/loop_pos.pl: -------------------------------------------------------------------------------- 1 | p(X) :- p(Y). 2 | ?- p(X). 3 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/loop_succ_pos.pl: -------------------------------------------------------------------------------- 1 | p(X) :- p(Y). 2 | p(0). 3 | ?- p(X). 4 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/loopvar.pl: -------------------------------------------------------------------------------- 1 | p(X) :- not q(X). 2 | q(X) :- not p(X). 3 | r(X) :- X \= 3, X \= 4, q(X). 4 | ?- p(X), r(Y). 5 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/loopvar2.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | p(1,X) :- not q(1,X). 4 | q(1,X) :- not p(1,X). 5 | r(X) :- X \= 3, X \= 4, q(1,X). 6 | ?- p(1,X), r(Y). 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/member.pl: -------------------------------------------------------------------------------- 1 | member(X,[X|T]). 2 | member(X,[Y|T]) :- X\=Y, member(X,T). 3 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/multitest.pl: -------------------------------------------------------------------------------- 1 | % { ancestor(bob,sam,[bob,jill,sam]), ... } x2 2 | %-parent(bob,Y) :- not father(bob,Y), not mother(bob,Y), not new(bob). 3 | %-parent(ted,Z). 4 | test(X) :- not test2(X, Y). 5 | test(X) :- test([]). 6 | test(X). 7 | test2(X, Y) :- Y \= 1, not test3(X). 8 | test2(X, 1) :- not test3(X). 9 | test3(X) :- not test(X). 10 | 11 | male(bob). 12 | male(bo). 13 | male(ben). 14 | 15 | female(may). 16 | female(jill). 17 | female(sam). 18 | 19 | father(bob,jill). 20 | father(bob,bo). 21 | father(ben,sam). 22 | 23 | mother(may,jill). 24 | mother(may,bo). 25 | mother(jill,sam). 26 | 27 | parent(X,Y) :- father(X,Y). 28 | parent(X,Y) :- mother(X,Y). 29 | 30 | % Get lineage from X to Y 31 | ancestor(X,Y,[X,Y]) :- parent(X,Y). 32 | ancestor(X,Y,[X|T]) :- parent(X,Z),ancestor(Z,Y,T). 33 | 34 | arith(Z) :- Z is 2 ** 2.2. 35 | 36 | ?- ancestor(bob,sam,X), arith(Z). 37 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/natnum.pl: -------------------------------------------------------------------------------- 1 | s(0). 2 | s(s(X)) :- 3 | s(X). 4 | 5 | sum(s(0), X, s(X)). 6 | sum(X, s(0), s(X)). 7 | sum(s(X), Y, s(Z)) :- 8 | X \= 0, 9 | sum(X, Y, Z). 10 | 11 | sumlist([X | T], [Y | T2], [Z | T3]) :- 12 | sum(X, Y, Z), 13 | sumlist(T, T2, T3). 14 | sumlist([], [], []). 15 | 16 | ?- sumlist([s(s(0)), s(s(s(0)))], [s(s(s(0))), s(s(s(0)))], X). 17 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/oddloop_odd.pl: -------------------------------------------------------------------------------- 1 | alpha(a). 2 | alpha(b). 3 | alpha(c). 4 | 5 | alpha_num(a). 6 | alpha_num(d). 7 | alpha_num(e). 8 | alpha_num(0). 9 | alpha_num(1). 10 | alpha_num(2). 11 | 12 | alpha_spec(e). 13 | alpha_spec(f). 14 | alpha_spec(g). 15 | alpha_spec('#'). 16 | alpha_spec('&'). 17 | 18 | member(X,[X|T]). 19 | member(X,[_|T]) :- member(X,T). 20 | 21 | state1(L) :- not alpha(X), not member(X,L), not state2(L). 22 | state1(X). 23 | %state2(L) :- not alpha_num(X), not member(X,L), not state3(L). 24 | state2(L) :- not state3(L). 25 | %state3(L) :- not alpha_spec(X), not member(X,L), not state1(L). 26 | state3(L) :- not state1(L). 27 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/paperexample.pl: -------------------------------------------------------------------------------- 1 | n(0). 2 | n(s(X)) :- n(X). 3 | p(X, Y) :- not q(X), t(Y, Y). 4 | q(X) :- not p(X, Y). 5 | r(V) :- r(V2). 6 | r(3.14). 7 | s(N) :- N \= 3.14. 8 | t(A, A). 9 | %a(X):- not b(X), t(X,X). 10 | %b(X):- not c(X), not q(X). 11 | %c(X):- not a(X). 12 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/path.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #table path/2. 6 | 7 | edge(1,2). 8 | edge(2,3) :- not edge(2,4). 9 | edge(2,4) :- not edge(2,3). 10 | 11 | 12 | path(X,Y) :- 13 | edge(X,Y). 14 | path(X,Y) :- 15 | path(X,Z), 16 | edge(Z,Y). 17 | 18 | 19 | ?- path(X,Y). 20 | 21 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/path_loop.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %#table path/2. 5 | 6 | edge(a,b). 7 | edge(b,c). 8 | edge(a,d) :- not path(c,d). 9 | 10 | path(X,Y) :- 11 | edge(X,Y). 12 | path(X,Y) :- 13 | edge(X,Z), 14 | path(Z,Y). 15 | 16 | 17 | ?- path(a,Y). 18 | 19 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/pos_loop2_simple.pl: -------------------------------------------------------------------------------- 1 | %This should fail since the Herbrand Universe only contains one symbol. 2 | 3 | q(a). 4 | r(a). 5 | 6 | p(X) :- p(Y). 7 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/pos_loop_pass_simple.pl: -------------------------------------------------------------------------------- 1 | q(a). 2 | q(b). 3 | q(c). 4 | 5 | p(X) :- p(Y). 6 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/pos_loop_simple.pl: -------------------------------------------------------------------------------- 1 | p(X) :- p(X). 2 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/pq_asp.pl: -------------------------------------------------------------------------------- 1 | p :- not q. 2 | q :- not p. 3 | 4 | 5 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/pq_loop.pl: -------------------------------------------------------------------------------- 1 | p(X) :- not q(X). 2 | q(X) :- not p(X). 3 | % ?- p(X). 4 | 5 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/pq_loop_b.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | p(X) :- not q(X). 6 | q(X) :- not p(X). 7 | 8 | q(b). 9 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/queens.pl: -------------------------------------------------------------------------------- 1 | % 4-queens: ((1,2),(2,4),(3,1),(4,3)) and ((1,3),(2,1),(3,4),(4,2)) 2 | % Retargetable N-queens program. 3 | 4 | nqueens(N, Q) :- 5 | _nqueens(N, N, [], Q). 6 | 7 | % Pick queens one at a time and test against all previous queens. 8 | _nqueens(X, N, Qi, Qo) :- 9 | X > 0, 10 | _pickqueen(X, Y, N), 11 | not _attack(X, Y, Qi), 12 | X1 is X - 1, 13 | _nqueens(X1, N, [q(X, Y) | Qi], Qo). 14 | _nqueens(0, _, Q, Q). 15 | 16 | 17 | % pick a queen for row X. 18 | _pickqueen(X, Y, Y) :- 19 | Y > 0, 20 | q(X, Y). 21 | _pickqueen(X, Y, N) :- 22 | N > 1, 23 | N1 is N - 1, 24 | _pickqueen(X, Y, N1). 25 | 26 | % check if a queen can attack any previously selected queen. 27 | _attack(X, _, [q(X, _) | _]). % same row 28 | _attack(_, Y, [q(_, Y) | _]). % same col 29 | _attack(X, Y, [q(X2, Y2) | _]) :- % same diagonal 30 | Xd is X2 - X, 31 | _abs(Xd, Xd2), 32 | Yd is Y2 - Y, 33 | _abs(Yd, Yd2), 34 | Xd2 = Yd2. 35 | _attack(X, Y, [_ | T]) :- 36 | _attack(X, Y, T). 37 | 38 | q(X, Y) :- not _negq(X, Y). 39 | _negq(X, Y) :- not q(X, Y). 40 | 41 | _abs(X, X) :- X >= 0. 42 | _abs(X, Y) :- X < 0, Y is X * -1. 43 | 44 | ?- nqueens(4, Q). 45 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/queens_hide.pl: -------------------------------------------------------------------------------- 1 | % 4-queens: ((1,2),(2,4),(3,1),(4,3)) and ((1,3),(2,1),(3,4),(4,2)) 2 | % Retargetable N-queens program. 3 | 4 | nqueens(N, Q) :- 5 | hide_nqueens(N, N, [], Q). 6 | 7 | % Pick queens one at a time and test against all previous queens. 8 | hide_nqueens(X, N, Qi, Qo) :- 9 | X > 0, 10 | hide_pickqueen(X, Y, N), 11 | not hide_attack(X, Y, Qi), 12 | X1 is X - 1, 13 | hide_nqueens(X1, N, [q(X, Y) | Qi], Qo). 14 | hide_nqueens(0, _, Q, Q). 15 | 16 | 17 | % pick a queen for row X. 18 | hide_pickqueen(X, Y, Y) :- 19 | Y > 0, 20 | q(X, Y). 21 | hide_pickqueen(X, Y, N) :- 22 | N > 1, 23 | N1 is N - 1, 24 | hide_pickqueen(X, Y, N1). 25 | 26 | % check if a queen can attack any previously selected queen. 27 | hide_attack(X, _, [q(X, _) | _]). % same row 28 | hide_attack(_, Y, [q(_, Y) | _]). % same col 29 | hide_attack(X, Y, [q(X2, Y2) | _]) :- % same diagonal 30 | Xd is X2 - X, 31 | hide_abs(Xd, Xd2), 32 | Yd is Y2 - Y, 33 | hide_abs(Yd, Yd2), 34 | Xd2 = Yd2. 35 | hide_attack(X, Y, [_ | T]) :- 36 | hide_attack(X, Y, T). 37 | 38 | q(X, Y) :- not hide_negq(X, Y). 39 | hide_negq(X, Y) :- not q(X, Y). 40 | 41 | hide_abs(X, X) :- X >= 0. 42 | hide_abs(X, Y) :- X < 0, Y is X * -1. 43 | 44 | ?- nqueens(4, Q). 45 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/reflexive.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #table edge/2. 5 | 6 | edge(1,2). 7 | edge(2,3). 8 | 9 | 10 | edge(X,Y) :- 11 | edge(Y,X). 12 | 13 | edge(4,5) :- not edge(2,5). 14 | 15 | ?- edge(X,Y). 16 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/schedule.pl: -------------------------------------------------------------------------------- 1 | %Assume each task takes exactly 1 hour, and each time slot is 1 hour 2 | 3 | make_schedule:-schedule(breakfast,_), 4 | schedule(lunch,_), 5 | schedule(dinner,_), 6 | schedule(asp_coding_1,_), 7 | schedule(asp_coding_2,_), 8 | schedule(homework,_), 9 | schedule(homework_discussion,_), 10 | schedule(snack,_). 11 | 12 | constraint(breakfast,T):-T>=6,T<10. 13 | constraint(lunch,T):-T>=11,T<13. 14 | constraint(dinner,T):-T>=17,T<19. 15 | constraint(snack,T):-schedule(lunch,T1),schedule(dinner,T2),T>T1,TT1. 18 | 19 | constraint(asp_coding_1,_). 20 | constraint(asp_coding_2,_). 21 | constraint(homework,_). 22 | 23 | time_slot(X):-X>=0,X<24. 24 | 25 | %A task may or may not be scheduled at a specific time. 26 | schedule(Task,Time):-time_slot(Time),constraint(Task,Time),not not_schedule(Task,Time). 27 | not_schedule(Task,Time):-not schedule(Task,Time). 28 | 29 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/simple.pl: -------------------------------------------------------------------------------- 1 | r(X):-X>0. 2 | r(a). 3 | r(b). 4 | r(c). 5 | 6 | p(X):-r(X), not q(X). 7 | q(X):-not p(X). 8 | 9 | q(5). 10 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/struct.pl: -------------------------------------------------------------------------------- 1 | p(s(X)). 2 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/succ.pl: -------------------------------------------------------------------------------- 1 | n(0). 2 | n(s(X)) :- n(X). 3 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test1.pl: -------------------------------------------------------------------------------- 1 | % { p, r, not q }, { p, not q }, { q, not p, not r } 2 | % p can succeed through not q, but not through r, since it would loop with no 3 | % intervening negation. Similarly, r can succeed only if p succeeds through the 4 | % first rule. Even with partial answer sets, not q will always be in any answer 5 | % set with p or r. 6 | 7 | p :- not q. 8 | q :- not p. 9 | p :- r. 10 | r :- p. 11 | 12 | _out :- r. 13 | _out :- p. 14 | _out :- q. 15 | 16 | #compute 0 { _out }. 17 | %:- not _out. 18 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test10.pl: -------------------------------------------------------------------------------- 1 | % { p, q, r, not s } 2 | p :- q, not s. 3 | q :- r. 4 | r. 5 | s :- not q. 6 | 7 | % #compute 1 { p }. 8 | :- not p. 9 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test11.pl: -------------------------------------------------------------------------------- 1 | % { p, r, not q }, { p, q, not r } 2 | p :- not q, r. 3 | p :- not r, q. 4 | r :- not q. 5 | q :- not r. 6 | % #compute 0 { p }. 7 | :- not p. 8 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test12.pl: -------------------------------------------------------------------------------- 1 | % { p, r, not q, not s } 2 | p :- not q. 3 | q :- r, s. 4 | r :- p. 5 | % #compute 1 { p }. 6 | :- not p. 7 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test13.pl: -------------------------------------------------------------------------------- 1 | % { p, q, r, not s, not t } 2 | p :- q, r. 3 | q :- not s. 4 | r :- not t. 5 | r :- not p. 6 | % #compute 1 { q }. 7 | :- not q. 8 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test14.pl: -------------------------------------------------------------------------------- 1 | % { t, not p, not q, not r, not s, not u } 2 | p :- not t. 3 | t :- not q. 4 | q :- not r, u, not q. 5 | r :- s. 6 | s :- p. 7 | % #compute 1 { not r }. 8 | :- r. 9 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test15.pl: -------------------------------------------------------------------------------- 1 | % false. 2 | % no answer set 3 | a :- not b. 4 | b :- not a. 5 | c :- not d. 6 | d :- not c. 7 | :- a, d. 8 | :- a, c. 9 | :- b, c. 10 | :- b, d. 11 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test16.pl: -------------------------------------------------------------------------------- 1 | % { a, b, c, not d, not e }, { a, c, d, not b, not e } 2 | % test of factorization 3 | a :- b, c. 4 | a :- d, c. 5 | a :- c, b, e. 6 | 7 | c :- not e. 8 | e :- not c. 9 | 10 | b :- not d. 11 | d :- not b. 12 | 13 | % #compute 2 {a}. 14 | :- not a. 15 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test17.pl: -------------------------------------------------------------------------------- 1 | % { p, not q } 2 | p :- not q. 3 | :- not p. 4 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test18.pl: -------------------------------------------------------------------------------- 1 | % { bird(tweety), flies(tweety), not -flies(tweety) }, { -flies(tweety), bird(tweety), not flies(tweety) } 2 | bird(tweety). 3 | 4 | flies(tweety) :- bird(tweety), not -flies(tweety). 5 | 6 | -flies(tweety) :- bird(tweety), not flies(tweety). 7 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test19.pl: -------------------------------------------------------------------------------- 1 | % false. 2 | bird(tux). 3 | penguin(tux). 4 | bird(tweety). 5 | chicken(tweety). 6 | 7 | flies(tux) :- bird(tux), not -flies(tux). 8 | 9 | -flies(tux) :- bird(tux), not flies(tux). 10 | -flies(tux) :- penguin(tux). 11 | 12 | flies(tweety) :- bird(tweety), not -flies(tweety). 13 | 14 | -flies(tweety) :- bird(tweety), not flies(tweety). 15 | -flies(tweety) :- penguin(tweety). 16 | 17 | :- flies(tux), -flies(tux). 18 | :- flies(tweety), -flies(tweety). 19 | 20 | flies(tux). 21 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test2.pl: -------------------------------------------------------------------------------- 1 | % { not p, not q, not r } 2 | % all must fail: no rules for q and r, only an OLON rule for p. 3 | 4 | p :- q, not p, r. 5 | 6 | %#compute 2 {not p, not q, not r}. 7 | comp :- not p, not q, not r. 8 | :- not comp. 9 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test20.pl: -------------------------------------------------------------------------------- 1 | % false. 2 | p(X) :- not q(X). 3 | q(X) :- not p(X). 4 | 5 | r(X) :- X \= 1, p(X), not r(X). 6 | s(X) :- X \= 2, p(X), not s(X). 7 | 8 | ?- p(X). 9 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test21.pl: -------------------------------------------------------------------------------- 1 | % { p(2), ... not p(Var20) ( Var20 \= 1, Var20 \= 2 ), not p(Var40) ( Var40 \= 2 ), not q(2) } 2 | p(X) :- not q(X). 3 | q(X) :- not p(X). 4 | 5 | r(X) :- X \= 1, X \= 2, p(X), not r(X). 6 | s(X) :- X \= 2, p(X), not s(X). 7 | 8 | ?- p(X). 9 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test3.pl: -------------------------------------------------------------------------------- 1 | % false. 2 | % Contradiction: OLON rule forces q to be false, fact forces it to be true. 3 | 4 | p :- q, not p. 5 | q. 6 | 7 | _out :- p. 8 | _out :- q. 9 | _out :- not p. 10 | _out :- not q. 11 | 12 | % #compute 1 { _out }. 13 | :- not _out. 14 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test4.pl: -------------------------------------------------------------------------------- 1 | % { p, not q } 2 | % p will always succeed through the fact. q fails due to the OLON rule and lack 3 | % of rules for q. 4 | 5 | p :- q, not p. 6 | p. 7 | 8 | % #compute 1 {p}. 9 | :- not p. 10 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test5.pl: -------------------------------------------------------------------------------- 1 | % { q, r, not p } 2 | % Rules for p, r and q.1 are both ordinary and OLON: even loop through q.2, odd 3 | % loop through q.1. 4 | 5 | p :- not q. 6 | q :- not r. 7 | r :- not p. 8 | q :- not p. 9 | 10 | % #compute 1 { q }. 11 | :- not q. 12 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test6.pl: -------------------------------------------------------------------------------- 1 | % answer set: { not p, not q } 2 | % Positive loop only: no success unless positive loops are enabled. 3 | 4 | p :- q. 5 | q :- p. 6 | 7 | % #compute 1 { not p }. 8 | :- p. 9 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test7.pl: -------------------------------------------------------------------------------- 1 | % { q, r, not p, not s } 2 | % Two even loops allow selection, but the OLON forces r to succeed. 3 | 4 | p :- not q. 5 | q :- not p. % (p ^ not q) V (q ^ not p) 6 | r :- not s, q. 7 | s :- not r. % (r ^ not s) V (s ^ not r) 8 | 9 | % #compute 1 { r }. 10 | :- not r. 11 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test8.pl: -------------------------------------------------------------------------------- 1 | % { q, s, not p, not r } 2 | % for ?- q, s. : { q, not p, s, not r } 3 | 4 | p :- not q. 5 | q :- not p. 6 | r :- not s. 7 | s :- not r. 8 | 9 | % #compute 1 {q,s}. 10 | comp :- q, s. 11 | :- not comp. 12 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/test9.pl: -------------------------------------------------------------------------------- 1 | % false. 2 | % Even loop with no negation through r must fail unless positive loops are 3 | % enabled. 4 | 5 | p :- not q, r. 6 | q :- not p. 7 | r :- p. 8 | 9 | % #compute 1 { p }. 10 | :- not p. 11 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/varcon.pl: -------------------------------------------------------------------------------- 1 | p(X) :- X \= Y, q(Y). 2 | q(X) :- X \= Y, p(X). 3 | 4 | #compute 1 {p(X)}. 5 | -------------------------------------------------------------------------------- /ATTIC/test_sasp/vars_optional.pl: -------------------------------------------------------------------------------- 1 | p(X) :- not q(X, Y). 2 | q(X, Y) :- not p(X), s(Y). 3 | r :- q(C, C). 4 | s(_). 5 | :- p(X), Z \= 7, q(Z, 0). 6 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/ball_asp.pl: -------------------------------------------------------------------------------- 1 | 2 | final(s0). 3 | final(s2). 4 | 5 | path(A,B,R) :- 6 | A = s(s0,0,_), B = s(F,5,_), 7 | reach(A,B,R), 8 | final(F). 9 | 10 | reach(A,B,[A-Action,B]) :- 11 | trans(A,B,Action). 12 | reach(A,B,[A-Action|R]) :- 13 | trans(A,Z,Action), 14 | reach(Z,B,R). 15 | 16 | trans(s(s0,T0, C0), s(s1, T1, C1), drop(T1)) :- 17 | T1 .>=. T0 + 1, 18 | drop(T1), 19 | C1 .=. 0. 20 | trans(s(s1,T1, C1), s(s0, T00, C00), catch(T00)) :- 21 | T00 .>=. T1 + 1, 22 | C00 .=. T00 - T1, 23 | catch(T00), 24 | C00 .<. 2. 25 | trans(s(s1,T1, C1), s(s2, T2, C2), wait(T2)) :- 26 | T2 .>=. T1 + 1, 27 | C2 .=. T2 - T1, 28 | not catch(T2), 29 | C2 .>=. 2. 30 | 31 | catch(T) :- not wait(T). 32 | wait(T) :- not catch(T). 33 | 34 | drop(T) :- not negdrop(T). 35 | negdrop(T) :- not drop(T). 36 | 37 | 38 | p(A, B, R) :- catch(T), path(A,B,R), T < 5. 39 | 40 | 41 | 42 | s:- r. 43 | r:- p(1), p(1). 44 | 45 | p(1). 46 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/clingcon_example.pl: -------------------------------------------------------------------------------- 1 | end(20). 2 | stepsize(7). 3 | step(N) :- 4 | end(E), 5 | bet(0,E,N). 6 | bet(N, M, N) :- N =< M. 7 | bet(N, M, K) :- N < M, N1 is N+1, bet(N1, M, K). 8 | 9 | at(0, S) :- S .=. 0. 10 | 11 | move(T) :- step(T), not neg_move(T). 12 | neg_move(T) :- step(T), not move(T). 13 | 14 | at(T1, S1) :- 15 | move(T), 16 | stepsize(St), 17 | T1 .=. T - 1, 18 | S1 .=. St + S, 19 | at(T, S). 20 | 21 | at(T1, S) :- 22 | not move(T), 23 | step(T), 24 | T1 .=. T - 1, 25 | step(T1), 26 | at(T, S). 27 | 28 | % :- end(E), S .=<. 100, at(E,S). 29 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/cross_train_Pontelli_97_execution.txt: -------------------------------------------------------------------------------- 1 | Ciao 1.16.0-alpha.3 (2017-08-23 15:19:45 -0500) [DARWINi686] 2 | ?- ensure_loaded('/Users/joaquin/Documents/Imdea/ASP/sCASP/test_scasp/cross_train_Pontelli_97.pl'). 3 | 4 | yes 5 | ?- findrange(M,N,X). 6 | 7 | X = [approach,lower,down,inn,out,exit,raise,up,approach], 8 | M.>.N, 9 | M.>.1.0, 10 | N.<.7.0, 11 | N.>.0 ? 12 | 13 | yes 14 | ?- downmorethan10. 15 | 16 | no 17 | ?- downbeforein(X). 18 | 19 | no 20 | ?- 21 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/ezsmt_light.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | hour_dom(D) :- D .>. 0, D .<. 23. 5 | 6 | switch :- not neg_switch. 7 | neg_switch :- not switch. 8 | 9 | lightOn :- switch, not am. 10 | 11 | % :- not lightOn. 12 | 13 | am :- not neg_am. 14 | neg_am :- not am. 15 | 16 | hour(X) :- hour_dom(X), X .>=. 12, not am. 17 | hour(X) :- hour_dom(X), X .<. 12, am. 18 | 19 | light_is(on) :- lightOn. 20 | light_is(off) :- not lightOn. 21 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/s.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | :- s. 5 | 6 | p(a). 7 | 8 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/01-weight_assignment_tree-654-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,49,67). 2 | leafWeightCardinality(leaf2,60,21). 3 | leafWeightCardinality(leaf3,20,21). 4 | leafWeightCardinality(leaf4,5,70). 5 | leafWeightCardinality(leaf5,25,54). 6 | leafWeightCardinality(leaf6,19,29). 7 | leafWeightCardinality(leaf7,25,49). 8 | leafWeightCardinality(leaf8,35,41). 9 | leafWeightCardinality(leaf9,53,32). 10 | leafWeightCardinality(leaf10,10,49). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(654). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/02-weight_assignment_tree-687-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,36,19). 2 | leafWeightCardinality(leaf2,8,49). 3 | leafWeightCardinality(leaf3,16,51). 4 | leafWeightCardinality(leaf4,72,54). 5 | leafWeightCardinality(leaf5,67,28). 6 | leafWeightCardinality(leaf6,26,4). 7 | leafWeightCardinality(leaf7,17,44). 8 | leafWeightCardinality(leaf8,25,44). 9 | leafWeightCardinality(leaf9,56,42). 10 | leafWeightCardinality(leaf10,64,47). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(687). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/03-weight_assignment_tree-742-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,81,1). 2 | leafWeightCardinality(leaf2,4,4). 3 | leafWeightCardinality(leaf3,15,36). 4 | leafWeightCardinality(leaf4,14,8). 5 | leafWeightCardinality(leaf5,12,32). 6 | leafWeightCardinality(leaf6,65,46). 7 | leafWeightCardinality(leaf7,35,57). 8 | leafWeightCardinality(leaf8,92,31). 9 | leafWeightCardinality(leaf9,56,81). 10 | leafWeightCardinality(leaf10,66,73). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(742). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/04-weight_assignment_tree-612-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,81,1). 2 | leafWeightCardinality(leaf2,4,4). 3 | leafWeightCardinality(leaf3,15,36). 4 | leafWeightCardinality(leaf4,14,8). 5 | leafWeightCardinality(leaf5,12,32). 6 | leafWeightCardinality(leaf6,65,46). 7 | leafWeightCardinality(leaf7,35,57). 8 | leafWeightCardinality(leaf8,92,31). 9 | leafWeightCardinality(leaf9,56,81). 10 | leafWeightCardinality(leaf10,66,73). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(612). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/05-weight_assignment_tree-579-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,81,1). 2 | leafWeightCardinality(leaf2,4,4). 3 | leafWeightCardinality(leaf3,15,36). 4 | leafWeightCardinality(leaf4,14,8). 5 | leafWeightCardinality(leaf5,12,32). 6 | leafWeightCardinality(leaf6,65,46). 7 | leafWeightCardinality(leaf7,35,57). 8 | leafWeightCardinality(leaf8,92,31). 9 | leafWeightCardinality(leaf9,56,81). 10 | leafWeightCardinality(leaf10,66,73). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(579). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/06-weight_assignment_tree-560-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,81,1). 2 | leafWeightCardinality(leaf2,4,4). 3 | leafWeightCardinality(leaf3,15,36). 4 | leafWeightCardinality(leaf4,14,8). 5 | leafWeightCardinality(leaf5,12,32). 6 | leafWeightCardinality(leaf6,65,46). 7 | leafWeightCardinality(leaf7,35,57). 8 | leafWeightCardinality(leaf8,92,31). 9 | leafWeightCardinality(leaf9,56,81). 10 | leafWeightCardinality(leaf10,66,73). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(560). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/07-weight_assignment_tree-547-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,81,1). 2 | leafWeightCardinality(leaf2,4,4). 3 | leafWeightCardinality(leaf3,15,36). 4 | leafWeightCardinality(leaf4,14,8). 5 | leafWeightCardinality(leaf5,12,32). 6 | leafWeightCardinality(leaf6,65,46). 7 | leafWeightCardinality(leaf7,35,57). 8 | leafWeightCardinality(leaf8,92,31). 9 | leafWeightCardinality(leaf9,56,81). 10 | leafWeightCardinality(leaf10,66,73). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(547). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/08-weight_assignment_tree-806-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,8,74). 2 | leafWeightCardinality(leaf2,97,21). 3 | leafWeightCardinality(leaf3,17,56). 4 | leafWeightCardinality(leaf4,76,25). 5 | leafWeightCardinality(leaf5,36,78). 6 | leafWeightCardinality(leaf6,32,18). 7 | leafWeightCardinality(leaf7,1,42). 8 | leafWeightCardinality(leaf8,51,39). 9 | leafWeightCardinality(leaf9,98,73). 10 | leafWeightCardinality(leaf10,95,25). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(806). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/09-weight_assignment_tree-778-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,56,24). 2 | leafWeightCardinality(leaf2,3,1). 3 | leafWeightCardinality(leaf3,98,94). 4 | leafWeightCardinality(leaf4,35,64). 5 | leafWeightCardinality(leaf5,32,72). 6 | leafWeightCardinality(leaf6,50,18). 7 | leafWeightCardinality(leaf7,57,15). 8 | leafWeightCardinality(leaf8,28,94). 9 | leafWeightCardinality(leaf9,87,85). 10 | leafWeightCardinality(leaf10,60,20). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(778). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/10-weight_assignment_tree-938-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,29,16). 2 | leafWeightCardinality(leaf2,12,90). 3 | leafWeightCardinality(leaf3,91,51). 4 | leafWeightCardinality(leaf4,14,93). 5 | leafWeightCardinality(leaf5,53,13). 6 | leafWeightCardinality(leaf6,26,86). 7 | leafWeightCardinality(leaf7,96,76). 8 | leafWeightCardinality(leaf8,55,79). 9 | leafWeightCardinality(leaf9,45,49). 10 | leafWeightCardinality(leaf10,72,35). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(938). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/11-weight_assignment_tree-934-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,29,16). 2 | leafWeightCardinality(leaf2,12,90). 3 | leafWeightCardinality(leaf3,91,51). 4 | leafWeightCardinality(leaf4,14,93). 5 | leafWeightCardinality(leaf5,53,13). 6 | leafWeightCardinality(leaf6,26,86). 7 | leafWeightCardinality(leaf7,96,76). 8 | leafWeightCardinality(leaf8,55,79). 9 | leafWeightCardinality(leaf9,45,49). 10 | leafWeightCardinality(leaf10,72,35). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(934). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/12-weight_assignment_tree-918-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,29,16). 2 | leafWeightCardinality(leaf2,12,90). 3 | leafWeightCardinality(leaf3,91,51). 4 | leafWeightCardinality(leaf4,14,93). 5 | leafWeightCardinality(leaf5,53,13). 6 | leafWeightCardinality(leaf6,26,86). 7 | leafWeightCardinality(leaf7,96,76). 8 | leafWeightCardinality(leaf8,55,79). 9 | leafWeightCardinality(leaf9,45,49). 10 | leafWeightCardinality(leaf10,72,35). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(918). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/13-weight_assignment_tree-901-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,29,16). 2 | leafWeightCardinality(leaf2,12,90). 3 | leafWeightCardinality(leaf3,91,51). 4 | leafWeightCardinality(leaf4,14,93). 5 | leafWeightCardinality(leaf5,53,13). 6 | leafWeightCardinality(leaf6,26,86). 7 | leafWeightCardinality(leaf7,96,76). 8 | leafWeightCardinality(leaf8,55,79). 9 | leafWeightCardinality(leaf9,45,49). 10 | leafWeightCardinality(leaf10,72,35). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(901). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/14-weight_assignment_tree-1070-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,92,61). 2 | leafWeightCardinality(leaf2,68,41). 3 | leafWeightCardinality(leaf3,63,57). 4 | leafWeightCardinality(leaf4,81,74). 5 | leafWeightCardinality(leaf5,60,92). 6 | leafWeightCardinality(leaf6,97,81). 7 | leafWeightCardinality(leaf7,85,14). 8 | leafWeightCardinality(leaf8,16,51). 9 | leafWeightCardinality(leaf9,43,27). 10 | leafWeightCardinality(leaf10,97,53). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1070). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/15-weight_assignment_tree-868-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,49,33). 2 | leafWeightCardinality(leaf2,51,55). 3 | leafWeightCardinality(leaf3,41,75). 4 | leafWeightCardinality(leaf4,7,27). 5 | leafWeightCardinality(leaf5,10,47). 6 | leafWeightCardinality(leaf6,64,73). 7 | leafWeightCardinality(leaf7,0,71). 8 | leafWeightCardinality(leaf8,40,89). 9 | leafWeightCardinality(leaf9,29,79). 10 | leafWeightCardinality(leaf10,85,86). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(868). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/16-weight_assignment_tree-862-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,49,33). 2 | leafWeightCardinality(leaf2,51,55). 3 | leafWeightCardinality(leaf3,41,75). 4 | leafWeightCardinality(leaf4,7,27). 5 | leafWeightCardinality(leaf5,10,47). 6 | leafWeightCardinality(leaf6,64,73). 7 | leafWeightCardinality(leaf7,0,71). 8 | leafWeightCardinality(leaf8,40,89). 9 | leafWeightCardinality(leaf9,29,79). 10 | leafWeightCardinality(leaf10,85,86). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(862). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/17-weight_assignment_tree-854-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,49,33). 2 | leafWeightCardinality(leaf2,51,55). 3 | leafWeightCardinality(leaf3,41,75). 4 | leafWeightCardinality(leaf4,7,27). 5 | leafWeightCardinality(leaf5,10,47). 6 | leafWeightCardinality(leaf6,64,73). 7 | leafWeightCardinality(leaf7,0,71). 8 | leafWeightCardinality(leaf8,40,89). 9 | leafWeightCardinality(leaf9,29,79). 10 | leafWeightCardinality(leaf10,85,86). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(854). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/18-weight_assignment_tree-851-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,49,33). 2 | leafWeightCardinality(leaf2,51,55). 3 | leafWeightCardinality(leaf3,41,75). 4 | leafWeightCardinality(leaf4,7,27). 5 | leafWeightCardinality(leaf5,10,47). 6 | leafWeightCardinality(leaf6,64,73). 7 | leafWeightCardinality(leaf7,0,71). 8 | leafWeightCardinality(leaf8,40,89). 9 | leafWeightCardinality(leaf9,29,79). 10 | leafWeightCardinality(leaf10,85,86). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(851). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/19-weight_assignment_tree-833-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,49,33). 2 | leafWeightCardinality(leaf2,51,55). 3 | leafWeightCardinality(leaf3,41,75). 4 | leafWeightCardinality(leaf4,7,27). 5 | leafWeightCardinality(leaf5,10,47). 6 | leafWeightCardinality(leaf6,64,73). 7 | leafWeightCardinality(leaf7,0,71). 8 | leafWeightCardinality(leaf8,40,89). 9 | leafWeightCardinality(leaf9,29,79). 10 | leafWeightCardinality(leaf10,85,86). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(833). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/20-weight_assignment_tree-997-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,87,33). 2 | leafWeightCardinality(leaf2,17,93). 3 | leafWeightCardinality(leaf3,77,42). 4 | leafWeightCardinality(leaf4,4,56). 5 | leafWeightCardinality(leaf5,86,70). 6 | leafWeightCardinality(leaf6,20,75). 7 | leafWeightCardinality(leaf7,24,88). 8 | leafWeightCardinality(leaf8,64,26). 9 | leafWeightCardinality(leaf9,95,11). 10 | leafWeightCardinality(leaf10,71,83). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(997). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/21-weight_assignment_tree-545-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,4,41). 2 | leafWeightCardinality(leaf2,3,62). 3 | leafWeightCardinality(leaf3,72,32). 4 | leafWeightCardinality(leaf4,3,47). 5 | leafWeightCardinality(leaf5,33,72). 6 | leafWeightCardinality(leaf6,59,1). 7 | leafWeightCardinality(leaf7,1,62). 8 | leafWeightCardinality(leaf8,46,33). 9 | leafWeightCardinality(leaf9,60,52). 10 | leafWeightCardinality(leaf10,5,16). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(545). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/22-weight_assignment_tree-539-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,4,41). 2 | leafWeightCardinality(leaf2,3,62). 3 | leafWeightCardinality(leaf3,72,32). 4 | leafWeightCardinality(leaf4,3,47). 5 | leafWeightCardinality(leaf5,33,72). 6 | leafWeightCardinality(leaf6,59,1). 7 | leafWeightCardinality(leaf7,1,62). 8 | leafWeightCardinality(leaf8,46,33). 9 | leafWeightCardinality(leaf9,60,52). 10 | leafWeightCardinality(leaf10,5,16). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(539). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/23-weight_assignment_tree-891-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,73,68). 2 | leafWeightCardinality(leaf2,86,23). 3 | leafWeightCardinality(leaf3,88,63). 4 | leafWeightCardinality(leaf4,10,22). 5 | leafWeightCardinality(leaf5,54,83). 6 | leafWeightCardinality(leaf6,62,60). 7 | leafWeightCardinality(leaf7,21,49). 8 | leafWeightCardinality(leaf8,8,81). 9 | leafWeightCardinality(leaf9,4,93). 10 | leafWeightCardinality(leaf10,50,97). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(891). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/24-weight_assignment_tree-814-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,41,62). 2 | leafWeightCardinality(leaf2,99,99). 3 | leafWeightCardinality(leaf3,39,25). 4 | leafWeightCardinality(leaf4,33,41). 5 | leafWeightCardinality(leaf5,51,40). 6 | leafWeightCardinality(leaf6,76,74). 7 | leafWeightCardinality(leaf7,13,55). 8 | leafWeightCardinality(leaf8,9,2). 9 | leafWeightCardinality(leaf9,42,84). 10 | leafWeightCardinality(leaf10,18,49). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(814). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/25-weight_assignment_tree-782-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,41,62). 2 | leafWeightCardinality(leaf2,99,99). 3 | leafWeightCardinality(leaf3,39,25). 4 | leafWeightCardinality(leaf4,33,41). 5 | leafWeightCardinality(leaf5,51,40). 6 | leafWeightCardinality(leaf6,76,74). 7 | leafWeightCardinality(leaf7,13,55). 8 | leafWeightCardinality(leaf8,9,2). 9 | leafWeightCardinality(leaf9,42,84). 10 | leafWeightCardinality(leaf10,18,49). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(782). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/26-weight_assignment_tree-764-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,41,62). 2 | leafWeightCardinality(leaf2,99,99). 3 | leafWeightCardinality(leaf3,39,25). 4 | leafWeightCardinality(leaf4,33,41). 5 | leafWeightCardinality(leaf5,51,40). 6 | leafWeightCardinality(leaf6,76,74). 7 | leafWeightCardinality(leaf7,13,55). 8 | leafWeightCardinality(leaf8,9,2). 9 | leafWeightCardinality(leaf9,42,84). 10 | leafWeightCardinality(leaf10,18,49). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(764). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/27-weight_assignment_tree-755-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,41,62). 2 | leafWeightCardinality(leaf2,99,99). 3 | leafWeightCardinality(leaf3,39,25). 4 | leafWeightCardinality(leaf4,33,41). 5 | leafWeightCardinality(leaf5,51,40). 6 | leafWeightCardinality(leaf6,76,74). 7 | leafWeightCardinality(leaf7,13,55). 8 | leafWeightCardinality(leaf8,9,2). 9 | leafWeightCardinality(leaf9,42,84). 10 | leafWeightCardinality(leaf10,18,49). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(755). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/28-weight_assignment_tree-646-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,33,68). 2 | leafWeightCardinality(leaf2,57,39). 3 | leafWeightCardinality(leaf3,42,55). 4 | leafWeightCardinality(leaf4,18,29). 5 | leafWeightCardinality(leaf5,22,70). 6 | leafWeightCardinality(leaf6,66,22). 7 | leafWeightCardinality(leaf7,70,68). 8 | leafWeightCardinality(leaf8,17,14). 9 | leafWeightCardinality(leaf9,1,10). 10 | leafWeightCardinality(leaf10,32,47). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(646). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/29-weight_assignment_tree-644-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,33,68). 2 | leafWeightCardinality(leaf2,57,39). 3 | leafWeightCardinality(leaf3,42,55). 4 | leafWeightCardinality(leaf4,18,29). 5 | leafWeightCardinality(leaf5,22,70). 6 | leafWeightCardinality(leaf6,66,22). 7 | leafWeightCardinality(leaf7,70,68). 8 | leafWeightCardinality(leaf8,17,14). 9 | leafWeightCardinality(leaf9,1,10). 10 | leafWeightCardinality(leaf10,32,47). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(644). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/30-weight_assignment_tree-631-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,33,68). 2 | leafWeightCardinality(leaf2,57,39). 3 | leafWeightCardinality(leaf3,42,55). 4 | leafWeightCardinality(leaf4,18,29). 5 | leafWeightCardinality(leaf5,22,70). 6 | leafWeightCardinality(leaf6,66,22). 7 | leafWeightCardinality(leaf7,70,68). 8 | leafWeightCardinality(leaf8,17,14). 9 | leafWeightCardinality(leaf9,1,10). 10 | leafWeightCardinality(leaf10,32,47). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(631). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/31-weight_assignment_tree-863-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,82,3). 2 | leafWeightCardinality(leaf2,26,19). 3 | leafWeightCardinality(leaf3,51,5). 4 | leafWeightCardinality(leaf4,36,22). 5 | leafWeightCardinality(leaf5,71,91). 6 | leafWeightCardinality(leaf6,97,74). 7 | leafWeightCardinality(leaf7,39,13). 8 | leafWeightCardinality(leaf8,98,51). 9 | leafWeightCardinality(leaf9,35,85). 10 | leafWeightCardinality(leaf10,30,70). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(863). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/32-weight_assignment_tree-812-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,82,3). 2 | leafWeightCardinality(leaf2,26,19). 3 | leafWeightCardinality(leaf3,51,5). 4 | leafWeightCardinality(leaf4,36,22). 5 | leafWeightCardinality(leaf5,71,91). 6 | leafWeightCardinality(leaf6,97,74). 7 | leafWeightCardinality(leaf7,39,13). 8 | leafWeightCardinality(leaf8,98,51). 9 | leafWeightCardinality(leaf9,35,85). 10 | leafWeightCardinality(leaf10,30,70). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(812). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/33-weight_assignment_tree-810-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,82,3). 2 | leafWeightCardinality(leaf2,26,19). 3 | leafWeightCardinality(leaf3,51,5). 4 | leafWeightCardinality(leaf4,36,22). 5 | leafWeightCardinality(leaf5,71,91). 6 | leafWeightCardinality(leaf6,97,74). 7 | leafWeightCardinality(leaf7,39,13). 8 | leafWeightCardinality(leaf8,98,51). 9 | leafWeightCardinality(leaf9,35,85). 10 | leafWeightCardinality(leaf10,30,70). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(810). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/34-weight_assignment_tree-809-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,82,3). 2 | leafWeightCardinality(leaf2,26,19). 3 | leafWeightCardinality(leaf3,51,5). 4 | leafWeightCardinality(leaf4,36,22). 5 | leafWeightCardinality(leaf5,71,91). 6 | leafWeightCardinality(leaf6,97,74). 7 | leafWeightCardinality(leaf7,39,13). 8 | leafWeightCardinality(leaf8,98,51). 9 | leafWeightCardinality(leaf9,35,85). 10 | leafWeightCardinality(leaf10,30,70). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(809). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/35-weight_assignment_tree-805-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,82,3). 2 | leafWeightCardinality(leaf2,26,19). 3 | leafWeightCardinality(leaf3,51,5). 4 | leafWeightCardinality(leaf4,36,22). 5 | leafWeightCardinality(leaf5,71,91). 6 | leafWeightCardinality(leaf6,97,74). 7 | leafWeightCardinality(leaf7,39,13). 8 | leafWeightCardinality(leaf8,98,51). 9 | leafWeightCardinality(leaf9,35,85). 10 | leafWeightCardinality(leaf10,30,70). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(805). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/36-weight_assignment_tree-802-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,82,3). 2 | leafWeightCardinality(leaf2,26,19). 3 | leafWeightCardinality(leaf3,51,5). 4 | leafWeightCardinality(leaf4,36,22). 5 | leafWeightCardinality(leaf5,71,91). 6 | leafWeightCardinality(leaf6,97,74). 7 | leafWeightCardinality(leaf7,39,13). 8 | leafWeightCardinality(leaf8,98,51). 9 | leafWeightCardinality(leaf9,35,85). 10 | leafWeightCardinality(leaf10,30,70). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(802). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/37-weight_assignment_tree-797-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,80,35). 2 | leafWeightCardinality(leaf2,46,4). 3 | leafWeightCardinality(leaf3,1,40). 4 | leafWeightCardinality(leaf4,96,33). 5 | leafWeightCardinality(leaf5,30,30). 6 | leafWeightCardinality(leaf6,96,61). 7 | leafWeightCardinality(leaf7,66,59). 8 | leafWeightCardinality(leaf8,16,98). 9 | leafWeightCardinality(leaf9,0,93). 10 | leafWeightCardinality(leaf10,19,53). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1164). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/38-weight_assignment_tree-879-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,95,9). 2 | leafWeightCardinality(leaf2,18,99). 3 | leafWeightCardinality(leaf3,59,29). 4 | leafWeightCardinality(leaf4,98,31). 5 | leafWeightCardinality(leaf5,46,37). 6 | leafWeightCardinality(leaf6,50,6). 7 | leafWeightCardinality(leaf7,99,96). 8 | leafWeightCardinality(leaf8,9,8). 9 | leafWeightCardinality(leaf9,82,32). 10 | leafWeightCardinality(leaf10,68,62). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(836). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/39-weight_assignment_tree-953-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,19,99). 2 | leafWeightCardinality(leaf2,98,76). 3 | leafWeightCardinality(leaf3,49,8). 4 | leafWeightCardinality(leaf4,97,30). 5 | leafWeightCardinality(leaf5,66,95). 6 | leafWeightCardinality(leaf6,3,69). 7 | leafWeightCardinality(leaf7,65,44). 8 | leafWeightCardinality(leaf8,75,37). 9 | leafWeightCardinality(leaf9,7,50). 10 | leafWeightCardinality(leaf10,46,13). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(953). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/40-weight_assignment_tree-944-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,19,99). 2 | leafWeightCardinality(leaf2,98,76). 3 | leafWeightCardinality(leaf3,49,8). 4 | leafWeightCardinality(leaf4,97,30). 5 | leafWeightCardinality(leaf5,66,95). 6 | leafWeightCardinality(leaf6,3,69). 7 | leafWeightCardinality(leaf7,65,44). 8 | leafWeightCardinality(leaf8,75,37). 9 | leafWeightCardinality(leaf9,7,50). 10 | leafWeightCardinality(leaf10,46,13). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(944). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/41-weight_assignment_tree-718-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,18,54). 2 | leafWeightCardinality(leaf2,58,50). 3 | leafWeightCardinality(leaf3,23,62). 4 | leafWeightCardinality(leaf4,34,69). 5 | leafWeightCardinality(leaf5,59,31). 6 | leafWeightCardinality(leaf6,23,67). 7 | leafWeightCardinality(leaf7,64,63). 8 | leafWeightCardinality(leaf8,62,5). 9 | leafWeightCardinality(leaf9,6,28). 10 | leafWeightCardinality(leaf10,4,52). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(718). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/42-weight_assignment_tree-367-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,14,27). 2 | leafWeightCardinality(leaf2,35,7). 3 | leafWeightCardinality(leaf3,42,3). 4 | leafWeightCardinality(leaf4,1,13). 5 | leafWeightCardinality(leaf5,4,39). 6 | leafWeightCardinality(leaf6,37,31). 7 | leafWeightCardinality(leaf7,19,18). 8 | leafWeightCardinality(leaf8,35,39). 9 | leafWeightCardinality(leaf9,19,49). 10 | leafWeightCardinality(leaf10,22,5). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(367). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/43-weight_assignment_tree-645-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,19,70). 2 | leafWeightCardinality(leaf2,29,11). 3 | leafWeightCardinality(leaf3,39,28). 4 | leafWeightCardinality(leaf4,31,57). 5 | leafWeightCardinality(leaf5,52,2). 6 | leafWeightCardinality(leaf6,48,61). 7 | leafWeightCardinality(leaf7,60,16). 8 | leafWeightCardinality(leaf8,7,32). 9 | leafWeightCardinality(leaf9,72,36). 10 | leafWeightCardinality(leaf10,39,37). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(645). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/44-weight_assignment_tree-365-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,39,14). 2 | leafWeightCardinality(leaf2,35,4). 3 | leafWeightCardinality(leaf3,18,44). 4 | leafWeightCardinality(leaf4,14,17). 5 | leafWeightCardinality(leaf5,18,35). 6 | leafWeightCardinality(leaf6,6,33). 7 | leafWeightCardinality(leaf7,12,38). 8 | leafWeightCardinality(leaf8,26,6). 9 | leafWeightCardinality(leaf9,27,4). 10 | leafWeightCardinality(leaf10,22,16). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(365). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/45-weight_assignment_tree-312-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,25,33). 2 | leafWeightCardinality(leaf2,31,32). 3 | leafWeightCardinality(leaf3,17,2). 4 | leafWeightCardinality(leaf4,5,1). 5 | leafWeightCardinality(leaf5,47,28). 6 | leafWeightCardinality(leaf6,9,8). 7 | leafWeightCardinality(leaf7,27,22). 8 | leafWeightCardinality(leaf8,15,47). 9 | leafWeightCardinality(leaf9,5,15). 10 | leafWeightCardinality(leaf10,18,12). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(312). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/46-weight_assignment_tree-764-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,51,32). 2 | leafWeightCardinality(leaf2,10,65). 3 | leafWeightCardinality(leaf3,23,66). 4 | leafWeightCardinality(leaf4,50,13). 5 | leafWeightCardinality(leaf5,53,71). 6 | leafWeightCardinality(leaf6,64,32). 7 | leafWeightCardinality(leaf7,73,7). 8 | leafWeightCardinality(leaf8,15,29). 9 | leafWeightCardinality(leaf9,66,27). 10 | leafWeightCardinality(leaf10,72,63). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(764). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/47-weight_assignment_tree-474-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,37,1). 2 | leafWeightCardinality(leaf2,35,68). 3 | leafWeightCardinality(leaf3,56,52). 4 | leafWeightCardinality(leaf4,42,62). 5 | leafWeightCardinality(leaf5,38,36). 6 | leafWeightCardinality(leaf6,4,56). 7 | leafWeightCardinality(leaf7,14,17). 8 | leafWeightCardinality(leaf8,5,10). 9 | leafWeightCardinality(leaf9,18,15). 10 | leafWeightCardinality(leaf10,2,63). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(474). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/48-weight_assignment_tree-285-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,25,33). 2 | leafWeightCardinality(leaf2,31,32). 3 | leafWeightCardinality(leaf3,17,2). 4 | leafWeightCardinality(leaf4,5,1). 5 | leafWeightCardinality(leaf5,47,28). 6 | leafWeightCardinality(leaf6,9,8). 7 | leafWeightCardinality(leaf7,27,22). 8 | leafWeightCardinality(leaf8,15,47). 9 | leafWeightCardinality(leaf9,5,15). 10 | leafWeightCardinality(leaf10,18,12). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(285). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/49-weight_assignment_tree-272-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,25,33). 2 | leafWeightCardinality(leaf2,31,32). 3 | leafWeightCardinality(leaf3,17,2). 4 | leafWeightCardinality(leaf4,5,1). 5 | leafWeightCardinality(leaf5,47,28). 6 | leafWeightCardinality(leaf6,9,8). 7 | leafWeightCardinality(leaf7,27,22). 8 | leafWeightCardinality(leaf8,15,47). 9 | leafWeightCardinality(leaf9,5,15). 10 | leafWeightCardinality(leaf10,18,12). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(272). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/50-weight_assignment_tree-430-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,38,23). 2 | leafWeightCardinality(leaf2,32,2). 3 | leafWeightCardinality(leaf3,30,9). 4 | leafWeightCardinality(leaf4,14,25). 5 | leafWeightCardinality(leaf5,30,40). 6 | leafWeightCardinality(leaf6,19,20). 7 | leafWeightCardinality(leaf7,31,41). 8 | leafWeightCardinality(leaf8,2,22). 9 | leafWeightCardinality(leaf9,14,38). 10 | leafWeightCardinality(leaf10,41,18). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(430). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/51-weight_assignment_tree-2133-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,65,56). 2 | leafWeightCardinality(leaf2,155,127). 3 | leafWeightCardinality(leaf3,154,154). 4 | leafWeightCardinality(leaf4,76,101). 5 | leafWeightCardinality(leaf5,157,175). 6 | leafWeightCardinality(leaf6,169,108). 7 | leafWeightCardinality(leaf7,10,128). 8 | leafWeightCardinality(leaf8,135,196). 9 | leafWeightCardinality(leaf9,167,101). 10 | leafWeightCardinality(leaf10,70,182). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(2133). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/52-weight_assignment_tree-1777-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,4,28). 2 | leafWeightCardinality(leaf2,178,162). 3 | leafWeightCardinality(leaf3,39,26). 4 | leafWeightCardinality(leaf4,129,45). 5 | leafWeightCardinality(leaf5,108,125). 6 | leafWeightCardinality(leaf6,21,32). 7 | leafWeightCardinality(leaf7,137,169). 8 | leafWeightCardinality(leaf8,104,193). 9 | leafWeightCardinality(leaf9,183,97). 10 | leafWeightCardinality(leaf10,144,162). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1777). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/53-weight_assignment_tree-1685-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,4,28). 2 | leafWeightCardinality(leaf2,178,162). 3 | leafWeightCardinality(leaf3,39,26). 4 | leafWeightCardinality(leaf4,129,45). 5 | leafWeightCardinality(leaf5,108,125). 6 | leafWeightCardinality(leaf6,21,32). 7 | leafWeightCardinality(leaf7,137,169). 8 | leafWeightCardinality(leaf8,104,193). 9 | leafWeightCardinality(leaf9,183,97). 10 | leafWeightCardinality(leaf10,144,162). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1685). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/54-weight_assignment_tree-1642-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,4,28). 2 | leafWeightCardinality(leaf2,178,162). 3 | leafWeightCardinality(leaf3,39,26). 4 | leafWeightCardinality(leaf4,129,45). 5 | leafWeightCardinality(leaf5,108,125). 6 | leafWeightCardinality(leaf6,21,32). 7 | leafWeightCardinality(leaf7,137,169). 8 | leafWeightCardinality(leaf8,104,193). 9 | leafWeightCardinality(leaf9,183,97). 10 | leafWeightCardinality(leaf10,144,162). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1642). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/55-weight_assignment_tree-1620-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,4,28). 2 | leafWeightCardinality(leaf2,178,162). 3 | leafWeightCardinality(leaf3,39,26). 4 | leafWeightCardinality(leaf4,129,45). 5 | leafWeightCardinality(leaf5,108,125). 6 | leafWeightCardinality(leaf6,21,32). 7 | leafWeightCardinality(leaf7,137,169). 8 | leafWeightCardinality(leaf8,104,193). 9 | leafWeightCardinality(leaf9,183,97). 10 | leafWeightCardinality(leaf10,144,162). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1620). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/56-weight_assignment_tree-1735-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,62,15). 2 | leafWeightCardinality(leaf2,197,113). 3 | leafWeightCardinality(leaf3,56,195). 4 | leafWeightCardinality(leaf4,71,9). 5 | leafWeightCardinality(leaf5,147,15). 6 | leafWeightCardinality(leaf6,179,131). 7 | leafWeightCardinality(leaf7,62,111). 8 | leafWeightCardinality(leaf8,33,133). 9 | leafWeightCardinality(leaf9,124,121). 10 | leafWeightCardinality(leaf10,106,112). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1735). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/57-weight_assignment_tree-1694-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,62,15). 2 | leafWeightCardinality(leaf2,197,113). 3 | leafWeightCardinality(leaf3,56,195). 4 | leafWeightCardinality(leaf4,71,9). 5 | leafWeightCardinality(leaf5,147,15). 6 | leafWeightCardinality(leaf6,179,131). 7 | leafWeightCardinality(leaf7,62,111). 8 | leafWeightCardinality(leaf8,33,133). 9 | leafWeightCardinality(leaf9,124,121). 10 | leafWeightCardinality(leaf10,106,112). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1694). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/58-weight_assignment_tree-1647-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,62,15). 2 | leafWeightCardinality(leaf2,197,113). 3 | leafWeightCardinality(leaf3,56,195). 4 | leafWeightCardinality(leaf4,71,9). 5 | leafWeightCardinality(leaf5,147,15). 6 | leafWeightCardinality(leaf6,179,131). 7 | leafWeightCardinality(leaf7,62,111). 8 | leafWeightCardinality(leaf8,33,133). 9 | leafWeightCardinality(leaf9,124,121). 10 | leafWeightCardinality(leaf10,106,112). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1647). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/59-weight_assignment_tree-1595-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,62,15). 2 | leafWeightCardinality(leaf2,197,113). 3 | leafWeightCardinality(leaf3,56,195). 4 | leafWeightCardinality(leaf4,71,9). 5 | leafWeightCardinality(leaf5,147,15). 6 | leafWeightCardinality(leaf6,179,131). 7 | leafWeightCardinality(leaf7,62,111). 8 | leafWeightCardinality(leaf8,33,133). 9 | leafWeightCardinality(leaf9,124,121). 10 | leafWeightCardinality(leaf10,106,112). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1595). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/60-weight_assignment_tree-1588-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,62,15). 2 | leafWeightCardinality(leaf2,197,113). 3 | leafWeightCardinality(leaf3,56,195). 4 | leafWeightCardinality(leaf4,71,9). 5 | leafWeightCardinality(leaf5,147,15). 6 | leafWeightCardinality(leaf6,179,131). 7 | leafWeightCardinality(leaf7,62,111). 8 | leafWeightCardinality(leaf8,33,133). 9 | leafWeightCardinality(leaf9,124,121). 10 | leafWeightCardinality(leaf10,106,112). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1588). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/61-weight_assignment_tree-1542-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,62,15). 2 | leafWeightCardinality(leaf2,197,113). 3 | leafWeightCardinality(leaf3,56,195). 4 | leafWeightCardinality(leaf4,71,9). 5 | leafWeightCardinality(leaf5,147,15). 6 | leafWeightCardinality(leaf6,179,131). 7 | leafWeightCardinality(leaf7,62,111). 8 | leafWeightCardinality(leaf8,33,133). 9 | leafWeightCardinality(leaf9,124,121). 10 | leafWeightCardinality(leaf10,106,112). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(1542). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/instances/62-weight_assignment_tree-2102-0.asp: -------------------------------------------------------------------------------- 1 | leafWeightCardinality(leaf1,133,115). 2 | leafWeightCardinality(leaf2,184,197). 3 | leafWeightCardinality(leaf3,79,71). 4 | leafWeightCardinality(leaf4,52,76). 5 | leafWeightCardinality(leaf5,101,138). 6 | leafWeightCardinality(leaf6,182,39). 7 | leafWeightCardinality(leaf7,193,127). 8 | leafWeightCardinality(leaf8,135,6). 9 | leafWeightCardinality(leaf9,183,115). 10 | leafWeightCardinality(leaf10,134,109). 11 | innerNode(1). 12 | innerNode(2). 13 | innerNode(3). 14 | innerNode(4). 15 | innerNode(5). 16 | innerNode(6). 17 | innerNode(7). 18 | innerNode(8). 19 | innerNode(9). 20 | num(10). 21 | max_total_weight(2102). 22 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/select_instance.asp: -------------------------------------------------------------------------------- 1 | %% USED to select an instance to the benchmarcks.... 2 | 3 | 4 | % #include('instances/01-weight_assignment_tree-654-0.asp'). 5 | % #include('instances/02-weight_assignment_tree-687-0.asp'). 6 | % #include('instances/03-weight_assignment_tree-742-0.asp'). 7 | % #include('instances/04-weight_assignment_tree-612-0.asp'). 8 | % #include('instances/05-weight_assignment_tree-579-0.asp'). 9 | % #include('instances/06-weight_assignment_tree-560-0.asp'). 10 | % #include('instances/07-weight_assignment_tree-547-0.asp'). 11 | % #include('instances/08-weight_assignment_tree-806-0.asp'). 12 | % #include('instances/09-weight_assignment_tree-778-0.asp'). 13 | % #include('instances/10-weight_assignment_tree-938-0.asp'). 14 | % #include('instances/11-weight_assignment_tree-934-0.asp'). 15 | % #include('instances/12-weight_assignment_tree-918-0.asp'). 16 | % #include('instances/13-weight_assignment_tree-901-0.asp'). 17 | #include('instances/14-weight_assignment_tree-1070-0.asp'). 18 | % ... 19 | % #include('instances/60-weight_assignment_tree-1588-0.asp'). 20 | % #include('instances/61-weight_assignment_tree-1542-0.asp'). 21 | % #include('instances/62-weight_assignment_tree-2102-0.asp'). 22 | 23 | %% EXAMPLE 24 | % leafWeightCardinality(leaf1, 4, 5). 25 | % leafWeightCardinality(leaf2, 3, 7). 26 | 27 | % innerNode(1). 28 | 29 | % num(2). 30 | % max_total_weight(9). 31 | %% EXAMPLE 32 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/weight_seq/select_instance.pl: -------------------------------------------------------------------------------- 1 | %% USED to select an instance to the benchmarcks.... 2 | 3 | 4 | % :- include('instances/01-weight_assignment_tree-654-0.asp'). 5 | % :- include('instances/02-weight_assignment_tree-687-0.asp'). 6 | % :- include('instances/03-weight_assignment_tree-742-0.asp'). 7 | % :- include('instances/04-weight_assignment_tree-612-0.asp'). 8 | % :- include('instances/05-weight_assignment_tree-579-0.asp'). 9 | % :- include('instances/06-weight_assignment_tree-560-0.asp'). 10 | % :- include('instances/07-weight_assignment_tree-547-0.asp'). 11 | % :- include('instances/08-weight_assignment_tree-806-0.asp'). 12 | % :- include('instances/09-weight_assignment_tree-778-0.asp'). 13 | % :- include('instances/10-weight_assignment_tree-938-0.asp'). 14 | % :- include('instances/11-weight_assignment_tree-934-0.asp'). 15 | % :- include('instances/12-weight_assignment_tree-918-0.asp'). 16 | % :- include('instances/13-weight_assignment_tree-901-0.asp'). 17 | :- include('instances/14-weight_assignment_tree-1070-0.asp'). 18 | % ... 19 | % :- include('instances/60-weight_assignment_tree-1588-0.asp'). 20 | % :- include('instances/61-weight_assignment_tree-1542-0.asp'). 21 | % :- include('instances/62-weight_assignment_tree-2102-0.asp'). 22 | 23 | %% EXAMPLE 24 | % leafWeightCardinality(leaf1, 4, 5). 25 | % leafWeightCardinality(leaf2, 3, 7). 26 | 27 | % innerNode(1). 28 | 29 | % num(2). 30 | % max_total_weight(9). 31 | %% EXAMPLE 32 | -------------------------------------------------------------------------------- /ATTIC/test_scasp/zhou_birds.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | %OWA-open world assumption(incomplete information) 4 | %conservative about abnormal definition 5 | flies(X):- bird(X), not ab(X). 6 | 7 | bird(X):- penguin(X). 8 | bird(X):- wounded_bird(X). 9 | 10 | ab(X):- not -penguin(X). %changed 11 | ab(X):- not -wounded_bird(X). %changed 12 | 13 | -wounded_bird(X):- -bird(X). %changed 14 | -penguin(X):- -bird(X). %changed 15 | 16 | -flies(X):- penguin(X). 17 | -flies(X):- -bird(X). 18 | 19 | %facts 20 | bird(tweety). 21 | -wounded_bird(tweety). 22 | -penguin(tweety). 23 | bird(et). 24 | -wounded_bird(et). 25 | -penguin(et). 26 | -flies(et). 27 | 28 | % penguin(X):-not -penguin(X). 29 | % wounded_bird(X):- not -wounded_bird(X). 30 | % -bird(X):-not bird(X). 31 | 32 | #compute 0 {flies(X)}. 33 | 34 | %?- flies(X). 35 | -------------------------------------------------------------------------------- /ATTIC/test_tabling/edge.pl: -------------------------------------------------------------------------------- 1 | #table p/2. 2 | 3 | e(a,b). 4 | e(b,c) :- not e(b,d). 5 | e(b,d) :- not e(b,c). 6 | e(b,a). 7 | 8 | p(X,Y) :- 9 | e(X,Y). 10 | p(X,Y) :- 11 | p(X,Z), 12 | e(Z,Y). 13 | 14 | 15 | ?- p(b,X). -------------------------------------------------------------------------------- /ATTIC/test_tabling/notp.pl: -------------------------------------------------------------------------------- 1 | p(X) :- not p(3), q(X). 2 | 3 | p(1). 4 | q(2). 5 | 6 | s. 7 | 8 | ?- p(X). -------------------------------------------------------------------------------- /ATTIC/test_tabling/notpq.pl: -------------------------------------------------------------------------------- 1 | p:-q. 2 | q:-p. 3 | 4 | ?- p. -------------------------------------------------------------------------------- /ATTIC/test_tabling/p.pl: -------------------------------------------------------------------------------- 1 | p(X) :- p(X). 2 | 3 | q(X):- X=1, not p(X). 4 | 5 | 6 | -------------------------------------------------------------------------------- /ATTIC/test_tabling/path.pl: -------------------------------------------------------------------------------- 1 | #table p/2. 2 | 3 | p(a,b). 4 | p(b,c) :- not p(b,d). 5 | p(b,d) :- not p(b,c). 6 | 7 | p(X,Y) :- 8 | p(X,Z), 9 | p(Z,Y). 10 | 11 | 12 | ?- p(a,X). -------------------------------------------------------------------------------- /ATTIC/test_tabling/pq.pl: -------------------------------------------------------------------------------- 1 | p(X) :- not q(X). 2 | q(X) :- not p(X). 3 | 4 | p(1). 5 | 6 | ?- q(X). 7 | -------------------------------------------------------------------------------- /ATTIC/test_tabling/prop.pl: -------------------------------------------------------------------------------- 1 | s(1). 2 | s(X) :- s(X). 3 | 4 | 5 | ?- not s(X). 6 | 7 | 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distclean 2 | 3 | SWIPL?=swipl 4 | SWIPL_PREFIX?=$(shell dirname $$(dirname $$(which ${SWIPL}))) 5 | 6 | all: scasp prolog/scasp/main.qlf 7 | 8 | scasp: 9 | ${SWIPL} --no-pce --undefined=error -O -o scasp -c prolog/scasp/main.pl 10 | prolog/scasp/main.qlf: 11 | ${SWIPL} qlf compile --include prolog/scasp/main.pl 12 | 13 | TEST_SCAP=${SWIPL} test/test_scasp.pl --passed 14 | 15 | check: check_load 16 | $(TEST_SCAP) test/all_programs test/all_programs/sasp 17 | $(TEST_SCAP) --dcc test/all_programs/dcc 18 | 19 | # Verify consistency of main load points 20 | check_load: 21 | ${SWIPL} -q -l prolog/scasp.pl -g check --on-warning=status -t halt 22 | ${SWIPL} -q -l prolog/scasp/main.pl -g check --on-warning=status -t halt 23 | 24 | ifneq ($(strip $(SWIPL_PREFIX)),) 25 | install: 26 | @echo "Installing scasp in $(SWIPL_PREFIX)/bin/scasp" 27 | ln -sf "$(CURDIR)/scasp" "$(SWIPL_PREFIX)/bin/scasp" 28 | else 29 | install: 30 | @echo 'Warning: No $$SWIPL_PREFIX defined.' 31 | @echo 'Warning: Too old Prolog or no writeable candidate' 32 | @echo 'Warning: Could not install the scasp executable' 33 | endif 34 | 35 | clean: 36 | @-find . -name "*~" -type f -delete 37 | 38 | distclean: clean 39 | ${RM} scasp prolog/scasp/main.qlf 40 | -------------------------------------------------------------------------------- /Manifest/Manifest.pl: -------------------------------------------------------------------------------- 1 | :- bundle(sCASP). 2 | 3 | depends([ 4 | core 5 | ]). 6 | 7 | alias_paths([ 8 | scasp = 'src' 9 | ]). 10 | 11 | lib('src'). 12 | 13 | cmd('src/scasp'). 14 | 15 | manual('scasp', [main='doc/SETTINGS.pl']). 16 | 17 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.1.4 2 | -------------------------------------------------------------------------------- /doc/SETTINGS.pl: -------------------------------------------------------------------------------- 1 | :- module(_, [], [doccfg]). 2 | 3 | %! \title Configuration for s(CASP) manual 4 | % \author Joaquin Arias 5 | 6 | filepath := '../src'. 7 | 8 | output_name := scasp. 9 | doc_structure := 10 | 'scasp_man' -[ 11 | 'user_installation', 12 | 'user_usage' 13 | ]. 14 | 15 | doc_mainopts := no_biblio|no_bugs|no_patches. 16 | doc_compopts := no_biblio|no_bugs|no_patches. 17 | 18 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/aux-sasp/go_time_bec_light_sasp_discrete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | run_query_5() { 5 | echo -e '\n\n----------\t QUERY: ' $1 ' \t\t--------------' 6 | echo "$@" > query.pl 7 | time sasp -s1 bec_light_sasp_discrete_0.5.pl query.pl 8 | } 9 | 10 | run_query_25() { 11 | echo -e '\n\n----------\t QUERY: ' $1 ' \t\t--------------' 12 | echo "$@" > query.pl 13 | time sasp -s1 bec_light_sasp_discrete_0.25.pl query.pl 14 | } 15 | 16 | 17 | 18 | if [ "$#" == 0 ]; then 19 | 20 | echo -e '\n\t\t\t\t*** BEC_discrete (step-wise = 0.5) - BENCHMARK - using sasp' 21 | run_query_5 "?- holdsAt(light_on, 2.0). % success " 22 | run_query_5 "?- -holdsAt(light_on, 5.0). % success " 23 | run_query_5 "?- holdsAt(light_red, 2.0). % success " 24 | run_query_5 "?- holdsAt(light_green, 3.0). % success " 25 | echo -e '\n\t\t\t\t*** BEC_discrete (step-wise = 0.25) - BENCHMARK - using sasp' 26 | run_query_25 "?- holdsAt(light_red, 2.25). % success " 27 | 28 | else 29 | run_query $@ 30 | 31 | fi 32 | 33 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/event-calculus/example-light/bec_light_02.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %% Include the BASIC EVENT CALCULUS THEORY 5 | #include '../bec_theory'. 6 | 7 | %% Inspired by example 4 from Mueller 8 | 9 | % If a light is turned on, it will be on: 10 | initiates(turn_on, light_on, T). 11 | 12 | % If a light is turned on, whether it is red or green will be released 13 | % from the commonsense law of inertia: 14 | releases(turn_on, light_red, T). 15 | releases(turn_on, light_green, T). 16 | 17 | % If a light is turned off, it will not be on, red, or green: 18 | terminates(turn_off, light_on, T). 19 | 20 | % After a light is turned on, it will emit red for two seconds and 21 | % green after the first two seconds: 22 | trajectory(light_on, T1, light_red, T2) :- T2 .>=. T1, T2.<.T1 + 2. 23 | trajectory(light_on, T1, light_green, T2) :- T2 .>=. T1 + 2. 24 | 25 | :- holdsAt(light_red,T), holdsAt(light_green,T). 26 | 27 | initiallyN(light_on). 28 | 29 | %% Actions 30 | happens(turn_on, 2). 31 | 32 | 33 | 34 | 35 | %% Queries (with the expected result) 36 | %% Uncomment the querie you want to check... 37 | 38 | ?- holdsAt(light_green,5). 39 | % ?- holdsAt(light_on,3). 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/event-calculus/example-light/bec_light_03_inconsistent.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %% Include the BASIC EVENT CALCULUS THEORY 5 | #include '../bec_theory'. 6 | 7 | %% Inspired by example 4 from Mueller 8 | 9 | % If a light is turned on, it will be on: 10 | initiates(turn_on, light_on, T). 11 | 12 | % If a light is turned on, whether it is red or green will be released 13 | % from the commonsense law of inertia: 14 | releases(turn_on, light_red, T). 15 | releases(turn_on, light_green, T). 16 | 17 | % If a light is turned off, it will not be on. 18 | terminates(turn_off, light_on, T). 19 | 20 | % After a light is turned on, it will emit red for six seconds and 21 | % green after the first four seconds: 22 | trajectory(light_on, T1, light_red, T2) :- T2 .>=. T1, T2.<.T1 + 6. 23 | trajectory(light_on, T1, light_green, T2) :- T2 .>=. T1 + 4. 24 | 25 | %% NOTE That this rule make the example inconsistent because the 26 | %% trajectory for light_red overlap the trajectory for light_green... 27 | 28 | :- holdsAt(light_red,T), holdsAt(light_green,T). 29 | 30 | %% Actions 31 | happens(turn_on, 2). 32 | 33 | 34 | 35 | 36 | %% Queries (with the expected result) 37 | %% Uncomment the querie you want to check... 38 | 39 | ?- holdsAt(light_green,5). 40 | % ?- holdsAt(light_on,3). 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/event-calculus/example-light/bec_light_04_theinconsistencedonothappens.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %% Include the BASIC EVENT CALCULUS THEORY 5 | #include '../bec_theory'. 6 | 7 | %% Inspired by example 4 from Mueller 8 | 9 | % If a light is turned on, it will be on: 10 | initiates(turn_on, light_on, T). 11 | 12 | % If a light is turned on, whether it is red or green will be released 13 | % from the commonsense law of inertia: 14 | releases(turn_on, light_red, T). 15 | releases(turn_on, light_green, T). 16 | 17 | % If a light is turned off, it will not be on. 18 | terminates(turn_off, light_on, T). 19 | 20 | % After a light is turned on, it will emit red for six seconds and 21 | % green after the first four seconds: 22 | trajectory(light_on, T1, light_red, T2) :- T2 .>=. T1, T2.<.T1 + 6. 23 | trajectory(light_on, T1, light_green, T2) :- T2 .>=. T1 + 4. 24 | 25 | 26 | %% In this example we obtain answer becuase the overlap do not occurs 27 | %% (the light is turned off after 3 seconds). 28 | :- holdsAt(light_red,T), holdsAt(light_green,T). 29 | 30 | 31 | %% Actions 32 | happens(turn_on, 2). 33 | happens(turn_off,5). 34 | 35 | 36 | 37 | %% Queries (with the expected result) 38 | %% Uncomment the querie you want to check... 39 | 40 | ?- holdsAt(light_red, 3). 41 | % ?- holdsAt(light_on,3). 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/event-calculus/scripts/go_bec_light_02_03_04: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | run_query_a() { 5 | echo -e '\n\n----------\t QUERY: ' $1 ' \t\t--------------' 6 | echo "$@" > query.pl 7 | scasp -n0 ../example-light/bec_light_02.pl query.pl 8 | } 9 | run_query_b() { 10 | echo -e '\n\n----------\t QUERY: ' $1 ' \t\t--------------' 11 | echo "$@" > query.pl 12 | scasp -n0 ../example-light/bec_light_03_inconsistent.pl query.pl 13 | } 14 | run_query_c() { 15 | echo -e '\n\n----------\t QUERY: ' $1 ' \t\t--------------' 16 | echo "$@" > query.pl 17 | scasp -n0 ../example-light/bec_light_04_theinconsistencedonothappens.pl query.pl 18 | } 19 | 20 | 21 | 22 | if [ "$#" == 0 ]; then 23 | 24 | echo -e '\t\t\t\t*** BEC - BENCHMARK - bec_light_02.pl' 25 | run_query_a "?- holdsAt(light_green,5). % success " 26 | run_query_a "?- holdsAt(light_on,3). % success " 27 | 28 | echo -e '\t\t\t\t*** BEC - BENCHMARK - bec_light_03_inconsistent.pl' 29 | run_query_b "?- holdsAt(light_green,5). % no " 30 | run_query_b "?- holdsAt(light_on,3). % no " 31 | 32 | echo -e '\t\t\t\t*** BEC - BENCHMARK - bec_light_04_theinconsistencedonothappens.pl' 33 | run_query_c "?- holdsAt(light_red,3). % success " 34 | run_query_c "?- holdsAt(light_on,3). % success " 35 | 36 | 37 | 38 | else 39 | run_query $@ 40 | 41 | fi 42 | 43 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/event-calculus/scripts/go_bec_tap_01_overflow: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | run_query() { 5 | echo -e '\n\n----------\t QUERY: ' $1 ' \t\t--------------' 6 | echo "$@" > query.pl 7 | scasp -n0 ../example-tap/bec_tap_01_overflow.pl query.pl 8 | } 9 | 10 | 11 | 12 | if [ "$#" == 0 ]; then 13 | 14 | echo -e '\t\t\t\t*** BEC - BENCHMARK - bec_tap_01_overflow' 15 | run_query "?- holdsAt(level(H),-1). % -> no " 16 | run_query "?- holdsAt(level(H),4). % -> H = 0 " 17 | run_query "?- holdsAt(level(H),8). % -> H = 3 " 18 | run_query "?- holdsAt(level(H),14). % -> H = 9 " 19 | run_query "?- holdsAt(level(H),19). % -> H = overlimit" 20 | run_query "?- holdsAt(level(7),T). % -> T = 12s " 21 | run_query "?- holdsAt(level(12),T). % -> no " 22 | run_query "?- holdsAt(spilling,T). % -> T > 15s " 23 | run_query "?- holdsAt(leak(L),14). % -> no " 24 | run_query "?- holdsAt(leak(L),19). % -> L = 4 " 25 | run_query "?- holdsAt(leak(L),22). % -> no " 26 | 27 | 28 | 29 | else 30 | run_query $@ 31 | 32 | fi 33 | 34 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/event-calculus/scripts/go_bec_tap_02_no_overflow: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | run_query() { 5 | echo -e '\n\n----------\t QUERY: ' $1 ' \t\t--------------' 6 | echo "$@" > query.pl 7 | scasp -n1 ../example-tap/bec_tap_02_no_overflow.pl query.pl 8 | } 9 | 10 | 11 | 12 | if [ "$#" == 0 ]; then 13 | 14 | echo -e '\t\t\t\t*** BEC - BENCHMARK - bec_tap_02_no_overflow' 15 | run_query "?- holdsAt(level(7),T). % -> T = 12s " 16 | run_query "?- holdsAt(level(12),T). % -> no " 17 | run_query "?- holdsAt(spilling,T). % -> no " 18 | run_query "?- holdsAt(leak(L),13). % -> no " 19 | run_query "?- holdsAt(leak(L),16). % -> no " 20 | 21 | 22 | 23 | else 24 | run_query $@ 25 | 26 | fi 27 | 28 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/event-calculus/scripts/go_bec_tap_03_two_models: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | run_query() { 5 | echo -e '\n\n----------\t QUERY: ' $1 ' \t\t--------------' 6 | echo "$@" > query.pl 7 | scasp -n0 ../example-tap/bec_tap_03_two_models.pl query.pl 8 | } 9 | 10 | 11 | 12 | if [ "$#" == 0 ]; then 13 | 14 | echo -e '\t\t\t\t*** BEC - BENCHMARK - bec_tap_03_two_models' 15 | run_query "?- holdsAt(level(7),T). % -> T = 12s / 12s " 16 | run_query "?- holdsAt(level(12),T). % -> no / 17s " 17 | run_query "?- holdsAt(spilling,T). % -> T > 15s / no " 18 | run_query "?- holdsAt(leak(L),13). % -> no / no " 19 | run_query "?- holdsAt(leak(L),16). % -> L = 1 / no " 20 | run_query "?- holdsAt(level(H),19), max_level(Max). % -> H = overlimit, Max = 10 / H = 14, Max = 16 " 21 | 22 | 23 | 24 | 25 | else 26 | run_query $@ 27 | 28 | fi 29 | 30 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/event-calculus/scripts/go_bec_tap_04_abducible_infer_event_time: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | run_query() { 5 | echo -e '\n\n----------\t QUERY: ' $1 ' \t\t--------------' 6 | echo "$@" > query.pl 7 | scasp -n0 ../example-tap/bec_tap_04_abducible_infer_event_time.pl query.pl 8 | } 9 | 10 | 11 | 12 | if [ "$#" == 0 ]; then 13 | 14 | echo -e '\t\t\t\t*** BEC - BENCHMARK - bec_tap_04_abducible_infer_event_time' 15 | run_query "?- holdsAt(level(7),T). % -> T = 12s / 12s " 16 | run_query "?- holdsAt(level(12),T). % -> no / 17s " 17 | run_query "?- holdsAt(spilling,T). % -> T > 15s (not happens(tapOff,5 21s (not happens(tapOff,5 no / no " 19 | run_query "?- holdsAt(leak(L),16). % -> L = 1 (not happens(tapOff,5 yes (not happens(tapOff,5 \t H=14 Max=16 (not happens(tapOff,5 query.pl 7 | time scasp -n1 ../example-light/bec_light_01.pl query.pl 8 | } 9 | 10 | 11 | 12 | if [ "$#" == 0 ]; then 13 | 14 | echo -e '\t\t\t\t*** BEC_clp - BENCHMARK - using scasp' 15 | run_query "?- holdsAt(light_on, 2). % success " 16 | run_query "?- -holdsAt(light_on, 5). % success " 17 | run_query "?- holdsAt(light_red, 2). % success " 18 | run_query "?- holdsAt(light_green, 3). % success " 19 | run_query "?- holdsAt(light_red, 9/4). % success " 20 | 21 | 22 | else 23 | run_query $@ 24 | 25 | fi 26 | 27 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/light/bec_light_01.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | %% Include the BASIC EVENT CALCULUS THEORY 4 | #include '../bec_theory'. 5 | 6 | %% Inspired by example 14 from Mueller (2014) 7 | 8 | % If a light is turned on, it will be on: 9 | initiates(turn_on, light_on, T). 10 | 11 | % If a light is turned on, whether it is red or green will be released 12 | % from the commonsense law of inertia: 13 | releases(turn_on, light_red, T). 14 | releases(turn_on, light_green, T). 15 | 16 | % If a light is turned off, it will not be on. 17 | terminates(turn_off, light_on, T). 18 | 19 | % After a light is turned on, it will emit red for up to two seconds 20 | % and green after at least two seconds: 21 | trajectory(light_on, T1, light_red, T2) :- T1 #< T2, T2 #< T1 + 1. 22 | trajectory(light_on, T1, light_green, T2) :- T2 #>= T1 + 1. 23 | 24 | initiallyN(light_on). 25 | 26 | %% Actions 27 | happens(turn_on, 2). 28 | happens(turn_off, 4). 29 | happens(turn_on, 6). 30 | 31 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/light/bec_query01.pl: -------------------------------------------------------------------------------- 1 | ?- holdsAt(light_red, 6.9). % success 2 | 3 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/light/bec_query02.pl: -------------------------------------------------------------------------------- 1 | ?- holdsAt(light_red, 6.99). % success 2 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/light/bec_query03.pl: -------------------------------------------------------------------------------- 1 | ?- holdsAt(light_red, 6.999). % success 2 | 3 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/light/bec_query0x.pl: -------------------------------------------------------------------------------- 1 | ?- holdsAt(light_red, T). % success 2 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/light/light_01.clingo: -------------------------------------------------------------------------------- 1 | %% Inspired by example 14 from Mueller (2014) 2 | 3 | timestep(0..10*P) :- precision(P). 4 | 5 | % If a light is turned on, it will be on: 6 | initiates(turn_on,light_on,T) :- timestep(T). 7 | 8 | % If a light is turned on, whether it is red or green will be released 9 | % from the commonsense law of inertia: 10 | releases(turn_on,light_red,T) :- timestep(T). 11 | releases(turn_on,light_green,T) :- timestep(T). 12 | 13 | % If a light is turned off, it will not be on 14 | terminates(turn_off,light_on,T) :- timestep(T). 15 | 16 | % After a light is turned on, it will emit red for up to D seconds 17 | % and green after at least D seconds where D is determine by delay(D): 18 | trajectory(light_on, T1, light_red, T2) :- 19 | timestep(T1), timestep(T2), precision(P), 20 | T1 < T2, T2 < T1 + (1*P). 21 | trajectory(light_on, T1, light_green, T2) :- 22 | timestep(T1), timestep(T2), precision(P), 23 | T2 >= T1 + (1*P). 24 | 25 | initiallyN(light_on). 26 | 27 | %% Actions 28 | happens(turn_on,2*P) :- precision(P). 29 | happens(turn_off,4*P) :- precision(P). 30 | happens(turn_on,6*P) :- precision(P). 31 | 32 | 33 | %% Queries (with the expected result) 34 | %% false :- not holdsAt(light_on,2*P), precision(P). 35 | :- not query. 36 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/light/query00.clingo: -------------------------------------------------------------------------------- 1 | precision(1). 2 | query :- holdsAt(light_red,T). 3 | 4 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/light/query01.clingo: -------------------------------------------------------------------------------- 1 | precision(10). 2 | query :- holdsAt(light_red,69). 3 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/light/query02.clingo: -------------------------------------------------------------------------------- 1 | precision(100). 2 | query :- holdsAt(light_red,699). 3 | 4 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/light/query03.clingo: -------------------------------------------------------------------------------- 1 | precision(1000). 2 | query :- holdsAt(light_red,6999). 3 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/scripts/go_vessel: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | echo -e '\n\n*************\t Clingo: ?- holdsAt(level(11),T) \t precision(1) \n' 5 | time clingo -n0 ../theory.clingo ../vessel/vessel_01.clingo ../vessel/query00.clingo 6 | echo -e '\n\t This result is incorrect due to the tiny precision\n' 7 | 8 | echo -e '\n\n*************\t Clingo: ?- holdsAt(level(110),T) \t precision(10) \n' 9 | time clingo -n0 ../theory.clingo ../vessel/vessel_01.clingo ../vessel/query01.clingo 10 | 11 | echo -e '\n\n*************\t Clingo: ?- holdsAt(level(1100),T) \t precision(100) \n' 12 | time clingo -n0 ../theory.clingo ../vessel/vessel_01.clingo ../vessel/query02.clingo 13 | 14 | 15 | 16 | 17 | echo -e '\n\n*************\t s(CASP): ?- holdsAt(level(11),T) \n' 18 | time scasp -n0 ../vessel/bec_vessel_01.pl ../vessel/bec_query01.pl 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/theory.e: -------------------------------------------------------------------------------- 1 | 2 | %% F2LP BASIC EVENT CALCULUS (BEC) THEORY 3 | 4 | 5 | %% BEC1 - StoppedIn(t1,f,t2) 6 | stoppedIn(T1, Fluent, T2) <- 7 | happens(Event, T) & T1 < T & T < T2 & (terminates(Event, Fluent, T) | releases(Event, Fluent, T)). 8 | 9 | %% BEC2 - StartedIn(t1,f,t2) 10 | startedIn(T1, Fluent, T2) <- 11 | happens(Event, T) & T1 < T & T < T2 & (initiates(Event, Fluent, T) | releases(Event, Fluent, T)). 12 | 13 | %% BEC3 - HoldsAt(f,t) 14 | holdsAt(Fluent2, T2) <- 15 | happens(Event, T1) & initiates(Event, Fluent1, T1) & trajectory(Fluent1, T1, Fluent2, T2) & not stoppedIn(T1, Fluent1, T2). 16 | 17 | %% BEC4 - HoldsAt(f,t) 18 | holdsAt(Fluent, T) <- 19 | initiallyP(Fluent) & not stoppedIn(0, Fluent, T). 20 | 21 | %% BEC5 - not HoldsAt(f,t) 22 | not holdsAt(Fluent, T) <- 23 | initiallyN(Fluent) & not startedIn(0, Fluent, T). 24 | 25 | %% BEC6 - HoldsAt(f,t) 26 | holdsAt(Fluent, T) <- 27 | happens(Event, T1) & initiates(Event, Fluent, T1) & T1 < T & not stoppedIn(T1, Fluent, T). 28 | 29 | %% BEC7 - not HoldsAt(f,t) 30 | not holdsAt(Fluent, T) <- 31 | happens(Event, T1) & terminates(Event, Fluent, T1) & T1 < T & not startedIn(T1, Fluent, T). 32 | 33 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/vessel/bec_queries.pl: -------------------------------------------------------------------------------- 1 | ?- holdsAt(level(L),15/2). 2 | ?- holdsAt(level(14),T). 3 | ?- holdsAt(level(L),15/2). 4 | ?- holdsAt(level(10/3),T). 5 | ?- holdsAt(level(12),14). 6 | ?- holdsAt(spilling,T). 7 | ?- holdsAt(level(11),T). -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/vessel/bec_query01.pl: -------------------------------------------------------------------------------- 1 | ?- holdsAt(level(11),T). 2 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/vessel/query00.clingo: -------------------------------------------------------------------------------- 1 | precision(1). 2 | query :- level(11,T). 3 | 4 | level(11,T) :- holdsAt(level(11),T). 5 | 6 | 7 | #show level/2. 8 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/vessel/query01.clingo: -------------------------------------------------------------------------------- 1 | precision(10). 2 | query :- level(110,T). 3 | 4 | level(110,T) :- holdsAt(level(110),T). 5 | 6 | 7 | #show level/2. 8 | -------------------------------------------------------------------------------- /examples/benchmark_EventCalculus/lopstr19/sCASP-clingo/vessel/query02.clingo: -------------------------------------------------------------------------------- 1 | precision(100). 2 | query :- level(1100,T). 3 | 4 | level(1100,T) :- holdsAt(level(1100),T). 5 | 6 | 7 | #show level/2. 8 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/sasp_vs_scasp/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | scasp: 5 | time scasp -s0 queens_4.pl || true 6 | time scasp -s0 hanoi_8.pl || true 7 | time scasp -s0 hamcycle_one.pl || true 8 | time scasp -s0 hamcycle_two.pl || true 9 | 10 | 11 | ## sasp implemented in CIAO 12 | sasp: 13 | time sasp -s0 queens_4.pl || true 14 | time sasp -s0 hanoi_8.pl || true 15 | time sasp -s0 hamcycle_one.pl || true 16 | time sasp -s0 hamcycle_two.pl || true 17 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/sasp_vs_scasp/hamcycle_one.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | 6 | % fact for each edge edge(U, V). 7 | edge(0, 1). 8 | edge(1, 2). 9 | edge(2, 0). 10 | 11 | reachable(V) :- chosen(U, V), reachable(U). 12 | reachable(0) :- chosen(V, 0). 13 | 14 | % Every vertex must be reachable. 15 | :- vertex(U), not reachable(U). 16 | 17 | % Choose exactly one edge from each vertex. 18 | other(U, V) :- 19 | vertex(U), vertex(V), vertex(W), 20 | edge(U, W), V \= W, chosen(U, W). 21 | chosen(U, V) :- 22 | edge(U, V), not other(U, V). 23 | 24 | % You cannot choose two edges to the same vertex 25 | :- chosen(U, W), chosen(V, W), U \= V. 26 | 27 | ?- chosen(1,2). 28 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/sasp_vs_scasp/hamcycle_two.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | vertex(3). 6 | 7 | % fact for each edge edge(U, V). 8 | edge(0, 1). 9 | edge(1, 2). 10 | edge(2, 3). 11 | edge(3, 0). 12 | 13 | edge(2, 0). 14 | edge(0, 3). 15 | edge(3, 1). 16 | 17 | reachable(V) :- chosen(U, V), reachable(U). 18 | reachable(0) :- chosen(V, 0). 19 | 20 | % Every vertex must be reachable. 21 | :- vertex(U), not reachable(U). 22 | 23 | % Choose exactly one edge from each vertex. 24 | other(U, V) :- 25 | vertex(U), vertex(V), vertex(W), 26 | edge(U, W), V \= W, chosen(U, W). 27 | chosen(U, V) :- 28 | edge(U, V), not other(U, V). 29 | 30 | % You cannot choose two edges to the same vertex 31 | :- chosen(U, W), chosen(V, W), U \= V. 32 | 33 | ?- chosen(1,2). 34 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/sasp_vs_scasp/hanoi_8.pl: -------------------------------------------------------------------------------- 1 | % Move N disks in T moves. 2 | hanoi(N, T) :- 3 | moven(N, 0, T, 1, 2, 3). 4 | 5 | % Move N disks from peg A to peg B using peg C. Assign move numbers. 6 | moven(N, Ti, To, A, B, C) :- 7 | N > 1, 8 | N1 is N - 1, 9 | moven(N1, Ti, T2, A, C, B), 10 | T3 is T2 + 1, 11 | move(T3, A, B), 12 | moven(N1, T3, To, C, B, A). 13 | moven(1, Ti, To, A, B, _) :- 14 | To is Ti + 1, 15 | move(To, A, B). 16 | 17 | % move T: move disk from P1 to P2. 18 | % any move may or may not be selected. 19 | move(T, P1, P2) :- 20 | not negmove(T, P1, P2). 21 | 22 | negmove(T, P1, P2) :- 23 | not move(T, P1, P2). 24 | 25 | ?- hanoi(8, T). 26 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/sasp_vs_scasp/queens_4.pl: -------------------------------------------------------------------------------- 1 | % 4-queens: ((1,2),(2,4),(3,1),(4,3)) and ((1,3),(2,1),(3,4),(4,2)) 2 | % Retargetable N-queens program. 3 | 4 | nqueens(N, Q) :- 5 | _nqueens(N, N, [], Q). 6 | 7 | % Pick queens one at a time and test against all previous queens. 8 | _nqueens(X, N, Qi, Qo) :- 9 | X > 0, 10 | _pickqueen(X, Y, N), 11 | not _attack(X, Y, Qi), 12 | X1 is X - 1, 13 | _nqueens(X1, N, [q(X, Y) | Qi], Qo). 14 | _nqueens(0, _, Q, Q). 15 | 16 | 17 | % pick a queen for row X. 18 | _pickqueen(X, Y, Y) :- 19 | Y > 0, 20 | q(X, Y). 21 | _pickqueen(X, Y, N) :- 22 | N > 1, 23 | N1 is N - 1, 24 | _pickqueen(X, Y, N1). 25 | 26 | % check if a queen can attack any previously selected queen. 27 | _attack(X, _, [q(X, _) | _]). % same row 28 | _attack(_, Y, [q(_, Y) | _]). % same col 29 | _attack(X, Y, [q(X2, Y2) | _]) :- % same diagonal 30 | Xd is X2 - X, 31 | _abs(Xd, Xd2), 32 | Yd is Y2 - Y, 33 | _abs(Yd, Yd2), 34 | Xd2 = Yd2. 35 | _attack(X, Y, [_ | T]) :- 36 | _attack(X, Y, T). 37 | 38 | q(X, Y) :- not _negq(X, Y). 39 | _negq(X, Y) :- not q(X, Y). 40 | 41 | _abs(X, X) :- X >= 0. 42 | _abs(X, Y) :- X < 0, Y is X * -1. 43 | 44 | ?- nqueens(4, Q). 45 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/stream_data_reasoning/README.md: -------------------------------------------------------------------------------- 1 | # Stream data reasoning 2 | 3 | Let us assume that we deal with series of data items, some of which 4 | may be contradictory. Moreover, different sources may give data a 5 | different degree of trustworthiness which can make some pieces of 6 | inconsistent data to be preferred. Lets us assume that `p(A)` and `q(A)` 7 | are contradictory and we receive, from source _S1_, `p(A)` and, from 8 | source _S2_, `q(a)`. We may decide that: (i) `p(A)` is __true__ because _S1_ is 9 | more realiable; (ii) or if _S2_ is more realiable, `q(a)` is __true__, and any 10 | value `not a` (i.e., _X \= a_) `p(A)` is also __true__; (iii) or, if both 11 | sources are equally reliable, them we have (at least) two different 12 | models: one where `q(a)` is __true__ and another where `p(A)` is __true__ (also 13 | for _X=a_). 14 | 15 | 16 | ## s(CASP) implementation 17 | 18 | ``` 19 | scasp stream_data_reasoning.pl 20 | ``` 21 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/stream_data_reasoning/new_stream.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | valid_stream(P,Data) :- 6 | stream(P,Data), 7 | not cancelled(P, Data). 8 | cancelled(P, Data) :- 9 | stream(P,Data), 10 | stream(P1, Data1), 11 | P1 > P, 12 | incompt(Data, Data1). 13 | 14 | incompt(p(X), q(X)) :- stream(_,p(X)). 15 | incompt(q(X), p(X)) :- stream(_,q(X)). 16 | incompt(a(X), b(Y)) :- stream(_,a(X)), stream(_,b(Y)), X > Y. 17 | incompt(b(X), a(X)) :- stream(_,b(X)), stream(_,b(Y)), X > Y. 18 | incompt(c(X), d(X)) :- stream(_,c(X)). 19 | incompt(d(X), c(X)) :- stream(_,d(X)). 20 | incompt(e(X), f(X)) :- stream(_,e(X)). 21 | incompt(f(X), e(X)) :- stream(_,f(X)). 22 | incompt(g(X), h(X)) :- stream(_,g(X)). 23 | incompt(h(X), g(X)) :- stream(_,h(X)). 24 | 25 | stream(1,p(c)). 26 | stream(2,q(b)). 27 | stream(2,q(a)). 28 | stream(3,p(a)). 29 | stream(1,a(1..100)). 30 | stream(2,b(50..100)). 31 | stream(3,c(1..10)). 32 | stream(4,d(1..10)). 33 | stream(5,e(1..10)). 34 | stream(6,f(1..10)). 35 | stream(7,g(1..10)). 36 | stream(8,h(1..10)). 37 | 38 | 39 | #show valid_stream/2. 40 | 41 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/stream_data_reasoning/stream_reasoning.pl: -------------------------------------------------------------------------------- 1 | valid_stream(P,Data) :- 2 | stream(P,Data), 3 | not cancelled(P, Data). 4 | cancelled(P, Data) :- 5 | higher_prio(P1, P), 6 | stream(P1, Data1), 7 | incompt(Data, Data1). 8 | higher_prio(PHi, PLo) :- 9 | PHi .>. PLo. 10 | incompt(p(X), q(X)). 11 | incompt(q(X), p(X)). 12 | 13 | stream(1,p(X)). 14 | stream(2,q(a)). 15 | stream(2,q(b)). 16 | stream(3,p(a)). 17 | 18 | ?- valid_stream(P,Data). 19 | 20 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | scasp: 6 | time scasp -s1 hanoi_scasp_7.pl || true 7 | time scasp -s1 hanoi_scasp_8.pl || true 8 | time scasp -s1 hanoi_scasp_9.pl || true 9 | 10 | asp: 11 | time clingo -n1 toh_standard_7.pl || true 12 | 13 | asp_inc: 14 | time clingo -n1 toh_incremental_7.pl || true 15 | 16 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/README.md: -------------------------------------------------------------------------------- 1 | # Towers of Hanoi 2 | 3 | ## Clingo standard implementation 4 | 5 | Known ASP encodings set a bound to the number of moves that can be 6 | done, proposed in 7 | ([Gebser et al. 2008](https://www.cs.utexas.edu/users/vl/teaching/lbai/clingo_guide.pdf)) 8 | for 7 disks and up to 126 movements. 9 | 10 | ``` 11 | clingo toh_standard_7.pl 12 | clingo toh_standard_8.pl 13 | clingo toh_standard_9.pl 14 | ``` 15 | 16 | ## Clingo incremental implementation 17 | 18 | ASP encoding by incrementing the number n of allowed movements (from 19 | the [clingo 5.2.0](https://github.com/potassco/clingo) distribution) and proposerd in ([Gebser et al. 2014](https://arxiv.org/pdf/1405.3694.pdf)) 20 | 21 | ``` 22 | clingo toh_incremental_7.pl 23 | clingo toh_incremental_8.pl 24 | clingo toh_incremental_9.pl 25 | ``` 26 | 27 | ## s(CASP) implementation 28 | 29 | s(CASP)’s top down approach can use a CLP-like control strategy to 30 | implement the wellknown Towers of Hanoi algorithm. Predicate 31 | hanoi(N,T) receives in N the number of disks and returns in T the 32 | number of movements and a partial stable model which contains all the 33 | movements and the time in which they have to be performed. 34 | ``` 35 | scasp hanoi_scasp_7.pl 36 | scasp hanoi_scasp_8.pl 37 | scasp hanoi_scasp_9.pl 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/hanoi_min.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | path(A,A,0). % :- 8 | % edge(A,B,D). 9 | 10 | path(A,B,D) :- 11 | D .=. D1 + D2, 12 | edge(A,Z,D1), 13 | path(Z,B,D2). 14 | 15 | edge(a,b,1). 16 | edge(a,b,2). 17 | edge(a,c,2). 18 | edge(a,b,0). 19 | edge(c,d,3). 20 | edge(d,g,1). 21 | edge(a,g,2). 22 | 23 | min_edge(A,B,D) :- 24 | edge(A,B,D), 25 | not neg_min_edge(A,B,D). 26 | 27 | neg_min_edge(A,B,D) :- 28 | D1 .<. D, 29 | edge(A,B,D1). 30 | 31 | 32 | min_path(A,B,D) :- 33 | edge(A,B,D), 34 | not neg_min_path(A,B,D). 35 | min_path(A,B,D) :- 36 | edge(A,Z,D1), 37 | D .=. D1 + D2, 38 | min_path(Z,B,D2), 39 | not neg_min_path(A,B,D). 40 | 41 | neg_min_path(A,B,D) :- 42 | D1 .<. D, 43 | min_path(A,B,D1). 44 | 45 | 46 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/hanoi_scasp_7.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | % Move N disks in T moves. 4 | hanoi(N, T) :- 5 | move_(N, 0, T, a, b, c). 6 | 7 | % Move N disks from peg Pi to peg Pf using peg Paux. 8 | move_(N,Ti,Tf,Pi,Pf,Paux) :- 9 | N.>.1, 10 | N1.=.N - 1, 11 | move_(N1,Ti,T1,Pi,Paux,Pf), 12 | move_(1,T1,T2,Pi,Pf,Paux), 13 | move_(N1,T2,Tf,Paux,Pf,Pi). 14 | move_(1,Ti,Tf,Pi,Pf,_) :- 15 | Tf.=.Ti + 1, 16 | move(Pi,Pf,Tf). 17 | 18 | % move T: move disk from Pi to Pf. 19 | % any move may or may not be selected. 20 | move(Pi,Pf,T):- not negmove(Pi,Pf,T). 21 | negmove(Pi,Pf,T):- not move(Pi,Pf,T). 22 | 23 | ?- hanoi(7, T). 24 | 25 | #show move/3. 26 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/hanoi_scasp_8.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | % Move N disks in T moves. 4 | hanoi(N, T) :- 5 | move_(N, 0, T, a, b, c). 6 | 7 | % Move N disks from peg Pi to peg Pf using peg Paux. 8 | move_(N,Ti,Tf,Pi,Pf,Paux) :- 9 | N.>.1, 10 | N1.=.N - 1, 11 | move_(N1,Ti,T1,Pi,Paux,Pf), 12 | move_(1,T1,T2,Pi,Pf,Paux), 13 | move_(N1,T2,Tf,Paux,Pf,Pi). 14 | move_(1,Ti,Tf,Pi,Pf,_) :- 15 | Tf.=.Ti + 1, 16 | move(Pi,Pf,Tf). 17 | 18 | % move T: move disk from Pi to Pf. 19 | % any move may or may not be selected. 20 | move(Pi,Pf,T):- not negmove(Pi,Pf,T). 21 | negmove(Pi,Pf,T):- not move(Pi,Pf,T). 22 | 23 | ?- hanoi(8, T). 24 | 25 | #show move/3. 26 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/hanoi_scasp_9.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | % Move N disks in T moves. 4 | hanoi(N, T) :- 5 | move_(N, 0, T, a, b, c). 6 | 7 | % Move N disks from peg Pi to peg Pf using peg Paux. 8 | move_(N,Ti,Tf,Pi,Pf,Paux) :- 9 | N.>.1, 10 | N1.=.N - 1, 11 | move_(N1,Ti,T1,Pi,Paux,Pf), 12 | move_(1,T1,T2,Pi,Pf,Paux), 13 | move_(N1,T2,Tf,Paux,Pf,Pi). 14 | move_(1,Ti,Tf,Pi,Pf,_) :- 15 | Tf.=.Ti + 1, 16 | move(Pi,Pf,Tf). 17 | 18 | % move T: move disk from Pi to Pf. 19 | % any move may or may not be selected. 20 | move(Pi,Pf,T):- not negmove(Pi,Pf,T). 21 | negmove(Pi,Pf,T):- not move(Pi,Pf,T). 22 | 23 | ?- hanoi(9, T). 24 | 25 | #show move/3. 26 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/new_hanoi.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | query(T,L) :- 6 | T .<. 50, hanoi(T,L). 7 | 8 | size(5). 9 | stack(Stack) :- size(N), gen_list(1,N,Stack). 10 | 11 | :- use_package(clpq). 12 | 13 | hanoi(T,List) :- 14 | stack(Stack), 15 | holds(T,st([],[],Stack),List). 16 | 17 | init(st(Stack,[],[])) :- 18 | stack(Stack). 19 | 20 | holds(0,St,[St-0]) :- 21 | init(St). 22 | holds(T1, St1,[St1-T1|Prev]) :- 23 | T1 .>. 0, 24 | T1 .=. T0 + 1, 25 | holds(T0, St0, Prev), 26 | trans(St0, St1), 27 | \+ member(St1-T,Prev). 28 | 29 | trans(st(A0,B0,C0), st(A1,B1,C1)) :- 30 | trans_(A0,A1,B0,B1,C0,C1). 31 | trans(st(A0,B0,C0), st(A1,B1,C1)) :- 32 | trans_(B0,B1,C0,C1,A0,A1). 33 | trans(st(A0,B0,C0), st(A1,B1,C1)) :- 34 | trans_(C0,C1,A0,A1,B0,B1). 35 | 36 | trans_([A|As],As,B,[A|B],C,C) :- 37 | not_invalid(A,B). 38 | trans_([A|As],As,B,B,C,[A|C]) :- 39 | not_invalid(A,C). 40 | 41 | % invalid(E,[O|_]) :- 42 | % E .>. O. 43 | 44 | not_invalid(_,[]). 45 | not_invalid(E,[O|_]) :- 46 | E .<. O. 47 | 48 | gen_list(N,N,[N]). 49 | gen_list(I,N,[I|L]) :- 50 | I < N, 51 | I1 is I + 1, 52 | gen_list(I1,N,L). 53 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/toh_incremental_7.pl: -------------------------------------------------------------------------------- 1 | #include . 2 | 3 | #program base. 4 | peg(a;b;c). 5 | disk(1..7). 6 | init_on(1..7,a). 7 | goal_on(1..7,b). 8 | 9 | on(D,P,0) :- init_on(D,P). 10 | 11 | #program step(t). 12 | 1 { move(D,P,t) : disk(D), peg(P) } 1. 13 | 14 | move(D,t) :- move(D,P,t). 15 | on(D,P,t) :- move(D,P,t). 16 | on(D,P,t) :- on(D,P,t-1), not move(D,t). 17 | blocked(D-1,P,t) :- on(D,P,t-1). 18 | blocked(D-1,P,t) :- blocked(D,P,t), disk(D). 19 | 20 | :- move(D,P,t), blocked(D-1,P,t). 21 | :- move(D,t), on(D,P,t-1), blocked(D,P,t). 22 | :- not 1 { on(D,P,t) } 1, disk(D). 23 | 24 | #program check(t). 25 | :- query(t), goal_on(D,P), not on(D,P,t). 26 | 27 | #show move/3. 28 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/toh_incremental_8.pl: -------------------------------------------------------------------------------- 1 | #include . 2 | 3 | #program base. 4 | peg(a;b;c). 5 | disk(1..8). 6 | init_on(1..8,a). 7 | goal_on(1..8,b). 8 | 9 | on(D,P,0) :- init_on(D,P). 10 | 11 | #program step(t). 12 | 1 { move(D,P,t) : disk(D), peg(P) } 1. 13 | 14 | move(D,t) :- move(D,P,t). 15 | on(D,P,t) :- move(D,P,t). 16 | on(D,P,t) :- on(D,P,t-1), not move(D,t). 17 | blocked(D-1,P,t) :- on(D,P,t-1). 18 | blocked(D-1,P,t) :- blocked(D,P,t), disk(D). 19 | 20 | :- move(D,P,t), blocked(D-1,P,t). 21 | :- move(D,t), on(D,P,t-1), blocked(D,P,t). 22 | :- not 1 { on(D,P,t) } 1, disk(D). 23 | 24 | #program check(t). 25 | :- query(t), goal_on(D,P), not on(D,P,t). 26 | 27 | #show move/3. 28 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/toh_incremental_9.pl: -------------------------------------------------------------------------------- 1 | #include . 2 | 3 | #program base. 4 | peg(a;b;c). 5 | disk(1..9). 6 | init_on(1..9,a). 7 | goal_on(1..9,b). 8 | 9 | on(D,P,0) :- init_on(D,P). 10 | 11 | #program step(t). 12 | 1 { move(D,P,t) : disk(D), peg(P) } 1. 13 | 14 | move(D,t) :- move(D,P,t). 15 | on(D,P,t) :- move(D,P,t). 16 | on(D,P,t) :- on(D,P,t-1), not move(D,t). 17 | blocked(D-1,P,t) :- on(D,P,t-1). 18 | blocked(D-1,P,t) :- blocked(D,P,t), disk(D). 19 | 20 | :- move(D,P,t), blocked(D-1,P,t). 21 | :- move(D,t), on(D,P,t-1), blocked(D,P,t). 22 | :- not 1 { on(D,P,t) } 1, disk(D). 23 | 24 | #program check(t). 25 | :- query(t), goal_on(D,P), not on(D,P,t). 26 | 27 | #show move/3. 28 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/toh_standard_5.pl: -------------------------------------------------------------------------------- 1 | peg(a;b;c). 2 | disk(1..6). 3 | init_on(1..6,a). 4 | goal_on(1..6,c). 5 | moves(63). 6 | 7 | % Generate 8 | { move(D,P,T) : disk(D), peg(P) } = 1 :- moves(M), T = 1..M. 9 | % Define 10 | move(D,T) :- move(D,_,T). 11 | on(D,P,0) :- init_on(D,P). 12 | on(D,P,T) :- move(D,P,T). 13 | on(D,P,T+1) :- on(D,P,T), not move(D,T+1), not moves(T). 14 | blocked(D-1,P,T+1) :- on(D,P,T), not moves(T). 15 | blocked(D-1,P,T) :- blocked(D,P,T), disk(D). 16 | % Test 17 | :- move(D,P,T), blocked(D-1,P,T). 18 | :- move(D,T), on(D,P,T-1), blocked(D,P,T). 19 | :- goal_on(D,P), not on(D,P,M), moves(M). 20 | :- { on(D,P,T) } != 1, disk(D), moves(M), T = 1..M. 21 | % Display 22 | #show move/3. 23 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/toh_standard_6.pl: -------------------------------------------------------------------------------- 1 | peg(a;b;c). 2 | disk(1..6). 3 | init_on(1..6,a). 4 | goal_on(1..6,c). 5 | moves(63). 6 | 7 | % Generate 8 | { move(D,P,T) : disk(D), peg(P) } = 1 :- moves(M), T = 1..M. 9 | % Define 10 | move(D,T) :- move(D,_,T). 11 | on(D,P,0) :- init_on(D,P). 12 | on(D,P,T) :- move(D,P,T). 13 | on(D,P,T+1) :- on(D,P,T), not move(D,T+1), not moves(T). 14 | blocked(D-1,P,T+1) :- on(D,P,T), not moves(T). 15 | blocked(D-1,P,T) :- blocked(D,P,T), disk(D). 16 | % Test 17 | :- move(D,P,T), blocked(D-1,P,T). 18 | :- move(D,T), on(D,P,T-1), blocked(D,P,T). 19 | :- goal_on(D,P), not on(D,P,M), moves(M). 20 | :- { on(D,P,T) } != 1, disk(D), moves(M), T = 1..M. 21 | % Display 22 | #show move/3. 23 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/toh_standard_7.pl: -------------------------------------------------------------------------------- 1 | peg(a;b;c). 2 | disk(1..7). 3 | init_on(1..7,a). 4 | goal_on(1..7,c). 5 | moves(127). 6 | 7 | % Generate 8 | { move(D,P,T) : disk(D), peg(P) } = 1 :- moves(M), T = 1..M. 9 | % Define 10 | move(D,T) :- move(D,_,T). 11 | on(D,P,0) :- init_on(D,P). 12 | on(D,P,T) :- move(D,P,T). 13 | on(D,P,T+1) :- on(D,P,T), not move(D,T+1), not moves(T). 14 | blocked(D-1,P,T+1) :- on(D,P,T), not moves(T). 15 | blocked(D-1,P,T) :- blocked(D,P,T), disk(D). 16 | % Test 17 | :- move(D,P,T), blocked(D-1,P,T). 18 | :- move(D,T), on(D,P,T-1), blocked(D,P,T). 19 | :- goal_on(D,P), not on(D,P,M), moves(M). 20 | :- { on(D,P,T) } != 1, disk(D), moves(M), T = 1..M. 21 | % Display 22 | #show move/3. 23 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/toh_standard_8.pl: -------------------------------------------------------------------------------- 1 | peg(a;b;c). 2 | disk(1..8). 3 | init_on(1..8,a). 4 | goal_on(1..8,c). 5 | moves(255). 6 | 7 | % Generate 8 | { move(D,P,T) : disk(D), peg(P) } = 1 :- moves(M), T = 1..M. 9 | % Define 10 | move(D,T) :- move(D,_,T). 11 | on(D,P,0) :- init_on(D,P). 12 | on(D,P,T) :- move(D,P,T). 13 | on(D,P,T+1) :- on(D,P,T), not move(D,T+1), not moves(T). 14 | blocked(D-1,P,T+1) :- on(D,P,T), not moves(T). 15 | blocked(D-1,P,T) :- blocked(D,P,T), disk(D). 16 | % Test 17 | :- move(D,P,T), blocked(D-1,P,T). 18 | :- move(D,T), on(D,P,T-1), blocked(D,P,T). 19 | :- goal_on(D,P), not on(D,P,M), moves(M). 20 | :- { on(D,P,T) } != 1, disk(D), moves(M), T = 1..M. 21 | % Display 22 | #show move/3. 23 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/towers_hanoi/toh_standard_9.pl: -------------------------------------------------------------------------------- 1 | peg(a;b;c). 2 | disk(1..9). 3 | init_on(1..9,a). 4 | goal_on(1..9,c). 5 | moves(511). 6 | 7 | % Generate 8 | { move(D,P,T) : disk(D), peg(P) } = 1 :- moves(M), T = 1..M. 9 | % Define 10 | move(D,T) :- move(D,_,T). 11 | on(D,P,0) :- init_on(D,P). 12 | on(D,P,T) :- move(D,P,T). 13 | on(D,P,T+1) :- on(D,P,T), not move(D,T+1), not moves(T). 14 | blocked(D-1,P,T+1) :- on(D,P,T), not moves(T). 15 | blocked(D-1,P,T) :- blocked(D,P,T), disk(D). 16 | % Test 17 | :- move(D,P,T), blocked(D-1,P,T). 18 | :- move(D,T), on(D,P,T-1), blocked(D,P,T). 19 | :- goal_on(D,P), not on(D,P,M), moves(M). 20 | :- { on(D,P,T) } != 1, disk(D), moves(M), T = 1..M. 21 | % Display 22 | #show move/3. 23 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/traveling_salesman/README.md: -------------------------------------------------------------------------------- 1 | # Traveling salesman 2 | 3 | A variant of the traveling salesman problem (visiting every city in a 4 | country only once, starting and ending in the same city, and moving 5 | between cities using the existing connections) where, in addition, we 6 | want to find out the length of the Hamiltonian cycle. 7 | 8 | Solutions for this problem using `CLP(FD)` and `ASP` appear in 9 | ([Dovier et al. 2005](https://users.dimi.uniud.it/~agostino.dovier/PAPERS/DFP05-cilc.pdf)), 10 | with comparable performance. However, they show that the `ASP` 11 | encoding is more compact, even if the `CLP(FD)` version uses the 12 | library predicate `circuit/1`, which does the bulk of the work and 13 | whose code is non-trivial. 14 | 15 | We will show that also in this problem, where the `ASP` solution is more 16 | compact than that of `CLP(FD)`, `s(CASP) `is more expressive. 17 | 18 | ## s(CASP) implementation 19 | 20 | ``` 21 | scasp hamiltonian_scasp.pl 22 | 23 | ``` 24 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/traveling_salesman/hamiltonian_asp.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 1 { hc(X,Y) : edge(X,Y) } 1 :- node(X). 7 | 1 { hc(Z,X) : edge(Z,X) } 1 :- node(X). 8 | reachable(X) :- node(X), hc(1,X). 9 | reachable(Y) :- node(X), node(Y), reachable(X), hc(X,Y). 10 | :- not reachable(X), node(X). 11 | 12 | 13 | edge(0, 1). 14 | edge(1, 2). 15 | edge(2, 3). 16 | edge(3, 0). 17 | 18 | edge(2, 0). 19 | edge(0, 3). 20 | edge(3, 1). 21 | 22 | node(0..3). 23 | 24 | 25 | distance(X,D) :- reachable(X), hc(1,X), dist(1,X,D). 26 | distance(Y,D) :- distance(X,D1), hc(X,Y), dist(X,Y,D2), D = D1 + D2. 27 | 28 | dist(0, 1, 1). 29 | dist(1, 2, 1). 30 | dist(2, 3, 1). 31 | dist(3, 0, 1). 32 | 33 | dist(2, 0, 1). 34 | dist(0, 3, 1). 35 | dist(3, 1, 1). 36 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/traveling_salesman/hamiltonian_scasp.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | reachable(V) :- cycle(U, V), reachable(U). 4 | reachable(a) :- cycle(V, a). 5 | 6 | % Every node must be reachable. 7 | :- node(U), not reachable(U). 8 | 9 | % Choose exactly one edge from each node. 10 | other(U, V) :- 11 | node(U), node(V), node(W), 12 | edge(U, W), V \= W, cycle(U, W). 13 | cycle(U, V) :- 14 | edge(U, V), not other(U, V). 15 | 16 | % You cannot choose two edges to the same node 17 | :- cycle(U, W), cycle(V, W), U \= V. 18 | 19 | 20 | travel_path(Start, Length, Cycle) :- path(Start, Start, Start, Length, [], Cycle). 21 | 22 | path(_, X, Y, D, Prev, [X,[D],Y|Prev]) :- 23 | cycle_dist(X, Y, D). 24 | path(Start, X, Y, D, Prev, Cycle) :- 25 | D #= D1 + D2, 26 | cycle_dist(Z, Y, D1), Z \= Start, 27 | path(Start, X, Z, D2, [([D1],Y)|Prev], Cycle). 28 | 29 | edge(X,Y) :- distance(X,Y,D). 30 | cycle_dist(U,V,D) :- 31 | cycle(U,V), distance(U,V,D). 32 | 33 | node(a). 34 | node(b). 35 | node(c). 36 | node(d). 37 | 38 | distance(b, c, 31/10). 39 | distance(c, d, L) :- 40 | L #> 8, L #< 21/2. 41 | distance(d, a, 1). 42 | distance(a, b, 1). 43 | distance(c, a, 1). 44 | distance(a, d, 1). 45 | distance(d, b, 1). 46 | 47 | 48 | ?- travel_path(b, D, Cycle). 49 | 50 | #show travel_path/3, cycle_dist/3. 51 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/yale_shooting_scenario/README.md: -------------------------------------------------------------------------------- 1 | # Yale shooting scenario 2 | 3 | Lets us compare the expressiveness of `s(CASP)` vs `ASP` + constraints 4 | using the spoiling Yale shooting scenario 5 | ([Janhunen et al. 2017](https://arxiv.org/pdf/1707.04053.pdf)). 6 | 7 | In this scenario we have an unloaded gun and three possible actions 8 | load, shoot, and wait. If we load the gun, it becomes loaded. If we 9 | shoot the gun and it was loaded for no more than 35 minutes, the 10 | turkey is killed. Otherwise, the gun powder is spoiled. We are looking 11 | for an executable plan such that: 12 | * the turkey is killed within 100 minutes, 13 | * considering that we are not allowed to shoot in the first 35 14 | minutes. 15 | 16 | ## s(CASP) implementation 17 | 18 | ``` 19 | scasp yale_shooting_casp.pl 20 | ``` 21 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/yale_shooting_scenario/yale_shooting_casp.pl: -------------------------------------------------------------------------------- 1 | 2 | duration(load,25). 3 | duration(shoot,5). 4 | duration(wait,36). 5 | 6 | holds(0,State,[]) :- 7 | init(State). 8 | holds(Time1, FinalState, [Action|As]) :- 9 | Time1 .>. 0, 10 | Time1 .=. Time + Duration, 11 | duration(Action, Duration), 12 | not prohibited(Action, Time1), 13 | transition(Action, PrevState, FinalState), 14 | holds(Time, PrevState, As). 15 | 16 | init(state(alive, unloaded, 0)). 17 | 18 | transition(load, state(alive, _, _), state(alive, loaded,FinalArmed)) :- 19 | FinalArmed = 0. 20 | transition(wait, state(alive, Gun, PrevArmed), state(alive, Gun, FinalArmed)) :- 21 | duration(wait, D), FinalArmed .=. PrevArmed + D. 22 | transition(shoot, state(alive, loaded, PrevArmed), state(dead, unloaded, 0)) :- 23 | not spoiled(PrevArmed). 24 | transition(shoot, state(alive, loaded, PrevArmed), state(alive, unloaded, 0)) :- 25 | spoiled(PrevArmed). 26 | 27 | spoiled(Armed) :- Armed .>. 35. 28 | prohibited(shoot, T) :- T .<. 35. 29 | 30 | ?- T .<. 100, holds(T, state(dead,_,_), List). 31 | 32 | #show holds/3. 33 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/yale_shooting_scenario/yale_shooting_casp_v2.pl: -------------------------------------------------------------------------------- 1 | 2 | duration(load,D) :- 3 | D .<. 23/3, D .>. 10/3. 4 | duration(shoot,5). 5 | duration(wait,36). 6 | 7 | holds(0,State,[]) :- 8 | init(State). 9 | holds(Time1, FinalState, [Action|As]) :- 10 | Time1 .>. 0, 11 | Time1 .=. Time + Duration, 12 | duration(Action, Duration), 13 | not prohibited(Action, Time1), 14 | transition(Action, PrevState, FinalState), 15 | holds(Time, PrevState, As). 16 | 17 | init(state(alive, unloaded, 0)). 18 | 19 | transition(load, state(alive, _, _), state(alive, loaded,FinalArmed)) :- 20 | FinalArmed = 0. 21 | transition(wait, state(alive, Gun, PrevArmed), state(alive, Gun, FinalArmed)) :- 22 | duration(wait, D), FinalArmed .=. PrevArmed + D. 23 | transition(shoot, state(alive, loaded, PrevArmed), state(dead, unloaded, 0)) :- 24 | not spoiled(PrevArmed). 25 | transition(shoot, state(alive, loaded, PrevArmed), state(alive, unloaded, 0)) :- 26 | spoiled(PrevArmed). 27 | 28 | spoiled(Armed) :- Armed .>. 35. 29 | prohibited(shoot, T) :- T .<. 35. 30 | 31 | ?- T .<. 40, holds(T, state(dead,_,_), List). 32 | 33 | #show holds/3. 34 | -------------------------------------------------------------------------------- /examples/benchmark_iclp18/yale_shooting_scenario/yale_shooting_clingoLD.pl: -------------------------------------------------------------------------------- 1 | #include "incmode_lc.lp". 2 | 3 | #program base. 4 | action(load). 5 | action(shoot). 6 | action(wait). 7 | duration(load,25). 8 | duration(shoot,5). 9 | duration(wait,36). 10 | unloaded(0). 11 | &sum { at(0) } = 0. 12 | &sum { armed(0) } = 0. 13 | 14 | #program step(n). 15 | 1 { do(X,n) : action(X) } 1. 16 | &sum { at(n), -1 * at(N') } = D :- 17 | do(X,n), 18 | duration(X,D), 19 | N' = n - 1. 20 | 21 | loaded(n) :- 22 | loaded(n-1), 23 | not unloaded(n). 24 | unloaded(n) :- 25 | unloaded(n-1), 26 | not loaded(n). 27 | dead(n) :- 28 | dead(n-1). 29 | 30 | &sum { armed(n) } = 0 :- 31 | unloaded(n-1). 32 | &sum { armed(n), -1 * armed(N') } = D :- 33 | do(X,n), 34 | duration(X,D), 35 | N' = n + 1, 36 | loaded(N'). 37 | 38 | loaded(n) :- 39 | do(load,n). 40 | unloaded(n) :- 41 | do(shoot,n). 42 | dead(n) :- 43 | do(shoot,n), 44 | &sum { armed(n) } <= 35. 45 | 46 | :- do(shoot,n), unloaded(n-1). 47 | 48 | #program check(n). 49 | :- not dead(n), query(n). 50 | :- not &sum { at(n) } <= 100, query(n). 51 | :- do(shoot,n), not &sum { at(n) } > 35. 52 | -------------------------------------------------------------------------------- /examples/birds.pl: -------------------------------------------------------------------------------- 1 | % Given 3 birds, which can fly? 2 | 3 | #pred penguin(X) :: '@(X) is a penguin'. 4 | penguin(sam). % sam is a penguin 5 | #pred wounded_bird(X) :: '@(X) is a wounded bird'. 6 | wounded_bird(john). % john is wounded 7 | 8 | #pred bird(X) :: '@(X) is a bird'. 9 | bird(tweety). % tweety is just a bird 10 | % penguines and wounded birds are still birds 11 | bird(X) :- penguin(X). 12 | bird(X) :- wounded_bird(X). 13 | 14 | #pred ab(X) :: '@(X:bird) is abnormal'. 15 | % penguins and wounded birds are abnormal 16 | ab(X) :- penguin(X). 17 | ab(X) :- wounded_bird(X). 18 | 19 | #pred flies(X) :: '@(X) can fly'. 20 | % birds can fly if they are not abnormal 21 | flies(X) :- bird(X), not ab(X). 22 | 23 | #pred -flies(X) :: '@(X) can not fly'. 24 | % explicit closed world assumptions 25 | -flies(X) :- ab(X). 26 | -flies(X) :- -bird(X). 27 | 28 | -wounded_bird(X) :- not wounded_bird(X). 29 | 30 | -bird(X) :- not bird(X). 31 | 32 | -penguin(X) :- not penguin(X). 33 | 34 | -ab(X) :- not ab(X). 35 | 36 | 37 | ?- flies(X). 38 | -------------------------------------------------------------------------------- /examples/classic_negation_incostistent.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | p(1). 6 | -p(1). 7 | 8 | 9 | 10 | %% no model since the program is inconsistent 11 | ?- p(2). 12 | -------------------------------------------------------------------------------- /examples/compiled/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example of compiled files to be invoke using -c or --compiled: 6 | 7 | scasp -c birds_compiled.pl 8 | 9 | 10 | 11 | The order of the clauses in the compiled file affects the run-time: 12 | 13 | - To obtain the order generated by the s(ASP)/s(CASP) compiler invoke: 14 | 15 | scasp --code --raw ../birds.pl > birds_compiled_raw.pl 16 | 17 | - To obtain the readable version generated by s(CASP) invoke: 18 | 19 | scasp --code ../birds.pl > birds_compiled.pl 20 | 21 | 22 | 23 | NOTE: to keep the variable names in the query of the compiled 24 | version rename them as atoms. For example: 25 | 26 | ?- flies(X). --> ?- flies('X'). 27 | -------------------------------------------------------------------------------- /examples/dyncall/birds.pl: -------------------------------------------------------------------------------- 1 | :- use_module('../../prolog/scasp'). 2 | 3 | % Given 3 birds, which can fly? 4 | 5 | %#pred penguin(X) :: '@(X) is a penguin'. 6 | penguin(sam). % sam is a penguin 7 | %#pred wounded_bird(X) :: '@(X) is a wounded bird'. 8 | wounded_bird(john). % john is wounded 9 | 10 | %#pred bird(X) :: '@(X) is a bird'. 11 | bird(tweety). % tweety is just a bird 12 | % penguines and wounded birds are still birds 13 | %bird(X) :- penguin(X,_Y), s(_C). 14 | bird(X) :- wounded_bird(X). 15 | 16 | %% #pred ab(X) :: '@(X) is abnormal'. 17 | %% #pred not ab(X) :: '@(X) is not abnormal'. 18 | % penguins and wounded birds are abnormal 19 | ab(X) :- penguin(X). 20 | ab(X) :- wounded_bird(X). 21 | 22 | %#pred flies(X) :: '@(X) can fly'. 23 | % birds can fly if they are not abnormal 24 | flies(X) :- bird(X), not ab(X). 25 | 26 | %#pred -flies(X) :: '@(X) can not fly'. 27 | % explicit closed world assumptions 28 | -flies(X) :- ab(X). 29 | -flies(X) :- -bird(X). 30 | 31 | -wounded_bird(X) :- not wounded_bird(X). 32 | 33 | -bird(X) :- not bird(X). 34 | 35 | -penguin(X) :- not penguin(X). 36 | 37 | -ab(X) :- not ab(X). 38 | 39 | 40 | %?- flies(X). 41 | -------------------------------------------------------------------------------- /examples/dyncall/solve_findall.pl: -------------------------------------------------------------------------------- 1 | :- use_module(library(scasp)). 2 | 3 | validate(L) :- 4 | findall(X, member(X,L), LL), 5 | LL = L. 6 | 7 | member(X1, [X2|_]) :- X1 #= X2. 8 | member(X, [_|R]) :- member(X, R). 9 | 10 | % ?- validate([1,2,3]). 11 | -------------------------------------------------------------------------------- /examples/embed/pq.pl: -------------------------------------------------------------------------------- 1 | :- use_module(library(scasp)). 2 | 3 | :- begin_scasp(qp,[p/1,q/1]). 4 | 5 | p(X) :- not q(X). 6 | q(X) :- not p(X). 7 | 8 | :- end_scasp. 9 | -------------------------------------------------------------------------------- /examples/entail_loop.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | p(X) :- Y .>. X + 1, p(Y). 9 | 10 | 11 | 12 | 13 | ?- X .>. 0, p(X). -------------------------------------------------------------------------------- /examples/hamcycle.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | 6 | % fact for each edge edge(U, V). 7 | edge(0, 1). 8 | edge(1, 2). 9 | edge(2, 0). 10 | 11 | reachable(V) :- chosen(U, V), reachable(U). 12 | reachable(0) :- chosen(V, 0). 13 | 14 | % Every vertex must be reachable. 15 | :- vertex(U), not reachable(U). 16 | 17 | % Choose exactly one edge from each vertex. 18 | other(U, V) :- 19 | vertex(U), vertex(V), vertex(W), 20 | edge(U, W), V \= W, chosen(U, W). 21 | chosen(U, V) :- 22 | edge(U, V), not other(U, V). 23 | 24 | % You cannot choose two edges to the same vertex 25 | :- chosen(U, W), chosen(V, W), U \= V. 26 | ?- chosen(1,2). 27 | -------------------------------------------------------------------------------- /examples/hamcycle_two.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | vertex(3). 6 | 7 | % fact for each edge edge(U, V). 8 | edge(0, 1). 9 | edge(1, 2). 10 | edge(2, 3). 11 | edge(3, 0). 12 | 13 | edge(2, 0). 14 | edge(0, 3). 15 | edge(3, 1). 16 | 17 | reachable(V) :- chosen(U, V), reachable(U). 18 | reachable(0) :- chosen(V, 0). 19 | 20 | % Every vertex must be reachable. 21 | :- vertex(U), not reachable(U). 22 | 23 | % Choose exactly one edge from each vertex. 24 | other(U, V) :- 25 | vertex(U), vertex(V), vertex(W), 26 | edge(U, W), V \= W, chosen(U, W). 27 | chosen(U, V) :- 28 | edge(U, V), not other(U, V). 29 | 30 | % You cannot choose two edges to the same vertex 31 | :- chosen(U, W), chosen(V, W), U \= V. 32 | ?- chosen(1,2). 33 | -------------------------------------------------------------------------------- /examples/hanoi.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | % Move N disks in T moves. 4 | hanoi(N, T) :- 5 | moven(N, 0, T, 1, 2, 3). 6 | 7 | % Move N disks from peg A to peg B using peg C. Assign move numbers. 8 | moven(N, Ti, To, A, B, C) :- 9 | N > 1, 10 | N1 is N - 1, 11 | moven(N1, Ti, T2, A, C, B), 12 | T3 is T2 + 1, 13 | move(T3, A, B), 14 | moven(N1, T3, To, C, B, A). 15 | moven(1, Ti, To, A, B, _) :- 16 | To is Ti + 1, 17 | move(To, A, B). 18 | 19 | % move T: move disk from P1 to P2. 20 | % any move may or may not be selected. 21 | move(T, P1, P2) :- 22 | not negmove(T, P1, P2). 23 | 24 | negmove(T, P1, P2) :- 25 | not move(T, P1, P2). 26 | 27 | ?- hanoi(8, T). 28 | -------------------------------------------------------------------------------- /examples/hanoi_7.pl: -------------------------------------------------------------------------------- 1 | % Move N disks in T moves. 2 | hanoi(N, T) :- 3 | moven(N, 0, T, 1, 2, 3). 4 | 5 | % Move N disks from peg A to peg B using peg C. Assign move numbers. 6 | moven(N, Ti, To, A, B, C) :- 7 | N > 1, 8 | N1 is N - 1, 9 | moven(N1, Ti, T2, A, C, B), 10 | T3 is T2 + 1, 11 | move(T3, A, B), 12 | moven(N1, T3, To, C, B, A). 13 | moven(1, Ti, To, A, B, _) :- 14 | To is Ti + 1, 15 | move(To, A, B). 16 | 17 | % move T: move disk from P1 to P2. 18 | % any move may or may not be selected. 19 | move(T, P1, P2) :- 20 | not negmove(T, P1, P2). 21 | 22 | negmove(T, P1, P2) :- 23 | not move(T, P1, P2). 24 | 25 | ?- hanoi(7, T). 26 | -------------------------------------------------------------------------------- /examples/min_model.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | p(X) :- r(X). 6 | p(X) :- not s(X), r(X). 7 | 8 | r(2). 9 | r(1). 10 | s(X) :- not t(X). 11 | t(X) :- not s(X). 12 | 13 | 14 | ?- p(X). 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/pq.pl: -------------------------------------------------------------------------------- 1 | p(X) :- not q(X). 2 | q(X) :- not p(X). 3 | 4 | 5 | ?- p(X). 6 | -------------------------------------------------------------------------------- /examples/queens.pl: -------------------------------------------------------------------------------- 1 | % 4-queens: ((1,2),(2,4),(3,1),(4,3)) and ((1,3),(2,1),(3,4),(4,2)) 2 | % Retargetable N-queens program. 3 | 4 | nqueens(N, Q) :- 5 | _nqueens(N, N, [], Q). 6 | 7 | % Pick queens one at a time and test against all previous queens. 8 | _nqueens(X, N, Qi, Qo) :- 9 | X > 0, 10 | _pickqueen(X, Y, N), 11 | not _attack(X, Y, Qi), 12 | X1 is X - 1, 13 | _nqueens(X1, N, [q(X, Y) | Qi], Qo). 14 | _nqueens(0, _, Q, Q). 15 | 16 | 17 | % pick a queen for row X. 18 | _pickqueen(X, Y, Y) :- 19 | Y > 0, 20 | q(X, Y). 21 | _pickqueen(X, Y, N) :- 22 | N > 1, 23 | N1 is N - 1, 24 | _pickqueen(X, Y, N1). 25 | 26 | % check if a queen can attack any previously selected queen. 27 | _attack(X, _, [q(X, _) | _]). % same row 28 | _attack(_, Y, [q(_, Y) | _]). % same col 29 | _attack(X, Y, [q(X2, Y2) | _]) :- % same diagonal 30 | Xd is X2 - X, 31 | _abs(Xd, Xd2), 32 | Yd is Y2 - Y, 33 | _abs(Yd, Yd2), 34 | Xd2 = Yd2. 35 | _attack(X, Y, [_ | T]) :- 36 | _attack(X, Y, T). 37 | 38 | q(X, Y) :- not _negq(X, Y). 39 | _negq(X, Y) :- not q(X, Y). 40 | 41 | _abs(X, X) :- X >= 0. 42 | _abs(X, Y) :- X < 0, Y is X * -1. 43 | 44 | ?- nqueens(4, Q). 45 | -------------------------------------------------------------------------------- /examples/rps.pl: -------------------------------------------------------------------------------- 1 | :- use_module(library(scasp)). 2 | :- use_module(library(scasp/human)). 3 | 4 | #pred player('G', 'X') :: '@(X) played in @(G)'. 5 | #pred winner('Game','Player') :: 'The winner of @(Game) is @(Player)'. 6 | #pred throw('Player','Sign') :: '@(Player) threw @(Sign)'. 7 | #pred beat('Sign','OtherSign') :: '@(Sign) beats @(OtherSign)'. 8 | 9 | beat(rock,scissors). 10 | beat(scissors,paper). 11 | beat(paper,rock). 12 | 13 | #abducible player(Game, Player). 14 | #abducible throw(Player, Sign). 15 | 16 | winner(Game,Player) :- 17 | player(Game, Player), 18 | player(Game, OtherPlayer), 19 | throw(Player,Sign), 20 | throw(OtherPlayer,OtherSign), 21 | beat(Sign,OtherSign). 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /pack.pl: -------------------------------------------------------------------------------- 1 | pack_version(2). 2 | name(scasp). 3 | version('1.1.4'). 4 | title('Goal directed ASP solver'). 5 | keywords([scasp, asp]). 6 | author('Joaquin Arias', 'joaquin.arias@urjc.es' ). 7 | author('Kyle Marple', '' ). 8 | author('Jan Wielemaker', 'jan@swi-prolog.org' ). 9 | requires(prolog >= '9'). 10 | home('https://github.com/SWI-Prolog/sCASP' ). 11 | download( 'https://github.com/SWI-Prolog/sCASP.git' ). 12 | -------------------------------------------------------------------------------- /prolog/scasp/html/html_head.pl: -------------------------------------------------------------------------------- 1 | :- module(scasp_html_head, [load_html_head/1]). 2 | 3 | load_html_head('\n \n \n \n c(ASP) Justification\n \n \n \n \n \n \n \n \n'). 4 | -------------------------------------------------------------------------------- /prolog/scasp/html/html_tail.pl: -------------------------------------------------------------------------------- 1 | :- module(html_tail, [load_html_tail/1]). 2 | 3 | load_html_tail('\n
\n\n\n\n'). -------------------------------------------------------------------------------- /prolog/scasp/ops.pl: -------------------------------------------------------------------------------- 1 | :- module(scasp_ops, 2 | [ op(700, xfx, [#= , #<>, #< , #> , #=<, #>= ]), 3 | op(950, xfx, ::), 4 | op(700, xfx, '| '), 5 | op(700, xfx, [~>, <~]), 6 | op(900, fy, not), 7 | op(700, xfx, '\u2209'), 8 | 9 | scasp_push_operators/0, 10 | scasp_push_operators/1, % +Module 11 | scasp_pop_operators/0 12 | ]). 13 | :- use_module(library(apply)). 14 | :- use_module(library(operators)). 15 | 16 | scasp_push_operators :- 17 | prolog_load_context(module, Context), 18 | scasp_push_operators(Context). 19 | 20 | scasp_push_operators(Context) :- 21 | findall(op(Pri, Ass, Op), scasp_op(Pri, Ass, Op), Ops), 22 | push_operators(Context:Ops). 23 | 24 | scasp_pop_operators :- 25 | pop_operators. 26 | 27 | term_expansion(scasp_op(Pri, Ass, List), Ops) :- 28 | maplist(mkop(Pri, Ass), List, Ops). 29 | 30 | mkop(Pri, Ass, Op, scasp_op(Pri, Ass, Op)). 31 | 32 | scasp_op(700, xfx, [#= , #<>, #< , #> , #=<, #>= ]). 33 | scasp_op(950, xfx, [::]). 34 | scasp_op(700, xfx, ['| ']). 35 | scasp_op(700, xfx, [~>, <~]). 36 | scasp_op(900, fy, [not]). 37 | scasp_op(700, xfx, ['\u2209']). 38 | 39 | % from input.pl 40 | scasp_op(1200, fx, #). 41 | scasp_op(350, fx, [include, compute, abducible]). 42 | scasp_op(1150, fx, [table, show, pred]). 43 | -------------------------------------------------------------------------------- /scripts/publish: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git push 4 | git push --tags 5 | 6 | swipl pack remove scasp 7 | swipl pack install -y https://github.com/SWI-Prolog/sCASP.git 8 | -------------------------------------------------------------------------------- /test/all_programs/abdbirds.pl: -------------------------------------------------------------------------------- 1 | % Birds with abducibles. If we observe that a bird is abnormal, we can use our 2 | % abducibles to speculate why. 3 | 4 | #abducible wounded_bird(X). 5 | #abducible penguin(X). 6 | #abducible ab(X). 7 | 8 | % Sam, Tweety and John are birds. 9 | bird(sam). 10 | bird(tweety). 11 | bird(john). 12 | 13 | % penguins and wounded birds are abnormal 14 | ab(X) :- penguin(X). 15 | ab(X) :- wounded_bird(X). 16 | 17 | % birds that are not abnormal can fly 18 | flies(X) :- bird(X), not ab(X). 19 | 20 | ?- not flies(tweety). 21 | -------------------------------------------------------------------------------- /test/all_programs/bec_light.pl: -------------------------------------------------------------------------------- 1 | % Basic Event Calculus 2 | 3 | %% Include the BASIC EVENT CALCULUS THEORY 4 | #include 'bec_theory.incl'. 5 | 6 | %% Inspired by example 14 from Mueller (2014) 7 | 8 | % If a light is turned on, it will be on: 9 | initiates(turn_on, light_on, T). 10 | 11 | % If a light is turned on, whether it is red or green will be released 12 | % from the commonsense law of inertia: 13 | releases(turn_on, light_red, T). 14 | releases(turn_on, light_green, T). 15 | 16 | % If a light is turned off, it will not be on. 17 | terminates(turn_off, light_on, T). 18 | 19 | % After a light is turned on, it will emit red for up to two seconds 20 | % and green after at least two seconds: 21 | trajectory(light_on, T1, light_red, T2) :- T1 #< T2, T2 #< T1 + 1. 22 | trajectory(light_on, T1, light_green, T2) :- T2 #>= T1 + 1. 23 | 24 | initiallyN(light_on). 25 | 26 | %% Actions 27 | happens(turn_on, 2). 28 | happens(turn_off, 4). 29 | happens(turn_on, 6). 30 | 31 | ?- holdsAt(light_red, T). 32 | -------------------------------------------------------------------------------- /test/all_programs/bec_loan.pl: -------------------------------------------------------------------------------- 1 | % Basic Event Calculus 2 | 3 | %% Include the BASIC EVENT CALCULUS THEORY 4 | #include 'bec_theory.incl'. 5 | 6 | is_1_day_after(B, A) :- B #= A + 1. 7 | 8 | %% based on the loan agreement example in Logical English 9 | initiates(ends(A), it_is(B), _) :- 10 | is_1_day_after(B, A). 11 | initiates(ends(1), is_liable_to_litigation(the_lender), A) :- 12 | holdsAt(requested_on(the_borrower, 1000, 2), A), 13 | not holdsAt(advanced_on(the_lender, 1000, _), 1). 14 | initiates(ends(2), is_terminated(the_agreement), _) :- 15 | not holdsAt(requested_on(the_borrower, 1000, 2), 2). 16 | initiates(requests(the_borrower, A), requested_on(the_borrower, A, B), B). 17 | initiates(advances(the_lender, A), advanced_on(the_lender, A, B), B). 18 | initiates(ends(_), is_potentially_defaulted(B), A) :- 19 | B=pays_to(C, D, E), 20 | is_due_on_from_to(D, A, C, E), 21 | holdsAt(it_is(F), F), 22 | not holdsAt(paid_to_on(C, D, E, _), F). 23 | initiates(pays_to(A, B, C), paid_to_on(A, B, C, D), D). 24 | 25 | is_due_on_from_to(550, 4, the_borrower, the_lender). 26 | is_due_on_from_to(525, 5, the_borrower, the_lender). 27 | 28 | %% Actions 29 | 30 | happens(ends(1), 1). 31 | happens(ends(2), 2). 32 | happens(requests(the_borrower, 1000), 2). 33 | 34 | ?- holdsAt(F, T). 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/all_programs/birds.pl: -------------------------------------------------------------------------------- 1 | % Given 3 birds, which can fly? 2 | 3 | #pred penguin(X) :: '@(X) is a penguin'. 4 | penguin(sam). % sam is a penguin 5 | #pred wounded_bird(X) :: '@(X) is a wounded bird'. 6 | wounded_bird(john). % john is wounded 7 | 8 | #pred bird(X) :: '@(X) is a bird'. 9 | bird(tweety). % tweety is just a bird 10 | % penguines and wounded birds are still birds 11 | bird(X) :- penguin(X,Y), s(C). 12 | bird(X) :- wounded_bird(X). 13 | 14 | %% #pred ab(X) :: '@(X) is abnormal'. 15 | %% #pred not ab(X) :: '@(X) is not abnormal'. 16 | % penguins and wounded birds are abnormal 17 | ab(X) :- penguin(X). 18 | ab(X) :- wounded_bird(X). 19 | 20 | #pred flies(X) :: '@(X) can fly'. 21 | % birds can fly if they are not abnormal 22 | flies(X) :- bird(X), not ab(X). 23 | 24 | #pred -flies(X) :: '@(X) can not fly'. 25 | % explicit closed world assumptions 26 | -flies(X) :- ab(X). 27 | -flies(X) :- -bird(X). 28 | 29 | -wounded_bird(X) :- not wounded_bird(X). 30 | 31 | -bird(X) :- not bird(X). 32 | 33 | -penguin(X) :- not penguin(X). 34 | 35 | -ab(X) :- not ab(X). 36 | 37 | 38 | ?- flies(X). 39 | -------------------------------------------------------------------------------- /test/all_programs/classic_negation_inconstistent.pass: -------------------------------------------------------------------------------- 1 | []-[]. 2 | -------------------------------------------------------------------------------- /test/all_programs/classic_negation_inconstistent.pl: -------------------------------------------------------------------------------- 1 | % Simple classical contradiction 2 | 3 | p(1). 4 | -p(1). 5 | 6 | %% no model since the program is inconsistent 7 | ?- p(2). 8 | -------------------------------------------------------------------------------- /test/all_programs/classic_negation_incostistent.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | p(1). 6 | -p(1). 7 | 8 | 9 | 10 | %% no model since the program is inconsistent 11 | ?- p(2). 12 | -------------------------------------------------------------------------------- /test/all_programs/clpq_equality.pl: -------------------------------------------------------------------------------- 1 | -mutually_exclusive(S1, S2) :- 2 | member(X, S1), member(X, S2). 3 | 4 | mutually_exclusive(S1, S2) :- 5 | not -mutually_exclusive(S1, S2). 6 | 7 | member(X1, [X2|_]) :- X1 #= X2. 8 | member(X, [_|R]) :- member(X, R). 9 | 10 | ?- mutually_exclusive([1,2], [3,4]). -------------------------------------------------------------------------------- /test/all_programs/cross_train_Pontelli_97_execution.txt: -------------------------------------------------------------------------------- 1 | Ciao 1.16.0-alpha.3 (2017-08-23 15:19:45 -0500) [DARWINi686] 2 | ?- ensure_loaded('/Users/joaquin/Documents/Imdea/ASP/sCASP/test_scasp/cross_train_Pontelli_97.pl'). 3 | 4 | yes 5 | ?- findrange(M,N,X). 6 | 7 | X = [approach,lower,down,inn,out,exit,raise,up,approach], 8 | M.>.N, 9 | M.>.1.0, 10 | N.<.7.0, 11 | N.>.0 ? 12 | 13 | yes 14 | ?- downmorethan10. 15 | 16 | no 17 | ?- downbeforein(X). 18 | 19 | no 20 | ?- 21 | -------------------------------------------------------------------------------- /test/all_programs/dcc/hamilton_c.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(a). 3 | vertex(b). 4 | vertex(c). 5 | vertex(d). 6 | 7 | 8 | % fact for each edge(U, V). 9 | edge(b, a). 10 | edge(b, d). 11 | edge(a, c). 12 | 13 | edge(a, b). 14 | edge(b, c). 15 | edge(c, d). 16 | edge(d, a). 17 | 18 | edge(c, a). 19 | edge(a, d). 20 | edge(d, b). 21 | 22 | 23 | reachable(V) :- chosen(V, a). 24 | reachable(V) :- chosen(V, U), reachable(U). 25 | 26 | 27 | % Choose exactly one edge from each vertex. 28 | chosen(U, V) :- 29 | edge(U, V), not other(U, V). 30 | other(U, V) :- 31 | edge(U, V), not chosen(U, V). 32 | 33 | % Every vertex must be reachable. 34 | :- vertex(U), not reachable(U). 35 | % You cannot choose two edges to the same vertex 36 | :- chosen(U, W), U \= V, chosen(V, W). 37 | :- chosen(W, U), U \= V, chosen(W, V). 38 | 39 | ?- reachable(a). 40 | 41 | #show chosen/2. 42 | -------------------------------------------------------------------------------- /test/all_programs/family-le-scasp.pl: -------------------------------------------------------------------------------- 1 | :-module('family-scasp+http://tests.com', []). 2 | source_lang(en). 3 | % s(CASP) Programming 4 | :- use_module(library(scasp)). 5 | % Uncomment to suppress warnings 6 | %:- style_check(-discontiguous). 7 | :- style_check(-singleton). 8 | :- set_prolog_flag(scasp_forall, prev). 9 | :- dynamic is_a_parent_of/2, is_a_grandparent_of/2. 10 | #pred is_a_parent_of(B,C) :: ' @(B:person) is a parent of @(C:person) '. 11 | #pred is_a_grandparent_of(B,C) :: ' @(B:person) is a grandparent of @(C:person) '. 12 | is_a_grandparent_of(A, B) :- 13 | is_a_parent_of(A, C), 14 | is_a_parent_of(C, B). 15 | /* Scenario one */ 16 | is_a_parent_of(john, mary). 17 | is_a_parent_of(mary, john). 18 | % */ 19 | /** */ 20 | ?- is_a_grandparent_of(_102530,_102532). 21 | /* **/ 22 | -------------------------------------------------------------------------------- /test/all_programs/family.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[goal_origin(ancestor(bob,sam),32)-[goal_origin(parent(bob,jill),28)-[goal_origin(father(bob,jill),20)-[]],goal_origin(ancestor(jill,sam),31)-[goal_origin(parent(jill,sam),29)-[goal_origin(mother(jill,sam),27)-[]]]],o_nmr_check-[(not o_chk_1('$VAR'('A')))-[goal_origin(test2('$VAR'('A'),'$VAR'('E')'| '{'$VAR'('E')∉[1]}),3)-[(not test3('$VAR'('A')))-[goal_origin(test1('$VAR'('A')),2)-[]]],goal_origin(test2('$VAR'('A'),1),4)-[(not test3('$VAR'('A')))-[goal_origin(test1('$VAR'('A')),2)-[]]]],(not o_chk_2('$VAR'('B')))-[goal_origin(test1('$VAR'('B')),2)-[]],(not o_chk_3('$VAR'('_'),'$VAR'('_')'| '{'$VAR'('_')∉[1]}))-[],(not o_chk_3('$VAR'('C'),1))-[(not test3('$VAR'('C')))-[goal_origin(test1('$VAR'('C')),2)-[]],goal_origin(test2('$VAR'('C'),1),4)-[(not test3('$VAR'('C')))-[goal_origin(test1('$VAR'('C')),2)-[]]]],(not o_chk_4('$VAR'('_'),1))-[],(not o_chk_4('$VAR'('D'),'$VAR'('F')'| '{'$VAR'('F')∉[1]}))-[(not test3('$VAR'('D')))-[goal_origin(test1('$VAR'('D')),2)-[]],goal_origin(test2('$VAR'('D'),'$VAR'('F')'| '{'$VAR'('F')∉[1]}),3)-[(not test3('$VAR'('D')))-[goal_origin(test1('$VAR'('D')),2)-[]]]]]]]-[[test1('$VAR'('A')),test1('$VAR'('B')),test1('$VAR'('C')),test1('$VAR'('D')),not test3('$VAR'('A')),not test3('$VAR'('C')),not test3('$VAR'('D')),ancestor(bob,sam),ancestor(jill,sam),father(bob,jill),mother(jill,sam),parent(bob,jill),parent(jill,sam),test2('$VAR'('A'),'$VAR'('E')'| '{'$VAR'('E')∉[1]}),test2('$VAR'('A'),1),test2('$VAR'('C'),1),test2('$VAR'('D'),'$VAR'('F')'| '{'$VAR'('F')∉[1]})]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/forall_arity.pass: -------------------------------------------------------------------------------- 1 | []-[]. 2 | -------------------------------------------------------------------------------- /test/all_programs/forall_arity.pl: -------------------------------------------------------------------------------- 1 | % Dual rules for q/2 and q/1 with one body variable used to clash. 2 | 3 | p(X) :- 4 | q(X,_). 5 | 6 | q(ha) :- 7 | q(a,X), 8 | X > 1. 9 | 10 | q(a,2). 11 | 12 | ?- not p(a). 13 | -------------------------------------------------------------------------------- /test/all_programs/gpa.pl: -------------------------------------------------------------------------------- 1 | % From Baral Book pg 81 2 | eligible(X) :- highGPA(X). 3 | eligible(X) :- special(X), fairGPA(X). 4 | -eligible(X) :- -special(X), -highGPA(X). 5 | interview(X) :- not eligible(X), not -eligible(X). 6 | fairGPA(john). 7 | -highGPA(john). 8 | ?- interview(john). 9 | -------------------------------------------------------------------------------- /test/all_programs/hamcycle.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | 6 | % fact for each edge edge(U, V). 7 | edge(0, 1). 8 | edge(1, 2). 9 | edge(2, 0). 10 | 11 | reachable(V) :- chosen(U, V), reachable(U). 12 | reachable(0) :- chosen(V, 0). 13 | 14 | % Every vertex must be reachable. 15 | :- vertex(U), not reachable(U). 16 | 17 | % Choose exactly one edge from each vertex. 18 | other(U, V) :- 19 | vertex(U), vertex(V), vertex(W), 20 | edge(U, W), V \= W, chosen(U, W). 21 | chosen(U, V) :- 22 | edge(U, V), not other(U, V). 23 | 24 | % You cannot choose two edges to the same vertex 25 | :- chosen(U, W), chosen(V, W), U \= V. 26 | ?- chosen(1,2). 27 | -------------------------------------------------------------------------------- /test/all_programs/hamcycle2.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | 6 | % fact for each edge edge(U, V). 7 | edge(0, 1). 8 | edge(1, 2). 9 | edge(2, 0). 10 | 11 | reachable(V) :- chosen(U, V), reachable(U). 12 | reachable(0) :- chosen(V, 0). 13 | 14 | % Every vertex must be reachable. 15 | :- vertex(U), not reachable(U). 16 | 17 | % Choose exactly one edge from each vertex. 18 | other(U, V) :- 19 | vertex(U), vertex(V), vertex(W), 20 | edge(U, W), V \= W, chosen(U, W). 21 | chosen(U, V) :- 22 | edge(U, V), not other(U, V). 23 | 24 | % You cannot choose two edges to the same vertex 25 | :- chosen(U, W), chosen(V, W), U \= V. 26 | ?- chosen(1,2). 27 | -------------------------------------------------------------------------------- /test/all_programs/hamcycle_two.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | vertex(3). 6 | 7 | % fact for each edge edge(U, V). 8 | edge(0, 1). 9 | edge(1, 2). 10 | edge(2, 3). 11 | edge(3, 0). 12 | 13 | edge(2, 0). 14 | edge(0, 3). 15 | edge(3, 1). 16 | 17 | reachable(V) :- chosen(U, V), reachable(U). 18 | reachable(0) :- chosen(V, 0). 19 | 20 | % Every vertex must be reachable. 21 | :- vertex(U), not reachable(U). 22 | 23 | % Choose exactly one edge from each vertex. 24 | other(U, V) :- 25 | vertex(U), vertex(V), vertex(W), 26 | edge(U, W), V \= W, chosen(U, W). 27 | chosen(U, V) :- 28 | edge(U, V), not other(U, V). 29 | 30 | % You cannot choose two edges to the same vertex 31 | :- chosen(U, W), chosen(V, W), U \= V. 32 | ?- chosen(1,2). 33 | -------------------------------------------------------------------------------- /test/all_programs/hanoi.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | % Move N disks in T moves. 4 | hanoi(N, T) :- 5 | moven(N, 0, T, 1, 2, 3). 6 | 7 | % Move N disks from peg A to peg B using peg C. Assign move numbers. 8 | moven(N, Ti, To, A, B, C) :- 9 | N > 1, 10 | N1 is N - 1, 11 | moven(N1, Ti, T2, A, C, B), 12 | T3 is T2 + 1, 13 | move(T3, A, B), 14 | moven(N1, T3, To, C, B, A). 15 | moven(1, Ti, To, A, B, _) :- 16 | To is Ti + 1, 17 | move(To, A, B). 18 | 19 | % move T: move disk from P1 to P2. 20 | % any move may or may not be selected. 21 | move(T, P1, P2) :- 22 | not negmove(T, P1, P2). 23 | 24 | negmove(T, P1, P2) :- 25 | not move(T, P1, P2). 26 | 27 | ?- hanoi(8, T). 28 | -------------------------------------------------------------------------------- /test/all_programs/hanoi_7.pl: -------------------------------------------------------------------------------- 1 | % Move N disks in T moves. 2 | hanoi(N, T) :- 3 | moven(N, 0, T, 1, 2, 3). 4 | 5 | % Move N disks from peg A to peg B using peg C. Assign move numbers. 6 | moven(N, Ti, To, A, B, C) :- 7 | N > 1, 8 | N1 is N - 1, 9 | moven(N1, Ti, T2, A, C, B), 10 | T3 is T2 + 1, 11 | move(T3, A, B), 12 | moven(N1, T3, To, C, B, A). 13 | moven(1, Ti, To, A, B, _) :- 14 | To is Ti + 1, 15 | move(To, A, B). 16 | 17 | % move T: move disk from P1 to P2. 18 | % any move may or may not be selected. 19 | move(T, P1, P2) :- 20 | not negmove(T, P1, P2). 21 | 22 | negmove(T, P1, P2) :- 23 | not move(T, P1, P2). 24 | 25 | ?- hanoi(7, T). 26 | -------------------------------------------------------------------------------- /test/all_programs/hanoi_scasp_7.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | % Move N disks in T moves. 4 | hanoi(N, T) :- 5 | move_(N, 0, T, a, b, c). 6 | 7 | % Move N disks from peg Pi to peg Pf using peg Paux. 8 | move_(N,Ti,Tf,Pi,Pf,Paux) :- 9 | N #> 1, 10 | N1 #= N - 1, 11 | move_(N1,Ti,T1,Pi,Paux,Pf), 12 | move_(1,T1,T2,Pi,Pf,Paux), 13 | move_(N1,T2,Tf,Paux,Pf,Pi). 14 | move_(1,Ti,Tf,Pi,Pf,_) :- 15 | Tf #= Ti + 1, 16 | move(Pi,Pf,Tf). 17 | 18 | % move T: move disk from Pi to Pf. 19 | % any move may or may not be selected. 20 | move(Pi,Pf,T):- not negmove(Pi,Pf,T). 21 | negmove(Pi,Pf,T):- not move(Pi,Pf,T). 22 | 23 | ?- hanoi(7, T). 24 | 25 | #show move/3. 26 | -------------------------------------------------------------------------------- /test/all_programs/haplotype.pl: -------------------------------------------------------------------------------- 1 | % https://swish.swi-prolog.org/?code=https://raw.githubusercontent.com/samwalrus/scasp_haplotype/master/swish.swinb 2 | %conflation. 3 | conflation(2,0,1). %Heterozygous 4 | conflation(2,1,0). %Heterozygous 5 | conflation(0,0,0). %Homozygous 6 | conflation(1,1,1). %Homozygous. 7 | 8 | conflation_seq([],[],[]). 9 | conflation_seq([G|Gs],[HA1|HAs],[HB1|HBs]):- 10 | conflation(G,HA1,HB1), 11 | conflation_seq(Gs,HAs,HBs). 12 | 13 | genotype(_G,Genotype):- 14 | haplotype(Hap1), 15 | haplotype(Hap2), 16 | conflation_seq(Genotype,Hap1,Hap2). 17 | 18 | haplotype(_X). 19 | 20 | ?- genotype(1,[2,1,2]),genotype(2,[1,2,1]). -------------------------------------------------------------------------------- /test/all_programs/impossibleancestor-scasp.pl: -------------------------------------------------------------------------------- 1 | :-module('impossibleancestor-scasp', []). 2 | source_lang(en). 3 | % s(CASP) Programming 4 | :- use_module(library(scasp)). 5 | % Uncomment to suppress warnings 6 | %:- style_check(-discontiguous). 7 | :- style_check(-singleton). 8 | :- set_prolog_flag(scasp_forall, prev). 9 | :- dynamic is_an_ancestor_of/2, is_a_parent_of/2, is_a_grandparent_of/2, is_impossible/1. 10 | #pred is_an_ancestor_of(B,C) :: ' @(B:person) is an ancestor of @(C:person) '. 11 | #pred is_a_parent_of(B,C) :: ' @(B:person) is a parent of @(C:person) '. 12 | #pred is_a_grandparent_of(B,C) :: ' @(B:person) is a grandparent of @(C:person) '. 13 | #pred is_impossible(B) :: ' @(B:person) is impossible '. 14 | is_a_grandparent_of(A, B) :- 15 | is_a_parent_of(A, C), 16 | is_a_parent_of(C, B). 17 | is_an_ancestor_of(A, B) :- 18 | is_a_parent_of(A, B). 19 | is_an_ancestor_of(A, B) :- 20 | is_a_parent_of(A, C), 21 | is_an_ancestor_of(C, B). 22 | /* Scenario one 23 | is_a_parent_of(john, mary). 24 | is_a_parent_of(mary, alice). 25 | % */ 26 | /* Scenario two */ 27 | is_a_parent_of(john, mary). 28 | is_a_parent_of(mary, john). 29 | is_impossible(A) :- 30 | is_an_ancestor_of(A, A). 31 | /* % */ 32 | /** 33 | ?- ? is_a_grandparent_of(_170772,_170774). 34 | ?- ? is_an_ancestor_of(_170760,_170762). */ 35 | ?- is_impossible(_170750). 36 | /* **/ 37 | -------------------------------------------------------------------------------- /test/all_programs/left-rec-succ_BAD.pl: -------------------------------------------------------------------------------- 1 | % Problematic left-recursion example (requires tabling) 2 | 3 | r(X, Y) :- r(X, Z), p(Z, Y). 4 | r(X, Y) :- p(X, Y). 5 | % r(a,d) works if goals reversed. Likely r(X, Z) will never succeed with Z = c 6 | r(X, Y) :- r(X, Z), q(Z, Y). 7 | 8 | p(a, b). 9 | p(b, c). 10 | q(c, d). 11 | 12 | ?- r(a,Y). 13 | -------------------------------------------------------------------------------- /test/all_programs/lion.pl: -------------------------------------------------------------------------------- 1 | % Animals 2 | 3 | animal(lion). 4 | animal(snake). 5 | animal(monkey). 6 | animal(rat). 7 | 8 | live(monkey, forest). 9 | live(snake, zoo). 10 | live(rat, apartment). 11 | 12 | live(X, forest) :- 13 | animal(X), 14 | not ab(live_animal(X)), 15 | not -live(X, forest). 16 | 17 | -live(X, Z) :- 18 | live(X, Y), 19 | Y \= Z. 20 | 21 | % ab(_) :- false. 22 | 23 | ?- live(lion, X). 24 | -------------------------------------------------------------------------------- /test/all_programs/loop_pos.pl: -------------------------------------------------------------------------------- 1 | % Possitive success loop (no models) 2 | 3 | p(X) :- p(Y). 4 | ?- p(X). 5 | -------------------------------------------------------------------------------- /test/all_programs/loop_succ_pos.pl: -------------------------------------------------------------------------------- 1 | % Possitive success loop (with model) 2 | 3 | p(X) :- p(Y). 4 | p(0). 5 | ?- p(X). 6 | -------------------------------------------------------------------------------- /test/all_programs/loopvar.pl: -------------------------------------------------------------------------------- 1 | % Even loop through negation with inequality (version I) 2 | 3 | p(X) :- not q(X). 4 | q(X) :- not p(X). 5 | r(X) :- X \= 3, X \= 4, q(X). 6 | ?- p(X), r(Y). 7 | -------------------------------------------------------------------------------- /test/all_programs/loopvar2.pl: -------------------------------------------------------------------------------- 1 | % Even loop through negation with inequality (version II) 2 | 3 | p(1,X) :- not q(1,X). 4 | q(1,X) :- not p(1,X). 5 | r(X) :- X \= 3, X \= 4, q(1,X). 6 | ?- p(1,X), r(Y). 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/all_programs/min_model.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | p(X) :- r(X). 6 | p(X) :- not s(X), r(X). 7 | 8 | r(2). 9 | r(1). 10 | s(X) :- not t(X). 11 | t(X) :- not s(X). 12 | 13 | 14 | ?- p(X). 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/all_programs/natnum.pl: -------------------------------------------------------------------------------- 1 | % Natural numbers (piano representation) 2 | 3 | s(0). 4 | s(s(X)) :- 5 | s(X). 6 | 7 | sum(s(0), X, s(X)). 8 | sum(X, s(0), s(X)). 9 | sum(s(X), Y, s(Z)) :- 10 | X \= 0, 11 | sum(X, Y, Z). 12 | 13 | sumlist([X | T], [Y | T2], [Z | T3]) :- 14 | sum(X, Y, Z), 15 | sumlist(T, T2, T3). 16 | sumlist([], [], []). 17 | 18 | ?- sumlist([s(s(0)), s(s(s(0)))], [s(s(s(0))), s(s(s(0)))], X). 19 | -------------------------------------------------------------------------------- /test/all_programs/path_loop.pl: -------------------------------------------------------------------------------- 1 | % Path in graph 2 | 3 | %#table path/2. 4 | 5 | edge(a,b). 6 | edge(b,c). 7 | edge(a,d) :- not path(c,d). 8 | 9 | path(X,Y) :- 10 | edge(X,Y). 11 | path(X,Y) :- 12 | edge(X,Z), 13 | path(Z,Y). 14 | 15 | 16 | ?- path(a,Y). 17 | 18 | -------------------------------------------------------------------------------- /test/all_programs/pq.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[goal_origin(p('$VAR'('X')),1)-[(not q('$VAR'('X')))-[chs(p('$VAR'('X')))-[]]]]]-[[p('$VAR'('X')),not q('$VAR'('X'))]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/pq.pl: -------------------------------------------------------------------------------- 1 | p(X) :- not q(X). 2 | q(X) :- not p(X). 3 | 4 | 5 | ?- p(X). 6 | -------------------------------------------------------------------------------- /test/all_programs/queens.pl: -------------------------------------------------------------------------------- 1 | % 4-queens 2 | % 3 | % Retargetable N-queens program. 4 | % Models ((1,2),(2,4),(3,1),(4,3)) and ((1,3),(2,1),(3,4),(4,2)) 5 | 6 | nqueens(N, Q) :- 7 | nqueens(N, N, [], Q). 8 | 9 | % Pick queens one at a time and test against all previous queens. 10 | nqueens(X, N, Qi, Qo) :- 11 | X > 0, 12 | pickqueen(X, Y, N), 13 | not attack(X, Y, Qi), 14 | X1 is X - 1, 15 | nqueens(X1, N, [q(X, Y) | Qi], Qo). 16 | nqueens(0, _, Q, Q). 17 | 18 | 19 | % pick a queen for row X. 20 | pickqueen(X, Y, Y) :- 21 | Y > 0, 22 | q(X, Y). 23 | pickqueen(X, Y, N) :- 24 | N > 1, 25 | N1 is N - 1, 26 | pickqueen(X, Y, N1). 27 | 28 | % check if a queen can attack any previously selected queen. 29 | attack(X, _, [q(X, _) | _]). % same row 30 | attack(_, Y, [q(_, Y) | _]). % same col 31 | attack(X, Y, [q(X2, Y2) | _]) :- % same diagonal 32 | Xd is X2 - X, 33 | abs(Xd, Xd2), 34 | Yd is Y2 - Y, 35 | abs(Yd, Yd2), 36 | Xd2 = Yd2. 37 | attack(X, Y, [_ | T]) :- 38 | attack(X, Y, T). 39 | 40 | q(X, Y) :- not negq(X, Y). 41 | negq(X, Y) :- not q(X, Y). 42 | 43 | abs(X, X) :- X >= 0. 44 | abs(X, Y) :- X < 0, Y is X * -1. 45 | 46 | ?- nqueens(4, Q). 47 | -------------------------------------------------------------------------------- /test/all_programs/rat.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[goal_origin(p('$VAR'('X')'| '{'$VAR'('X')#>7r12}),1)-[]]]-[[p('$VAR'('X')'| '{'$VAR'('X')#>7r12})]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/rat.pl: -------------------------------------------------------------------------------- 1 | % Rational number constraint 2 | 3 | p(X) :- 4 | X #> 1/3 + 1/4. 5 | 6 | ?- p(X). 7 | -------------------------------------------------------------------------------- /test/all_programs/sasp/abdbirds.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[(not flies(tweety))-[goal_origin(bird(tweety),5)-[],goal_origin(abduced(ab(tweety)),3)-[]]],test_scasp:query-[(not flies(tweety))-[goal_origin(bird(tweety),5)-[],goal_origin(ab(tweety),7)-[goal_origin(abduced(penguin(tweety)),2)-[]]]],test_scasp:query-[(not flies(tweety))-[goal_origin(bird(tweety),5)-[],goal_origin(ab(tweety),8)-[goal_origin(abduced(wounded_bird(tweety)),1)-[]]]]]-[[ab(tweety),bird(tweety),not flies(tweety)],[ab(tweety),bird(tweety),not flies(tweety),penguin(tweety)],[ab(tweety),bird(tweety),not flies(tweety),wounded_bird(tweety)]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/sasp/abdbirds.pl: -------------------------------------------------------------------------------- 1 | % Birds with abducibles. If we observe that a bird is abnormal, we can use our 2 | % abducibles to speculate why. 3 | 4 | #abducible wounded_bird(X). 5 | #abducible penguin(X). 6 | #abducible ab(X). 7 | 8 | % Sam, Tweety and John are birds. 9 | bird(sam). 10 | bird(tweety). 11 | bird(john). 12 | 13 | % penguins and wounded birds are abnormal 14 | ab(X) :- penguin(X). 15 | ab(X) :- wounded_bird(X). 16 | 17 | % birds that are not abnormal can fly 18 | flies(X) :- bird(X), not ab(X). 19 | 20 | ?- not flies(tweety). 21 | -------------------------------------------------------------------------------- /test/all_programs/sasp/gpa.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[goal_origin(interview(john),4)-[(not eligible(john))-[(not highGPA(john))-[],(not special(john))-[]],(not-eligible(john))-[(not-special(john))-[]]],o_nmr_check-[(not o_chk_1)-[(not-eligible('$VAR'('A')))-[(not-special('$VAR'('A')))-[]]],(not o_chk_2)-[(not-special('$VAR'('_')))-[]],(not o_chk_3)-[(not-highGPA('$VAR'('B')'| '{'$VAR'('B')∉[john]}))-[],proved(not highGPA(john))-[]]]]]-[[not-eligible('$VAR'('A')),not eligible(john),not-eligible(john),not-highGPA('$VAR'('B')'| '{'$VAR'('B')∉[john]}),-highGPA(john),interview(john)]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/sasp/gpa.pl: -------------------------------------------------------------------------------- 1 | % From Baral Book pg 81 2 | eligible(X) :- highGPA(X). 3 | eligible(X) :- special(X), fairGPA(X). 4 | -eligible(X) :- -special(X), -highGPA(X). 5 | interview(X) :- not eligible(X), not -eligible(X). 6 | fairGPA(john). 7 | -highGPA(john). 8 | ?- interview(john). 9 | -------------------------------------------------------------------------------- /test/all_programs/sasp/hamcycle.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | 6 | % fact for each edge edge(U, V). 7 | edge(0, 1). 8 | edge(1, 2). 9 | edge(2, 0). 10 | 11 | reachable(V) :- chosen(U, V), reachable(U). 12 | reachable(0) :- chosen(V, 0). 13 | 14 | % Every vertex must be reachable. 15 | :- vertex(U), not reachable(U). 16 | 17 | % Choose exactly one edge from each vertex. 18 | other(U, V) :- 19 | vertex(U), vertex(V), vertex(W), 20 | edge(U, W), V \= W, chosen(U, W). 21 | chosen(U, V) :- 22 | edge(U, V), not other(U, V). 23 | 24 | % You cannot choose two edges to the same vertex 25 | :- chosen(U, W), chosen(V, W), U \= V. 26 | ?- chosen(1,2). 27 | -------------------------------------------------------------------------------- /test/all_programs/sasp/hamcycle2.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | 6 | % fact for each edge edge(U, V). 7 | edge(0, 1). 8 | edge(1, 2). 9 | edge(2, 0). 10 | 11 | reachable(V) :- chosen(U, V), reachable(U). 12 | reachable(0) :- chosen(V, 0). 13 | 14 | % Every vertex must be reachable. 15 | :- vertex(U), not reachable(U). 16 | 17 | % Choose exactly one edge from each vertex. 18 | other(U, V) :- 19 | vertex(U), vertex(V), vertex(W), 20 | edge(U, W), V \= W, chosen(U, W). 21 | chosen(U, V) :- 22 | edge(U, V), not other(U, V). 23 | 24 | % You cannot choose two edges to the same vertex 25 | :- chosen(U, W), chosen(V, W), U \= V. 26 | ?- chosen(1,2). 27 | -------------------------------------------------------------------------------- /test/all_programs/sasp/hamcycle_two.pl: -------------------------------------------------------------------------------- 1 | % fact for each vertex(N). 2 | vertex(0). 3 | vertex(1). 4 | vertex(2). 5 | vertex(3). 6 | 7 | % fact for each edge edge(U, V). 8 | edge(0, 1). 9 | edge(1, 2). 10 | edge(2, 3). 11 | edge(3, 0). 12 | 13 | edge(2, 0). 14 | edge(0, 3). 15 | edge(3, 1). 16 | 17 | reachable(V) :- chosen(U, V), reachable(U). 18 | reachable(0) :- chosen(V, 0). 19 | 20 | % Every vertex must be reachable. 21 | :- vertex(U), not reachable(U). 22 | 23 | % Choose exactly one edge from each vertex. 24 | other(U, V) :- 25 | vertex(U), vertex(V), vertex(W), 26 | edge(U, W), V \= W, chosen(U, W). 27 | chosen(U, V) :- 28 | edge(U, V), not other(U, V). 29 | 30 | % You cannot choose two edges to the same vertex 31 | :- chosen(U, W), chosen(V, W), U \= V. 32 | ?- chosen(1,2). 33 | -------------------------------------------------------------------------------- /test/all_programs/sasp/hanoi_7.pl: -------------------------------------------------------------------------------- 1 | % Tower of Hanoi, 7 pegs 2 | 3 | % Move N disks in T moves. 4 | hanoi(N, T) :- 5 | moven(N, 0, T, 1, 2, 3). 6 | 7 | % Move N disks from peg A to peg B using peg C. Assign move numbers. 8 | moven(N, Ti, To, A, B, C) :- 9 | N > 1, 10 | N1 is N - 1, 11 | moven(N1, Ti, T2, A, C, B), 12 | T3 is T2 + 1, 13 | move(T3, A, B), 14 | moven(N1, T3, To, C, B, A). 15 | moven(1, Ti, To, A, B, _) :- 16 | To is Ti + 1, 17 | move(To, A, B). 18 | 19 | % move T: move disk from P1 to P2. 20 | % any move may or may not be selected. 21 | move(T, P1, P2) :- 22 | not negmove(T, P1, P2). 23 | 24 | negmove(T, P1, P2) :- 25 | not move(T, P1, P2). 26 | 27 | ?- hanoi(7, T). 28 | -------------------------------------------------------------------------------- /test/all_programs/sasp/left-rec-succ_BAD.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[goal_origin(r(a,b),2)-[goal_origin(p(a,b),4)-[]]]]-[[p(a,b),r(a,b)]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/sasp/left-rec-succ_BAD.pl: -------------------------------------------------------------------------------- 1 | % Problematic left-recursion example (requires tabling) 2 | 3 | r(X, Y) :- r(X, Z), p(Z, Y). 4 | r(X, Y) :- p(X, Y). 5 | % r(a,d) works if goals reversed. Likely r(X, Z) will never succeed with Z = c 6 | r(X, Y) :- r(X, Z), q(Z, Y). 7 | 8 | p(a, b). 9 | p(b, c). 10 | q(c, d). 11 | 12 | ?- r(a,Y). 13 | -------------------------------------------------------------------------------- /test/all_programs/sasp/lion.pl: -------------------------------------------------------------------------------- 1 | % Animals 2 | 3 | animal(lion). 4 | animal(snake). 5 | animal(monkey). 6 | animal(rat). 7 | 8 | live(monkey, forest). 9 | live(snake, zoo). 10 | live(rat, apartment). 11 | 12 | live(X, forest) :- 13 | animal(X), 14 | not ab(live_animal(X)), 15 | not -live(X, forest). 16 | 17 | -live(X, Z) :- 18 | live(X, Y), 19 | Y \= Z. 20 | 21 | % ab(_) :- false. 22 | 23 | ?- live(lion, X). 24 | -------------------------------------------------------------------------------- /test/all_programs/sasp/loop_pos.pass: -------------------------------------------------------------------------------- 1 | []-[]. 2 | -------------------------------------------------------------------------------- /test/all_programs/sasp/loop_pos.pl: -------------------------------------------------------------------------------- 1 | % Possitive success loop (no models) 2 | 3 | p(X) :- p(Y). 4 | ?- p(X). 5 | -------------------------------------------------------------------------------- /test/all_programs/sasp/loop_succ_pos.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[goal_origin(p(0),2)-[]]]-[[p(0)]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/sasp/loop_succ_pos.pl: -------------------------------------------------------------------------------- 1 | % Possitive success loop (with model) 2 | 3 | p(X) :- p(Y). 4 | p(0). 5 | ?- p(X). 6 | -------------------------------------------------------------------------------- /test/all_programs/sasp/loopvar.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[goal_origin(p(3),1)-[(not q(3))-[chs(p(3))-[]]],goal_origin(r('$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}),3)-[goal_origin(q('$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}),2)-[(not p('$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}))-[chs(q('$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}))-[]]]]]]-[[not p('$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}),p(3),q('$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}),not q(3),r('$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]})]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/sasp/loopvar.pl: -------------------------------------------------------------------------------- 1 | % Even loop through negation with inequality (version I) 2 | 3 | p(X) :- not q(X). 4 | q(X) :- not p(X). 5 | r(X) :- X \= 3, X \= 4, q(X). 6 | ?- p(X), r(Y). 7 | -------------------------------------------------------------------------------- /test/all_programs/sasp/loopvar2.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[goal_origin(p(1,3),1)-[(not q(1,3))-[chs(p(1,3))-[]]],goal_origin(r('$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}),3)-[goal_origin(q(1,'$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}),2)-[(not p(1,'$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}))-[chs(q(1,'$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}))-[]]]]]]-[[r('$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}),not p(1,'$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}),p(1,3),q(1,'$VAR'('Y')'| '{'$VAR'('Y')∉[3,4]}),not q(1,3)]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/sasp/loopvar2.pl: -------------------------------------------------------------------------------- 1 | % Even loop through negation with inequality (version II) 2 | 3 | p(1,X) :- not q(1,X). 4 | q(1,X) :- not p(1,X). 5 | r(X) :- X \= 3, X \= 4, q(1,X). 6 | ?- p(1,X), r(Y). 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/all_programs/sasp/natnum.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[goal_origin(sumlist([s(s(0)),s(s(s(0)))],[s(s(s(0))),s(s(s(0)))],[s(s(s(s(s(0))))),s(s(s(s(s(s(0))))))]),6)-[goal_origin(sum(s(s(0)),s(s(s(0))),s(s(s(s(s(0)))))),5)-[goal_origin(sum(s(0),s(s(s(0))),s(s(s(s(0))))),3)-[]],goal_origin(sumlist([s(s(s(0)))],[s(s(s(0)))],[s(s(s(s(s(s(0))))))]),6)-[goal_origin(sum(s(s(s(0))),s(s(s(0))),s(s(s(s(s(s(0))))))),5)-[goal_origin(sum(s(s(0)),s(s(s(0))),s(s(s(s(s(0)))))),5)-[goal_origin(sum(s(0),s(s(s(0))),s(s(s(s(0))))),3)-[]]],goal_origin(sumlist([],[],[]),7)-[]]]]]-[[sum(s(0),s(s(s(0))),s(s(s(s(0))))),sum(s(s(0)),s(s(s(0))),s(s(s(s(s(0)))))),sum(s(s(s(0))),s(s(s(0))),s(s(s(s(s(s(0))))))),sumlist([],[],[]),sumlist([s(s(0)),s(s(s(0)))],[s(s(s(0))),s(s(s(0)))],[s(s(s(s(s(0))))),s(s(s(s(s(s(0))))))]),sumlist([s(s(s(0)))],[s(s(s(0)))],[s(s(s(s(s(s(0))))))])]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/sasp/natnum.pl: -------------------------------------------------------------------------------- 1 | % Natural numbers (piano representation) 2 | 3 | s(0). 4 | s(s(X)) :- 5 | s(X). 6 | 7 | sum(s(0), X, s(X)). 8 | sum(X, s(0), s(X)). 9 | sum(s(X), Y, s(Z)) :- 10 | X \= 0, 11 | sum(X, Y, Z). 12 | 13 | sumlist([X | T], [Y | T2], [Z | T3]) :- 14 | sum(X, Y, Z), 15 | sumlist(T, T2, T3). 16 | sumlist([], [], []). 17 | 18 | ?- sumlist([s(s(0)), s(s(s(0)))], [s(s(s(0))), s(s(s(0)))], X). 19 | -------------------------------------------------------------------------------- /test/all_programs/sasp/path_loop.pl: -------------------------------------------------------------------------------- 1 | % Path in graph 2 | 3 | %#table path/2. 4 | 5 | edge(a,b). 6 | edge(b,c). 7 | edge(a,d) :- not path(c,d). 8 | 9 | path(X,Y) :- 10 | edge(X,Y). 11 | path(X,Y) :- 12 | edge(X,Z), 13 | path(Z,Y). 14 | 15 | 16 | ?- path(a,Y). 17 | 18 | -------------------------------------------------------------------------------- /test/all_programs/simpleRPS-scasp.pl: -------------------------------------------------------------------------------- 1 | :-module('simpleRPS-scasp', []). 2 | source_lang(en). 3 | % s(CASP) Programming 4 | :- use_module(library(scasp)). 5 | % Uncomment to suppress warnings 6 | %:- style_check(-discontiguous). 7 | :- style_check(-singleton). 8 | :- set_prolog_flag(scasp_forall, prev). 9 | :- dynamic the_game_is_a_draw/0, inputs_and/3, gets/2, beats/2. 10 | #pred the_game_is_a_draw :: ' the game is a draw '. 11 | #pred inputs_and(B,C,D) :: ' @(B:person) inputs @(C:choice) and @(D:amount) '. 12 | #pred gets(B,C) :: ' @(B:person) gets @(C:amount) '. 13 | #pred beats(B,C) :: ' @(B:choice) beats @(C:choice) '. 14 | beats(scissors, paper). 15 | beats(paper, rock). 16 | beats(rock, scissors). 17 | gets(A, B) :- 18 | inputs_and(A, C, D), 19 | inputs_and(E, F, G), 20 | A\=E, 21 | beats(C, F), 22 | B is D+G. 23 | the_game_is_a_draw :- 24 | inputs_and(A, B, _), 25 | inputs_and(C, B, _), 26 | A\=C. 27 | gets(A, B) :- 28 | the_game_is_a_draw, 29 | inputs_and(A, _, B). 30 | /* Scenario mbj */ 31 | inputs_and(miguel, paper, 100). 32 | inputs_and(bob, paper, 1000). 33 | /* % */ 34 | /** */ 35 | ?- gets(Who,How_much). 36 | /* ?- ? the_game_is_a_draw. 37 | ?- ? jacinto\=bob. 38 | **/ 39 | 40 | -------------------------------------------------------------------------------- /test/all_programs/solve_findall.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[goal_origin(validate([1,2,3]),1)-[goal_origin(member(1,[1,2,3]),2)-[],goal_origin(member(2,[1,2,3]),3)-[goal_origin(member(2,[2,3]),2)-[]],goal_origin(member(3,[1,2,3]),3)-[goal_origin(member(3,[2,3]),3)-[goal_origin(member(3,[3]),2)-[]]]]]]-[[validate([1,2,3]),member(1,[1,2,3]),member(2,[1,2,3]),member(2,[2,3]),member(3,[1,2,3]),member(3,[2,3]),member(3,[3])]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/solve_findall.pl: -------------------------------------------------------------------------------- 1 | validate(L) :- 2 | findall(X, member(X,L), LL), 3 | LL = L. 4 | 5 | member(X1, [X2|_]) :- X1 #= X2. 6 | member(X, [_|R]) :- member(X, R). 7 | 8 | ?- validate([1,2,3]). 9 | -------------------------------------------------------------------------------- /test/all_programs/subset-scasp.pl: -------------------------------------------------------------------------------- 1 | :-module('subset-scasp', []). 2 | source_lang(en). 3 | % s(CASP) Programming 4 | :- use_module(library(scasp)). 5 | % Uncomment to suppress warnings 6 | %:- style_check(-discontiguous). 7 | :- style_check(-singleton). 8 | :- set_prolog_flag(scasp_forall, prev). 9 | :- dynamic is_a_subset_of/2, is_a_set/1, belongs_to/2. 10 | #pred is_a_subset_of(B,C) :: ' @(B:set) is a subset of @(C:set) '. 11 | #pred is_a_set(B) :: ' @(B:thing) is a set '. 12 | #pred belongs_to(B,C) :: ' @(B:thing) belongs to @(C:set) '. 13 | is_a_subset_of(A, B) :- 14 | is_a_set(A), 15 | is_a_set(B), 16 | forall(belongs_to(C, A), belongs_to(C, B)). 17 | forall(A,B) :- not(A, not(B)). 18 | /* Scenario one 19 | is_a_set(family_one). 20 | is_a_set(family_two). 21 | belongs_to('Bob', family_one). 22 | belongs_to('Alice', family_one). 23 | belongs_to('Alice', family_two). 24 | % */ 25 | /* Scenario two */ 26 | is_a_set(['Alice', 'Bob']). 27 | is_a_set(['Alice']). 28 | belongs_to(A, B) :- 29 | member(A, B). 30 | /* % */ 31 | /** */ 32 | ?- is_a_subset_of(SubSet,Set). 33 | /** ?- ? is_a_subset_of(_10660,_10662). 34 | **/ 35 | -------------------------------------------------------------------------------- /test/all_programs/vars.pass: -------------------------------------------------------------------------------- 1 | [test_scasp:query-[goal_origin(p(a,b,c,d,'$VAR'('E')'| '{'$VAR'('E')#>1,'$VAR'('E')#<5}),1)-[]]]-[[p(a,b,c,d,'$VAR'('E')'| '{'$VAR'('E')#>1,'$VAR'('E')#<5})]]. 2 | -------------------------------------------------------------------------------- /test/all_programs/vars.pl: -------------------------------------------------------------------------------- 1 | % Simple clp(r) constraint 2 | 3 | p(a,b,c,d,A) :- 4 | A #< 5, A #> 1. 5 | 6 | ?- p(A,B,C,D,E). 7 | -------------------------------------------------------------------------------- /test/bench.sh: -------------------------------------------------------------------------------- 1 | cat << EOF 2 | 3 | 4 |
    5 |
  • SWI-Prolog $(scasp --version 2>&1) 6 |
  • Ciao $(scasp-ciao --version) 7 |
8 | EOF 9 | 10 | swi() 11 | { /bin/time -f %U bash -c "scasp -n0 --unknown=fail $1 2>&1 > /dev/null" 2>&1 12 | } 13 | 14 | ciao() 15 | { /bin/time -f %U bash -c "scasp-ciao -n0 $1 2>&1 > /dev/null" 2>&1 16 | } 17 | 18 | cat << EOF 19 | 20 | 21 | EOF 22 | for f in $*; do 23 | echo "" 24 | done 25 | cat << EOF 26 |
ProgramSWICiao
$f$(swi $f)$(ciao $f)
27 | 28 | 29 | EOF 30 | -------------------------------------------------------------------------------- /test/le_programs/family-le-scasp.pl: -------------------------------------------------------------------------------- 1 | :-module('family-scasp+http://tests.com', []). 2 | source_lang(en). 3 | % s(CASP) Programming 4 | :- use_module(library(scasp)). 5 | % Uncomment to suppress warnings 6 | %:- style_check(-discontiguous). 7 | :- style_check(-singleton). 8 | :- set_prolog_flag(scasp_forall, prev). 9 | :- dynamic is_a_parent_of/2, is_a_grandparent_of/2. 10 | #pred is_a_parent_of(B,C) :: ' @(B:person) is a parent of @(C:person) '. 11 | #pred is_a_grandparent_of(B,C) :: ' @(B:person) is a grandparent of @(C:person) '. 12 | is_a_grandparent_of(A, B) :- 13 | is_a_parent_of(A, C), 14 | is_a_parent_of(C, B). 15 | /* Scenario one */ 16 | is_a_parent_of(john, mary). 17 | is_a_parent_of(mary, john). 18 | % */ 19 | /** */ 20 | ?- is_a_grandparent_of(_102530,_102532). 21 | /* **/ 22 | -------------------------------------------------------------------------------- /test/le_programs/impossibleancestor-scasp.pl: -------------------------------------------------------------------------------- 1 | :-module('impossibleancestor-scasp', []). 2 | source_lang(en). 3 | % s(CASP) Programming 4 | :- use_module(library(scasp)). 5 | % Uncomment to suppress warnings 6 | %:- style_check(-discontiguous). 7 | :- style_check(-singleton). 8 | :- set_prolog_flag(scasp_forall, prev). 9 | :- dynamic is_an_ancestor_of/2, is_a_parent_of/2, is_a_grandparent_of/2, is_impossible/1. 10 | #pred is_an_ancestor_of(B,C) :: ' @(B:person) is an ancestor of @(C:person) '. 11 | #pred is_a_parent_of(B,C) :: ' @(B:person) is a parent of @(C:person) '. 12 | #pred is_a_grandparent_of(B,C) :: ' @(B:person) is a grandparent of @(C:person) '. 13 | #pred is_impossible(B) :: ' @(B:person) is impossible '. 14 | is_a_grandparent_of(A, B) :- 15 | is_a_parent_of(A, C), 16 | is_a_parent_of(C, B). 17 | is_an_ancestor_of(A, B) :- 18 | is_a_parent_of(A, B). 19 | is_an_ancestor_of(A, B) :- 20 | is_a_parent_of(A, C), 21 | is_an_ancestor_of(C, B). 22 | /* Scenario one 23 | is_a_parent_of(john, mary). 24 | is_a_parent_of(mary, alice). 25 | % */ 26 | /* Scenario two */ 27 | is_a_parent_of(john, mary). 28 | is_a_parent_of(mary, john). 29 | is_impossible(A) :- 30 | is_an_ancestor_of(A, A). 31 | /* % */ 32 | /** 33 | ?- ? is_a_grandparent_of(_170772,_170774). 34 | ?- ? is_an_ancestor_of(_170760,_170762). */ 35 | ?- is_impossible(_170750). 36 | /* **/ 37 | -------------------------------------------------------------------------------- /test/le_programs/simpleRPS-scasp.pl: -------------------------------------------------------------------------------- 1 | :-module('simpleRPS-scasp', []). 2 | source_lang(en). 3 | % s(CASP) Programming 4 | :- use_module(library(scasp)). 5 | % Uncomment to suppress warnings 6 | %:- style_check(-discontiguous). 7 | :- style_check(-singleton). 8 | :- set_prolog_flag(scasp_forall, prev). 9 | :- dynamic the_game_is_a_draw/0, inputs_and/3, gets/2, beats/2. 10 | #pred the_game_is_a_draw :: ' the game is a draw '. 11 | #pred inputs_and(B,C,D) :: ' @(B:person) inputs @(C:choice) and @(D:amount) '. 12 | #pred gets(B,C) :: ' @(B:person) gets @(C:amount) '. 13 | #pred beats(B,C) :: ' @(B:choice) beats @(C:choice) '. 14 | beats(scissors, paper). 15 | beats(paper, rock). 16 | beats(rock, scissors). 17 | gets(A, B) :- 18 | inputs_and(A, C, D), 19 | inputs_and(E, F, G), 20 | A\=E, 21 | beats(C, F), 22 | B is D+G. 23 | the_game_is_a_draw :- 24 | inputs_and(A, B, _), 25 | inputs_and(C, B, _), 26 | A\=C. 27 | gets(A, B) :- 28 | the_game_is_a_draw, 29 | inputs_and(A, _, B). 30 | /* Scenario mbj */ 31 | inputs_and(miguel, paper, 100). 32 | inputs_and(bob, paper, 1000). 33 | /* % */ 34 | /** */ 35 | ?- gets(Who,How_much). 36 | /* ?- ? the_game_is_a_draw. 37 | ?- ? jacinto\=bob. 38 | **/ 39 | 40 | -------------------------------------------------------------------------------- /test/le_programs/subset-scasp.pl: -------------------------------------------------------------------------------- 1 | :-module('subset-scasp', []). 2 | source_lang(en). 3 | % s(CASP) Programming 4 | :- use_module(library(scasp)). 5 | % Uncomment to suppress warnings 6 | %:- style_check(-discontiguous). 7 | :- style_check(-singleton). 8 | :- set_prolog_flag(scasp_forall, prev). 9 | :- dynamic is_a_subset_of/2, is_a_set/1, belongs_to/2. 10 | #pred is_a_subset_of(B,C) :: ' @(B:set) is a subset of @(C:set) '. 11 | #pred is_a_set(B) :: ' @(B:thing) is a set '. 12 | #pred belongs_to(B,C) :: ' @(B:thing) belongs to @(C:set) '. 13 | is_a_subset_of(A, B) :- 14 | is_a_set(A), 15 | is_a_set(B), 16 | forall(belongs_to(C, A), belongs_to(C, B)). 17 | forall(A,B) :- not(A, not(B)). 18 | /* Scenario one 19 | is_a_set(family_one). 20 | is_a_set(family_two). 21 | belongs_to('Bob', family_one). 22 | belongs_to('Alice', family_one). 23 | belongs_to('Alice', family_two). 24 | % */ 25 | /* Scenario two */ 26 | is_a_set(['Alice', 'Bob']). 27 | is_a_set(['Alice']). 28 | belongs_to(A, B) :- 29 | member(A, B). 30 | /* % */ 31 | /** */ 32 | ?- is_a_subset_of(SubSet,Set). 33 | /** ?- ? is_a_subset_of(_10660,_10662). 34 | **/ 35 | -------------------------------------------------------------------------------- /test/min_programs/bec_loan.pl: -------------------------------------------------------------------------------- 1 | % Basic Event Calculus 2 | 3 | %% Include the BASIC EVENT CALCULUS THEORY 4 | #include '../all_programs/bec_theory.incl'. 5 | 6 | is_1_day_after(B, A) :- B #= A + 1. 7 | 8 | %% based on the loan agreement example in Logical English 9 | initiates(ends(A), it_is(B), _) :- 10 | is_1_day_after(B, A). 11 | initiates(ends(1), is_liable_to_litigation(the_lender), A) :- 12 | holdsAt(requested_on(the_borrower, 1000, 2), A), 13 | not holdsAt(advanced_on(the_lender, 1000, _), 1). 14 | initiates(ends(2), is_terminated(the_agreement), _) :- 15 | not holdsAt(requested_on(the_borrower, 1000, 2), 2). 16 | initiates(requests(the_borrower, A), requested_on(the_borrower, A, B), B). 17 | initiates(advances(the_lender, A), advanced_on(the_lender, A, B), B). 18 | initiates(ends(_), is_potentially_defaulted(B), A) :- 19 | B=pays_to(C, D, E), 20 | is_due_on_from_to(D, A, C, E), 21 | holdsAt(it_is(F), F), 22 | not holdsAt(paid_to_on(C, D, E, _), F). 23 | initiates(pays_to(A, B, C), paid_to_on(A, B, C, D), D). 24 | 25 | is_due_on_from_to(550, 4, the_borrower, the_lender). 26 | is_due_on_from_to(525, 5, the_borrower, the_lender). 27 | 28 | %% Actions 29 | 30 | happens(ends(1), 1). 31 | happens(ends(2), 2). 32 | happens(requests(the_borrower, 1000), 2). 33 | 34 | ?- holdsAt(F, T). 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/min_programs/clpq_gt_gte_lt_lte_equal.pl: -------------------------------------------------------------------------------- 1 | valid(X) :- in_target(X). 2 | -valid(X) :- not valid(X). 3 | 4 | in_target(X) :- X#>=0, X#=<10. 5 | in_target(X) :- X#>4, X#<10. 6 | in_target(X) :- X#=5. 7 | 8 | member(X, [X|_]). 9 | member(X, [_|R]) :- member(X, R). 10 | 11 | ?- -valid(X). -------------------------------------------------------------------------------- /test/min_programs/clpq_intercept.pl: -------------------------------------------------------------------------------- 1 | -mutually_exclusive(S1, S2) :- 2 | segment(S1), segment(S2), S1 =\= S2, 3 | intercept(S1, S2). 4 | 5 | mutually_exclusive(S1, S2) :- 6 | not -mutually_exclusive(S1, S2). 7 | 8 | intercept([X1, X2], [Y1, Y2]) :- 9 | Y1 #=< X1, X1 #=< Y2. 10 | intercept([X1, X2], [Y1, Y2]) :- 11 | Y1 #=< X2, X2 #=< Y2. 12 | 13 | segment([1,2]). 14 | segment([2,3]). 15 | segment([3,4]). 16 | 17 | ?- mutually_exclusive(S1, S2). -------------------------------------------------------------------------------- /test/min_programs/ex01-dual.pl: -------------------------------------------------------------------------------- 1 | p(X):- q(X , Z) , not r(X). 2 | p(Z):- not q(X , Z) , r(X). 3 | 4 | q(X , a):- X #> 5. 5 | r(X):- X #< 1. 6 | 7 | ?- p(X). -------------------------------------------------------------------------------- /test/min_programs/ex02-member.pl: -------------------------------------------------------------------------------- 1 | member(X, [X |Xs]). 2 | member(X, [_ |Xs]):- member(X, Xs). 3 | 4 | list([1,2,3]). 5 | 6 | not_in_list(A) :- 7 | list(A), 8 | not member(B, A). 9 | 10 | 11 | ?- not_in_list(A). -------------------------------------------------------------------------------- /test/min_programs/forall_arity.pl: -------------------------------------------------------------------------------- 1 | % Dual rules for q/2 and q/1 with one body variable used to clash. 2 | 3 | p(X) :- 4 | q(X,_). 5 | 6 | q(ha) :- 7 | q(a,X), 8 | X > 1. 9 | 10 | q(a,2). 11 | 12 | ?- not p(a). 13 | -------------------------------------------------------------------------------- /test/min_programs/hamiltonian_scasp.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | reachable(V) :- cycle(U, V), reachable(U). 4 | reachable(a) :- cycle(V, a). 5 | 6 | % Every node must be reachable. 7 | :- node(U), not reachable(U). 8 | 9 | % Choose exactly one edge from each node. 10 | other(U, V) :- 11 | node(U), node(V), node(W), 12 | edge(U, W), V \= W, cycle(U, W). 13 | cycle(U, V) :- 14 | edge(U, V), not other(U, V). 15 | 16 | % You cannot choose two edges to the same node 17 | :- cycle(U, W), cycle(V, W), U \= V. 18 | 19 | 20 | travel_path(Start, Length, Cycle) :- path(Start, Start, Start, Length, [], Cycle). 21 | 22 | path(_, X, Y, D, Prev, [X,[D],Y|Prev]) :- 23 | cycle_dist(X, Y, D). 24 | path(Start, X, Y, D, Prev, Cycle) :- 25 | D #= D1 + D2, 26 | cycle_dist(Z, Y, D1), Z \= Start, 27 | path(Start, X, Z, D2, [([D1],Y)|Prev], Cycle). 28 | 29 | edge(X,Y) :- distance(X,Y,D). 30 | cycle_dist(U,V,D) :- 31 | cycle(U,V), distance(U,V,D). 32 | 33 | node(a). 34 | node(b). 35 | node(c). 36 | node(d). 37 | 38 | distance(b, c, 31/10). 39 | distance(c, d, L) :- 40 | L #> 8, L #< 21/2. 41 | distance(d, a, 1). 42 | distance(a, b, 1). 43 | distance(c, a, 1). 44 | distance(a, d, 1). 45 | distance(d, b, 1). 46 | 47 | 48 | ?- travel_path(b, D, Cycle). 49 | 50 | #show travel_path/3, cycle_dist/3. 51 | -------------------------------------------------------------------------------- /test/min_programs/lion.pl: -------------------------------------------------------------------------------- 1 | % Animals 2 | 3 | animal(lion). 4 | animal(snake). 5 | animal(monkey). 6 | animal(rat). 7 | 8 | live(monkey, forest). 9 | live(snake, zoo). 10 | live(rat, apartment). 11 | 12 | live(X, forest) :- 13 | animal(X), 14 | not ab(live_animal(X)), 15 | not -live(X, forest). 16 | 17 | -live(X, Z) :- 18 | live(X, Y), 19 | Y \= Z. 20 | 21 | % ab(_) :- false. 22 | 23 | ?- live(lion, X). 24 | -------------------------------------------------------------------------------- /test/min_programs/nixon-diamond.pl: -------------------------------------------------------------------------------- 1 | %:- set_prolog_flag(scasp_assume, true). 2 | 3 | pacifist(X) :- not -pacifist(X), quaker(X). 4 | -pacifist(X) :- not pacifist(X), republican(X). 5 | -quaker(X) :- not quaker(X). 6 | -republican(X) :- not republican(X). 7 | quaker(alan). 8 | quaker(nixon). 9 | republican(bill). 10 | pacifist(bill). 11 | republican(nixon). 12 | 13 | :- republican(X), -republican(X). 14 | 15 | 16 | ?- pacifist(X). -------------------------------------------------------------------------------- /test/min_programs/solve_call.pl: -------------------------------------------------------------------------------- 1 | process(G) :- 2 | call(G). 3 | process(G) :- 4 | exception(G), 5 | not(call(G)). 6 | 7 | exception(test). 8 | 9 | ?- process(test). 10 | -------------------------------------------------------------------------------- /test/min_programs/solve_findall_superset.pl: -------------------------------------------------------------------------------- 1 | % subset(S1, S2) :- 2 | % not -subset(S1, S2). 3 | 4 | % -subset(S1, S2) :- 5 | % -member(X, S1), member(X,S2). 6 | 7 | % -member(X, S) :- not member(X, S). 8 | 9 | % member(X1, [X2|_]) :- X1 #= X2. 10 | % member(X, [_|R]) :- member(X, R). 11 | 12 | superset(Y, L) :- 13 | findall(X, subset(X, Y), L). % didn't work 14 | 15 | subset([], _). 16 | subset([X|R], S2) :- 17 | minus(X, S2, [], NS2), 18 | subset(R, NS2). 19 | 20 | % minus(X, S1, [], NS1) 21 | minus(X, [X|R], P, F) :- 22 | append(P, R, F). 23 | minus(X1, [X2|R], P, F) :- 24 | X1 #<> X2, 25 | minus(X1, R, [X2|P], F). 26 | 27 | append([], X, X). 28 | append([U|X], Y, [U|Z]) :- append(X,Y,Z). 29 | 30 | ?- subset(X, [1,2,3]). 31 | 32 | %?- superset([1,2], L). -------------------------------------------------------------------------------- /test/min_programs/solve_forall.pl: -------------------------------------------------------------------------------- 1 | subset(S1, S2) :- 2 | forall(X, contained(X, S1, S2)). 3 | 4 | contained(X, S1, S2) :- 5 | member(X, S1), member(X, S2). 6 | contained(X, S1, S2) :- 7 | member(X, S2), not member(X, S1). 8 | 9 | member(X1, [X2|_]) :- X1 #= X2. 10 | member(X, [_|R]) :- member(X, R). 11 | 12 | ?- subset([1], [1,3]). -------------------------------------------------------------------------------- /test/min_programs/solve_not_is.pl: -------------------------------------------------------------------------------- 1 | invalid_value(X) :- not valid_value(X). 2 | 3 | valid_value(V) :- 4 | coord(X), coord(Y), 5 | is(V, X+Y). 6 | 7 | coord(1). 8 | coord(2). 9 | coord(3). 10 | 11 | ?- invalid_value(X). -------------------------------------------------------------------------------- /test/min_programs/solve_not_true.pl: -------------------------------------------------------------------------------- 1 | valid(X) :- 2 | X#<>1, 3 | not(true). 4 | 5 | ?- valid(X). -------------------------------------------------------------------------------- /test/min_programs/stream_reasoning.pl: -------------------------------------------------------------------------------- 1 | valid_stream(P,Data) :- 2 | stream(P,Data), 3 | not cancelled(P, Data). 4 | cancelled(P, Data) :- 5 | higher_prio(P1, P), 6 | stream(P1, Data1), 7 | incompt(Data, Data1). 8 | higher_prio(PHi, PLo) :- 9 | PHi #> PLo. 10 | incompt(p(X), q(X)). 11 | incompt(q(X), p(X)). 12 | 13 | stream(1,p(X)). 14 | stream(2,q(a)). 15 | stream(2,q(b)). 16 | stream(3,p(a)). 17 | 18 | ?- valid_stream(P,Data). 19 | 20 | -------------------------------------------------------------------------------- /test/min_programs/yale_shooting_casp_v2.pl: -------------------------------------------------------------------------------- 1 | 2 | duration(load,D) :- 3 | D #< 23/3, D #> 10/3. 4 | duration(shoot,5). 5 | duration(wait,36). 6 | 7 | holds(0,State,[]) :- 8 | init(State). 9 | holds(Time1, FinalState, [Action|As]) :- 10 | Time1 #> 0, 11 | Time1 #= Time + Duration, 12 | duration(Action, Duration), 13 | not prohibited(Action, Time1), 14 | transition(Action, PrevState, FinalState), 15 | holds(Time, PrevState, As). 16 | 17 | init(state(alive, unloaded, 0)). 18 | 19 | transition(load, state(alive, _, _), state(alive, loaded,FinalArmed)) :- 20 | FinalArmed = 0. 21 | transition(wait, state(alive, Gun, PrevArmed), state(alive, Gun, FinalArmed)) :- 22 | duration(wait, D), FinalArmed #= PrevArmed + D. 23 | transition(shoot, state(alive, loaded, PrevArmed), state(dead, unloaded, 0)) :- 24 | not spoiled(PrevArmed). 25 | transition(shoot, state(alive, loaded, PrevArmed), state(alive, unloaded, 0)) :- 26 | spoiled(PrevArmed). 27 | 28 | spoiled(Armed) :- Armed #> 35. 29 | prohibited(shoot, T) :- T #< 35. 30 | 31 | ?- T #< 40, holds(T, state(dead,_,_), List). 32 | 33 | #show holds/3. 34 | -------------------------------------------------------------------------------- /test/small_programs/ex01-dual.pl: -------------------------------------------------------------------------------- 1 | p(X):- q(X , Z) , not r(X). 2 | p(Z):- not q(X , Z) , r(X). 3 | 4 | q(X , a):- X #> 5. 5 | r(X):- X #< 1. 6 | 7 | ?- p(X). -------------------------------------------------------------------------------- /test/small_programs/solve_not_true.pl: -------------------------------------------------------------------------------- 1 | valid(X) :- 2 | X#<>1, 3 | not(true). 4 | 5 | ?- valid(X). -------------------------------------------------------------------------------- /test/test_clp_disequality.pl: -------------------------------------------------------------------------------- 1 | :- module(clp_disequality_test, 2 | [ run_test/0 3 | ]). 4 | 5 | :- use_module(clp_disequality). 6 | 7 | run_test :- 8 | template(_A = 5), 9 | template(_B .\=. 4), 10 | template((C .\=. 5, C = 5)), 11 | template(p(1,2) .\=. p(_D1, _D2)), 12 | template((E .\=. 25, E .\=. 3, [E,E,E] = [E,E,4])), 13 | template((F .\=. 4, F .\=. 5)), 14 | template(( G .\=. 6, G .\=. 5, G = 4)), 15 | template((H .\=. 6, H .\=. 5, p(H,3) .\=. p(4,H))), 16 | template((I1 .\=.3, I2 .\=. 5, I1 .\=. I2)), 17 | template((s(_K) = s(5))). 18 | 19 | template(Goal) :- 20 | format('\n--------------------------\n'), 21 | copy_term(Goal, Copy), 22 | format('TEST ~w',Copy),nl, 23 | term_variables(Goal, Var), 24 | term_variables(Copy, CVar), 25 | ( intercept(call(Goal),_,fail), 26 | format('Result: '), 27 | print_list(-(Var,CVar)),nl, 28 | fail 29 | ; \+ call(Goal), 30 | format('Result: \n\tfails\n') 31 | ). 32 | template(_). 33 | 34 | 35 | print_list(-([],[])). 36 | print_list(-([X|Xs],[Cx|Cxs])) :- 37 | \+ \+ ( numbervars(Cx+X, 0, _, [attvar(skip)]), 38 | format('\n\t~p is ~p', [Cx, X]) 39 | ), 40 | print_list(-(Xs,Cxs)). 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/test_just.pl: -------------------------------------------------------------------------------- 1 | :- module(test_just, 2 | [ test_just/0 3 | ]). 4 | :- use_module('../prolog/scasp'). 5 | :- use_module('../prolog/scasp/human'). 6 | :- use_module(library(plunit)). 7 | :- use_module(library(debug)). 8 | 9 | :- meta_predicate 10 | human(0, +). 11 | 12 | test_just :- 13 | run_tests([ scasp_just_1 14 | ]). 15 | 16 | :- begin_tests(scasp_just_1). 17 | :- dynamic q/0. 18 | 19 | p. 20 | pq :- not q. 21 | p(X) :- X #> 3. 22 | 23 | test(p) :- 24 | human(p, "p holds"). 25 | test(p1) :- 26 | human(p(_X), "p holds for any number greater than 3"). 27 | test(np1) :- 28 | human(not p(_X), "there is no evidence that p holds for \c 29 | any number less than or equal to 3"). 30 | test(pq) :- 31 | human(pq, "pq holds, because there is no evidence that q holds"). 32 | 33 | :- end_tests(scasp_just_1). 34 | 35 | 36 | /******************************* 37 | * HARNASS * 38 | *******************************/ 39 | 40 | human(G, Expected) :- 41 | once(scasp(G, [tree(Tree)])), 42 | with_output_to(string(String0), 43 | human_justification_tree(Tree, [])), 44 | split_string(String0, "\n", " \n\u220e", Strings), 45 | atomics_to_string(Strings, " ", String), 46 | assertion(Expected == String). 47 | -------------------------------------------------------------------------------- /test/test_prolog.pl: -------------------------------------------------------------------------------- 1 | :- use_module('../prolog/scasp/prolog'). 2 | :- use_module('../prolog/scasp/stack'). 3 | 4 | :- meta_predicate 5 | proof(0). 6 | 7 | proof(Goal) :- 8 | scasp_prolog(Goal, Tree), 9 | print_justification_tree(Tree, []). 10 | --------------------------------------------------------------------------------