Final Flashcards
Imperative programming languages are based on a:
paradigm but functional programming languages are based on:
statement-at-a-time
mathematical functions
What Greek letter is often used to denote Scheme ? Why?
Greek letter L(lambda)
Essentially a lambda is a block of code that can be passed as an argument to a function call
Define referential transparency.
the evaluation of a function always produces the same result given the same parameters
Who developed LISP and when?
late 50s by John McCarthy
What data types were parts of the original LISP?
atoms and lists
What does the abbreviation REPL stand for?
read-evaluate-print loop
Is Scheme statically or dynamically scoped?
statically scoped
If Scheme were a pure functional language, could it include PRINT? Why or why not?
No, because there is no state change, it will return the same expression
What is tail recursion?
No operation to perform after recursive function. Returns recursive call directly
Imperative languages vs functional languages
imperative languages:
based on the von Neumann architecture In an imperative language, operations are done and the results are stored in variables for later use
functional languages:
based on mathematical functions variables are not necessary, as is the case in mathematics
Logic languages are declarative and imperative languages are procedural. Explain the difference between declarative ( nonprocedural ) and procedural
declarative: A computer language that does not require writing traditional programming logic
procedural: the use of code in a step-wise procedure to develop applications
Imperative languages are based on: paradigmfunctional languages are based on:
logic languages are based on:
statement-at-a-time
mathematical functions
formal logic
Resolution:
an inference principle that allows inferred propositions to be computed from given propositions
Unification:
finding values for variables in propositions that allows matching process to succeed
Instantiation:
assigning temporary values to variables to allow unification to succeed
Backtracking:
Begin search where previous search left offCan take lots of time and space because may find all possible proofs to every subgoal
What are the forms of Horn clauses?
Headed: single atomic proposition on left side
Headless : empty left side (used to state facts)
Antecedent:
Consequent:
the first half of a hypothetical proposition, whenever the if-clause precedes the then-clause
the second half of a hypothetical propositionIn the standard form of such a proposition, it is the part that follows then
Another name for a query is a?
goal
The process of proving a goal is called:
matching, satisfying or resolution
forward chaining:
backward chaining:
Begin with facts and rules of database and attempt to find sequence that leads to goal. Works well with a large set of possibly correct answers
Begin with goal and attempt to find sequence that leads to set of facts in database. Works well with a small set of possibly correct answers
Prolog implementations use _________ chaining
backward
Explain the difference between a depth-first and a breadth-first search when discussing how multiple goals are satisfied.
Which approach does Prolog use?
Depth first: searchfind a complete proof for the first subgoal before working on others
Breadth-first search : work on all subgoals in parallel
Prolog uses depth-first search
Explain what is wrong with the Prolog statement K is K + 1
The problem is that unification is not assignment is K + 1 will always fail for integers
What is a list in Prolog?
simply a collection of terms
What is an anonymous variable?
the underscore character means an anonymous variable- it means we do not care what instantiation it might get from unification
What are the two ways a Prolog programmer can control the order of pattern matching during resolution
placement of rules in a database and by using the cut operator
Explain the closed-world assumption used by Prolog
The only knowledge is what is in the database
Explain the negation problem with Prolog
Negation in Prolog is implemented based on the use of cut. Actually , negation in Prolog is the so-called negation as failure , which means that to negate p one tries to prove p (just executing it), and if p is proved then its negation , not(p) , fails.
Language domains:
Scientific Business Education Artificial Intelligence Web
Language paradigms:
Imperative Functional Declarative Object oriented Procedural Logic Symbolic
Language implementation
Compiled
Interpreted
Hybrid