324-lecture5 - Principles of Programming Languages...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Principles of Programming Languages Principles of Programming Languages Lecture 5 Lecture 5 Wael Aboulsaadat Wael Aboulsaadat [email protected] [email protected] http://portal.utoronto.ca/ Prolog: backtracking example 2 Prolog: backtracking example 2 Prolog: backtracking example 3 Prolog: backtracking example 3 Prolog: backtracking example 3 Prolog: backtracking example 3 – cont’d cont’d Prolog: backtracking example 3 Prolog: backtracking example 3 – cont’d cont’d Prolog: top Prolog: top-down vs. bottom down vs. bottom-up reasoning up reasoning • Prolog uses top-down inference, although some other logic programming systems use bottom-up inference (e.g. Coral) • Each has its own advantages and disadvantages: – Bottom-up may generate many irrelevant facts – Top-down may explore many lines of reasoning that fail. op own and bottom p inference are logically • Top-down and bottom-up inference are logically equivalent – i.e. they both prove the same set of facts. • However, only top-down inference simulates program execution – i.e. execution is inherently top down, since it proceeds from the main procedure downwards, to subroutines, to sub-subroutines, etc... Prolog: unification operators Prolog: unification operators • = unify with operator: X = Y – Semantically: unifable test – Succeeds as long as X and Y can be unified – X may or may not be instantiated. Y may or may not be instantiated – As a side effect, X and Y become bound together (refer to the same object) – E.g....
View Full Document

{[ snackBarMessage ]}

Page1 / 18

324-lecture5 - Principles of Programming Languages...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online