Prog Lang Exam 2 Flashcards
Logic Programming
A programming paradigm where logic is used to represent both programs and the process of computation.
Mathematical Logic
Basis for logic programming, involving the first-order predicate calculus, axioms, theorems, and logical interferences.
What are the two logic programming languages?
Prolag and Curry
Logical Statements
Etiher true or false; axioms are assumed true statements from which other true statements are derived.
Horn Clauses
A simplified form of first-order predicate calculus used in logic programming.
Resolution
A rule for combining Horn Clauses by eliminating matching terms.
Unification
Process of making staements identical by assigning values to variables, essential in deriving logical conclusions.
Core structures of Prolog, where rules and facts are expressed in a logical format.
Horn Clauses
Prolog’s Search Strategy
Prolog employs a depth-first search strategy to resolve goals, which can lead to infinite loops if not carefully managed.
Structure of Horn Clauses
a1 and a2 and a3 … and an –> b
b
Head of the clause.
a1, …, an
Body of the clause
Backtracking
Allows Prolog to search for multiple solutions, but care must be taken to avoid infinite loops.
Negation as Failure
A goal fails if it cannot be proven true, representing the closed-world assumption.
Problems with Logic Programming
Control issues, occur-check problems, and declarative nature.
The Curry Language
Combines the features of Haskell (functional programming) and Prolog (logic programming).
Curry Key Features
Nondeterminism, lazy evaluation, and combincation of functional and logic programming.
Nondeterminism
Allows multiple solutions to be explored without a predefined order.
Lazy Evaluation
Only computes values when needed, enhancing efficiency.
Prolog vs. Curry
Prolog focuses on logic programming with backtracking and unification, whereas Curry blends logic and functional programming with features like lazy evaluation and nondeterminism.
OOP languages aim to facilitate:
- Reusability of software components.
- Modification of behavior with minimal code changes.
- Independence of different components through abstraction, polymorphism, and encapsulation.
Polymorphism
Ability to extend the types of data operations can apply to, like method overloading and parameterized types.
Manual memory management
Developers must manually allocate and deallocate memory using new and delete.
Multiple Inheritanc
C++ supports multiple inheritance, which is not allowed in Java due to complexity (such as the diamond problem).