Lambda Calculus Interpreter Definition by cases on E = x Ax E1 | E1 E2 Below is pseudocode for a lambda calculus interpreter. It performs applicative order reduction and reduces to Weak Head Normal Form: interpret(x) = x interpret(AxE1) = AxE1 interpret(E1 E2) = let f = interpret(E1) in let a = interpret(E2) in case f of AxE3 -> interpret(E3[alx]) ~fa In a similar fashion, write pseudocode for reducing a lambda expression into Normal Form using applicative order reduction.
Added by Shelia T.
Close
Step 1
First, we need to define a helper function `isReducible` to check if an expression can be further reduced. ``` isReducible(x) = False isReducible(AxE1) = True isReducible(E1 E2) = isReducible(E1) or isReducible(E2) ``` Show more…
Show all steps
Your feedback will help us improve your experience
Linda Winkler and 55 other Calculus 3 educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Propositional Inference Suppose you want to show: A ∧ B ∧ (B ⇒ D) ∧ ((A ∧ D) ⇒ E) ∧ ((B ∧ C) ⇒ F) ∧ (A ⇒ C) ∧ (F ⇒ G) ⊨ G Draw the diagram we used in the video for forward and backward chaining. Indicate the order in which symbols are popped from the agenda by forward chaining Indicate the order in which subgoals are added to the stack by backwards chaining Prove the entailment using resolution. (You do not need to show every clause generated, just those on the path to G.) Draw the tree of models explored by DPLL
Sri K.
A shift reduces parser carries out the actions specified within braces immediately after reducing with the corresponding rule of the grammar: $S \rightarrow x x W$ [print ' $\left.1^{\prime}\right]$ $S \rightarrow y$ [print '2'] $W \rightarrow S z$ [print '3'] What is the translation of ' $x x x x y z z^{\prime}$ ? (A) 1231 (B) 1233 (C) 2131 (D) 2321
COMPILER DESIGN
LEXICAL ANALYSIS AND PARSING
Let L denote a list. Write Prolog procedures to do the following: 4.1. count(X,L,N): Count the number of occurrences of X in L to give the result N. 4.2. delete_all(X,L,L1): Delete all occurrences of X from L to give the result L1. 4.3. replace_all(X,L,Y,L1): Replace all occurrences of X in L with Y to give the result L1
Shaiju T.
Recommended Textbooks
Calculus: Early Transcendentals
Thomas Calculus
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD