1:-module('turingcomplete-scasp', []). 2source_lang(en).
4:- use_module(library(scasp)). 7:- style_check(-singleton). 8:- set_prolog_flag(scasp_forall, prev). 9:- dynamic says_that_and_lead_to_and_after_performing/6, it_changes_from_to_and_from_to/5, is_left_after_and_is_left_after/4, moves_to_and_to/5, the_head_of_is_leaving/3, some_tm_goes_from_to/2. 10some_tm_goes_from_to(A, B) :-
11 it_changes_from_to_and_from_to(q0, [], C, A, D),
12 reverse(C, E),
13 append(E, D, B).
14it_changes_from_to_and_from_to(qf, A, A, B, B).
15it_changes_from_to_and_from_to(A, B, C, D, E) :-
16 the_head_of_is_leaving(D, F, G),
17 says_that_and_lead_to_and_after_performing(_,
18 A,
19 F,
20 H,
21 I,
22 J),
23 has_as_head_before(K, I, G),
24 moves_to_and_to(J, B, L, K, M),
25 it_changes_from_to_and_from_to(H, L, C, M, E).
26the_head_of_is_leaving([], b, []).
27the_head_of_is_leaving(A, B, C) :-
28 has_as_head_before(A, B, C).
29moves_to_and_to(left, A, B, C, D) :-
30 is_left_after_and_is_left_after(A, B, C, D).
31moves_to_and_to(stay, A, A, B, B).
32moves_to_and_to(right, A, B, C, D) :-
33 has_as_head_before(B, E, A),
34 has_as_head_before(C, E, D).
35is_left_after_and_is_left_after([], [], A, B) :-
36 has_as_head_before(B, b, A).
37is_left_after_and_is_left_after(A, B, C, D) :-
38 has_as_head_before(A, E, B),
39 has_as_head_before(D, E, C).
41says_that_and_lead_to_and_after_performing(rule1, q0, 1, q0, 1, right).
42says_that_and_lead_to_and_after_performing(rule2, q0, b, qf, 1, stay).
45?- some_tm_goes_from_to([1,1,1,b],FinalState).