1. Trang chủ
  2. » Thể loại khác

Logic as a tool a guide to formal logical reasoning ( PDFDrive ) 283

1 0 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1
Dung lượng 62,71 KB

Nội dung

Applications: Mathematical Proofs and Automated Reasoning 259 (c) The substitution [Charles/X, William/Y] unifies the head of (R1) with the body of (Q32), thus resolving these rules to produce the new query (Q33): :- parent(Charles, William) (d) The fact (F2) is identical to the body of (Q33), thus resolving these rules to produce the empty query/clause (Q34): :- The derivation of the empty clause in P Q3 means that the program P has answered the original query (Q3) with “Yes.” Let us now run P on the following query: (Q4): :- ancestor(Elisabeth, Y) (a) The substitution [Elisabeth/X] unifies the head of (R1) with the body of (Q4), thus resolving these two rules to produce the new query (Q41): :- parent(Elisabeth, Y) (b) The substitution [Charles/Y] unifies the fact (F1) with the body of (Q41), thus resolving these rules to produce the empty query (Q42): :- This completes the derivation, yielding a solution [Charles/Y] If we are interested in only one solution, we can stop here However, if we want to look for other solutions we can re-run the program by instructing it to look for another solution This can be done by using a special feature of Prolog that cuts the execution branch producing the previous solution and forces Prolog to look for a new solution (c) In this case, re-running the program will cause Prolog to look for another way to unify a rule with the body of (Q4) Such an alternative is provided by rule (R2) and the substitution [Elisabeth/X, Wiliam/Y] will, as before, unify the head of (R2) with the body of (Q4) This causes a further execution repeating the previous one, which will also succeed, producing another solution: [Wiliam/Y] (d) Repeating the re-running after disallowing the previous two solutions will likewise produce yet another solution: [George/Y] It is not difficult to see that no more solutions can be obtained As expected, the program computes consecutively three answers – Charles, William, George – to the query (Q4), which essentially asks “To whom is Elisabeth an ancestor?” How exactly does Prolog run? The derivation engine of Prolog is based on the earlier mentioned SLD-resolution strategy, enhanced with a special mechanism for controlled backtracking, which allows for a search of multiple solutions as above As for input resolution, SLD-resolution is not refutation-complete for first-order logic but it is complete for the Horn logic of Prolog programs However, because of the depth-first

Ngày đăng: 28/10/2022, 15:42