eval skipl_false : SKIP1 INC (PAIR FALSE ZERO) =n> (\b -> b TRUE ZERO) PAIR TRUE ZERO eval skip1_true_zero : SKIP1 INC (PAIR TRUE ZERO) =n> (\b -> b TRUE ONE) PAIR TRUE ONE -- eval skip1_true_one : SKIP1 INC (PAIR TRUE ONE) =n> (\b -> b TRUE TWO) PAIR TRUE TWO

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Lambda calculus

--------------------------------------------------------------------------------
-- Booleans
--------------------------------------------------------------------------------

let TRUE = \x y -> x
let FALSE = \x y -> y
let ITE = \b x y -> b x y
let AND = \b1 b2 -> ITE b1 b2 FALSE
let OR = \b1 b2 -> ITE b1 TRUE b2

--------------------------------------------------------------------------------
-- Numbers
--------------------------------------------------------------------------------

let ZERO = \f x -> x
let ONE = \f x -> f x
let TWO = \f x -> f (f x)
let INC = \n f x -> f (n f x)

--------------------------------------------------------------------------------
-- Pairs
--------------------------------------------------------------------------------

let PAIR = \x y b -> ITE b x y
let FST = \p -> p TRUE
let SND = \p -> p FALSE

--------------------------------------------------------------------------------
-- Ignore this definition; it's a hack to allow you to test some parts before
-- completing others
--------------------------------------------------------------------------------

let TODO = \i g n o r e -> i g n o r e

--------------------------------------------------------------------------------
-- do not modify text BEFORE this line
--------------------------------------------------------------------------------

let SKIP1 = TODO -- (a)
let DEC = TODO -- (b)
let SUB = TODO -- (c)
let ISZ = TODO -- (d)
let EQL = TODO -- (e)

--------------------------------------------------------------------------------
-- do not modify text AFTER this line
--------------------------------------------------------------------------------

-- Part (a)

eval skip1_false :
SKIP1 INC (PAIR FALSE ZERO)
=~> (\b -> b TRUE ZERO) -- PAIR TRUE ZERO

eval skip1_true_zero :
SKIP1 INC (PAIR TRUE ZERO)
=~> (\b -> b TRUE ONE) -- PAIR TRUE ONE

eval skip1_true_one :
SKIP1 INC (PAIR TRUE ONE)
=~> (\b -> b TRUE TWO) -- PAIR TRUE TWO

--------------------------------------------------------------------------------

-- Part (b)

eval decr_zero :
DEC ZERO
=~> ZERO

eval decr_one :
DEC ONE
=~> ZERO

eval decr_two :
DEC TWO
=~> ONE

 

## Problem 3: `03_minus.lc`

**NOTE:** You only need to write lambda-calculus definitions for `SKIP1`, `DEC`, `SUB`, `ISZ` and `EQL`.

### Part (a)

Replace the definition of `SKIP1` with a suitable lambda-term (i.e., replace `TODO` with a suitable term) so that the following reductions are valid:

```plaintext
eval skip1_false :
  SKIP1 INC (PAIR FALSE ZERO)
  ==> (\b -> b TRUE ZERO)      -- PAIR TRUE ZERO

eval skip1_true_zero :
  SKIP1 INC (PAIR TRUE ZERO)
  ==> (\b -> b TRUE ONE)       -- PAIR TRUE ONE

eval skip1_true_one :
  SKIP1 INC (PAIR TRUE ONE)
  ==> (\b -> b TRUE TWO)       -- PAIR TRUE TWO
```

### Part (b)

Replace the definition of `DEC` (decrement-by-one) with a suitable lambda-term (i.e., replace `TODO` with a suitable term) so that the following reductions are valid:

```plaintext
eval decr_zero :
  DEC ZERO
  ==> ZERO

eval decr_one :
  DEC ONE
  ==> ZERO

eval decr_two :
  DEC TWO
  ==> ONE
```
Transcribed Image Text:## Problem 3: `03_minus.lc` **NOTE:** You only need to write lambda-calculus definitions for `SKIP1`, `DEC`, `SUB`, `ISZ` and `EQL`. ### Part (a) Replace the definition of `SKIP1` with a suitable lambda-term (i.e., replace `TODO` with a suitable term) so that the following reductions are valid: ```plaintext eval skip1_false : SKIP1 INC (PAIR FALSE ZERO) ==> (\b -> b TRUE ZERO) -- PAIR TRUE ZERO eval skip1_true_zero : SKIP1 INC (PAIR TRUE ZERO) ==> (\b -> b TRUE ONE) -- PAIR TRUE ONE eval skip1_true_one : SKIP1 INC (PAIR TRUE ONE) ==> (\b -> b TRUE TWO) -- PAIR TRUE TWO ``` ### Part (b) Replace the definition of `DEC` (decrement-by-one) with a suitable lambda-term (i.e., replace `TODO` with a suitable term) so that the following reductions are valid: ```plaintext eval decr_zero : DEC ZERO ==> ZERO eval decr_one : DEC ONE ==> ZERO eval decr_two : DEC TWO ==> ONE ```
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY