Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
18 Cards in this Set
- Front
- Back
Logic programming
* Facts * Rules |
Facts = logical statements assumed to be true (axioms)
Rules = logical statements that derive new facts from existing facts that support the premise Solve a problem or compute a result by posing a query to the system. Goal: logical statement proven to be true |
|
Forward chaining
|
Start with the facts and work forward towards the query (the goal)
When a fact matches the antecedent of a rule, the rule fires, and the conclusion of the rule is added to the database of facts |
|
Backward chaining
|
Start with the query/goal/conclusion and work backwards saving any facts that support the goal
More appropriate in cases where a particular conclusion is to be proved When a conclusion matches the conclusion of a rule in a database, the antecedents of the rule are compared with facts in the database |
|
Forward chaining is ___-driven and backward chaining is ___-driven
|
Forward chaining = data-driven, best for automatic, "unconscious" processing (object recognition, routine decisions). May do lots of work irrelevant to the goal
Backward chaining = goal-driven, more appropriate for problem solving. Where are my keys? How do I get into a PhD program? Often used in medical diagnosis. |
|
Headless horn clause in Prolog syntax
(one of two basic statement forms) |
Unconditional assertion (assumed to be true).
male(bill). father(bill, jake). opposite(X, Y). |
|
Headed horn clause in Prolog syntax
(one of two basic statement forms) |
consequence :- antecedent_expression
ancestor(mary, shelley) :- mother(mary, shelley) * Variables in the consequence are assumed to be universally quantified. * Variables in the antecedent expression are assumed to be existentially quantified. |
|
Goal statement (queries) in Prolog
|
Propositions that we want the system to either prove or disprove. In the form of a headless horn statement
?- female(Jean). system will reply either yes or no |
|
"is" operator in Prolog
|
takes arithmetic expression as right operand and variable as left operand
?- X is 1 + 2 X = 3 ?- 1+2 is 4-1 % the first argument 1+2 is already instantiated false. |
|
Prolog tracing model of execution has four events:
|
Call - beginning of attempt to satisfy goal
Exit - when a goal has been satisfied Fail - when a goal fails Redo - when backtracking occurs |
|
In terms of context-free grammars, what is BNF?
|
Backus-Naur Form - one of two main notation techniques
|
|
Why have a methodology or notation for language semantics?
|
* Programmers need to know what statements mean
* Compiler writers must know exactly what language constructs do * Correctness proofs would be possible * Compiler generators would be possible * Designers could detect ambiguities and inconsistencies |
|
Short-Circuit Evaluation
|
(13 * a) * (b / 13 - 1)
If a is zero, no need to evaluate (b / 13 - 1) |
|
What are the three primary methods of describing dynamic (as opposed to static) semantics?
|
Operational, Denotational, Axiomatic
Note that there is no single widely acceptable notation or formalism for describing dynamic language semantics |
|
Operational semantics
|
Describe the meaning of a program by executing statements on a machine, either simulated or actual
The change in the state of the machine (memory, registers, etc.) defines the meaning of the statement |
|
Denotational semantics
|
Based on recursive function theory:
Define a mathematical object for each language entity Define a function that maps instances of the language entities onto instances of the corresponding mathematical objects |
|
Operational vs. Denotational
|
In operational semantics, the state changes are defined by coded algorithms
In denotational semantics, the state changes are defined by rigorous mathematical functions |
|
Axiomatic semantics
|
Based on formal logic (predicate calculus)
Original purpose: formal program verification Axioms or inference rules are defined for each statement type in the language to allow transformations of logical expressions into more formal logical expressions The logical expressions are called assertions |
|
What are the design issues in arithmetic expressions?
|
Operator precedence rules?
Operator associativity rules? Order of operand evaluation? Operand evaluation side effects? Operator overloading? Type mixing in expressions? |