Recursion - 1. Recursion. Recursion - 2. A Simple Recursive Example
|
|
- Thomasine Franklin
- 6 years ago
- Views:
Transcription
1 Recursion - 1 Only looping method in pure Lisp is recursion Recursion Based on Chapter 6 of Wilensky Recursive function f includes calls to f in its definition For a recursive function to eventually terminate the size of the arguments of recursive function calls need to be smaller than the original call LP-1 LP-2 Recursion - 2 A Simple Recursive Example Calculate n th power of some number m (i.e. m n ) Recursive programming involves:» Identifying how the task at hand can be solved by solving a simpler version of the same task» Specify a way to combine solutions to simpler versions to solve the original problem» Identify a base case (and its value) Base case: n = 0 which returns a result of 1 Recursive case: m n = m x m n-1 n > 0 (defun my_exp( m n ) (if ( zerop n ) 1 ( * m ( my_exp m ( - n 1 ) ) ) ) ) LP-3 LP-4
2 Recursion a general template ( defun recursive (thelist otherparameters) (cond ( (null thelist) (first base case) )... ( (pred1) (last base case) ) Recursion in General Base case: atom, nil, 0, 1, Reduction Operator: car, cdr, -1, +2, Composition Operator: cons, append, +, *, identity function, )) ( (pred2) (first nonbase case) )... ( t (last nonbase case) ) For example in function my_exp» Base case: n = 0» Reduction operator: -1» Composition Operator: * LP-5 LP-6 Recursion on Lists car recursion» Reduction by car: base case is typically an atom cdr recursion» Reducton by cdr: base case is typically the empty list car/cdr recursion» Reduction by car and cdr. Base case is an atom or the empty list car Recursion - Example ( very-first x ) finds the first atom of an s-expression. > (very-first a) A > (very-first ( ( b ) ( a c ) ) ) B > (very-first ( ( ) ( ( ( r ) v ) ) ) ) Base case: atom Reduction operator: car Composition operator: identity function ( defun very-first ( x ) ( cond ( ( atom x ) x ) LP-7 ( t ( very-first ( car x ) ) ) ) ) LP-8
3 cdr Recursion - Example car/cdr Recursion - Example ( my_append l1 l2 ) joins the contents of two lists together expression. > ( my_append ( a b c ) ( d e ) ) ( A B C D E ) > ( my_append ( ) ( x y ) ) ( X Y ) > (my_append ( ( a ) b ) ( ) ) ( ( A ) B ) Base case: If l1 is empty list result is l2 Composition operator: cons ( defun my_append ( l1 l2 ) ( cond ( ( null l1 ) l2 ) ( t ( cons ( car l1 ) ( my_append ( cdr l1 ) l2 ) ) ) ) ) LP-9 ( my_equal s1 s2 ) returns true if s1 and s2 have the same structure (same as Lisp built-in function equal ) Base case: atom or empty list Reduction operator: car or cdr Composition operator: and ( defun my_equal ( s1 s2 ) ( cond ( ( atom s1 ) ( and ( atom s2 ) ( eq s1 s2 ) ) ( (atom s2 ) nil ) ( t ( and ( my_equal (car s1 ) ( car s2 ) ) ( my_equal ( cdr s1 ) ( cdr s2 ) ) ) ) ) ) LP-10 Single / Double Recursion Tail Recursion When the function only calls itself once referred to as singly recursive» car recursion is singly recursive» cdr recursion is singly recursive When the value returned by the internal recursive call is the same as the value returned by the outer call tail recursion The composition function is the identity function When the function calls itself twice referred to as doubly recursive» car/cdr recursion is doubly recursive Tail recursion is more efficient LP-11 LP-12
4 Recursion - Example 1 ( my-length l ) is a function that counts the number of top-level elements in the list l ( Lisp has a built-in function length that does this ) > (my-length ( a ( b ) c ) ) 3 > ( my-length ( ) ) 0 > ( my-length ( ( ) ) ) 1 Recursion - Example 1 ( defun my-length ( l ) ( if ( null l ) 0 ( 1+ (my-length ( cdr l ) ) ) ) ) Composition Operator: 1+ IS THERE A MORE EFFICIENT WAY TO DO THIS??? LP-13 LP-14 Recursion - Example 1 - Revisited Recursion - Example 2 Use tail recursion to make function my-length more efficient ( reverse l ) is a function that returns the top-level elements of list l in reverse order ( defun my-length ( l ) ( my-length-aux l 0 ) ) > ( reverse ( a b c ) ) ( C B A ) > ( reverse ( a ( b c ) d ) ) ( defun my-length-aux ( l result ) ( if ( null l ) result ( my-length-aux ( cdr l ) ( 1+ result ) ) ) ) ( D ( B C ) A ) > ( reverse ( ) ) LP-15 LP-16
5 Recursion - Example 2 Recursion - Example 2 - Revisited ( defun reverse ( l ) ( cond ( null l ) nil Use tail recursion to make function reverse more efficient ( t ( append ( reverse ( cdr l ) ) ( list ( car l ) ) ) ) ) ( defun tail-reverse ( l ) ( tail-reverse-aux l ( ) ) ) Composition Operator: append ( defun tail-reverse-aux ( l result ) ( cond ( ( null l ) result ) IS THERE A MORE EFFICIENT WAY TO DO THIS??? ) ) ) ( t ( tail-reverse-aux ( cdr l ) ( cons (car l ) result ) ) LP-17 LP-18 Recursion - Example 2 Recursion- Example 3 In case you were wondering. (remove-top list item ) removes item from list only at the top level > ( remove-top '( ) 'a ) Tail recursion can be much more efficient Complexity of reverse: O(n 2 ) Complexity of tail-reverse: O(n) > ( remove-top '( a b c ) 'a ) ( B C ) > ( remove-top '( a ( b c ) b ) 'b ) ( A ( B C ) ) Composition operator: cons LP-19 LP-20
6 Recursion- Example 3 Recursion- Example 4 (remove-all list item ) removes item from list at any level (defun remove-top (list item) (cond ( ( null list ) nil ) ( ( equal ( car list ) item ) ( remove-top ( cdr list ) item ) ) ( t ( cons ( car list ) ( remove-top ( cdr list ) item ) ) ) )) > ( remove-all ( ) a ) > ( remove-all ( a b c ) a ) ( B C ) > ( remove-all ( a ( ( b ) c ) b ) b ) ( A ( C ) ) Composition operator: cons LP-21 LP-22 Recursion - Example 4 (defun remove-all (list item) )) (cond ( ( null list ) nil ) ( ( equal ( car list ) item ) ( remove-all ( cdr list ) item ) ) ( ( atom ( car list ) ) ( cons ( car list ) ( remove-all ( cdr list ) item ) ) ) ( t ( cons ( remove-all ( car list ) item ) ( remove-all ( cdr list ) item ) ) ) LP-23
Lisp Programming! Gunnar Gotshalks! LP-1
Lisp Programming! LP-1 Boolean Functions! Return T for true and nil for false!» ( atom item )! > is item an atom, i.e. not a cons cell!» ( listp item )! > is item a list, i.e. a cons cell!» ( null item
More informationLambda Calculus! Gunnar Gotshalks! LC-1
Lambda Calculus! LC-1 λ Calculus History! Developed by Alonzo Church during mid 1930 s! One fundamental goal was to describe what can be computed.! Full definition of λ-calculus is equivalent in power
More informationMeta-Circularity, and Vice-Versa
1/60, and Vice-Versa didier@lrde.epita.fr http://www.lrde.epita.fr/ didier ACCU 2011 Thursday, April 14th 2/60 Table of contents 1 2 Symbolic Expressions 3 The of LISP 4 5 6 7 8 Dynamic 9 4/60 circularity
More information6.001 SICP September? Procedural abstraction example: sqrt (define try (lambda (guess x) (if (good-enuf? guess x) guess (try (improve guess x) x))))
September? 600-Introduction Trevor Darrell trevor@csail.mit.edu -D5 6.00 web page: http://sicp.csail.mit.edu/ section web page: http://www.csail.mit.edu/~trevor/600/ Abstractions Pairs and lists Common
More information(defvar *ASSERTIONS* nil) ;;;top level interpreter loop (defun logic-shell ()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; LOGIC PROGRAMMING INTERPRETER ;;; ;;; from George Lugar and William Stubblefield ;;; Artificial Intelligence and the Design of Expert Systems
More informationToward Automating the Discovery of Decreasing Measures
Toward Automating the Discovery of Decreasing Measures Robert S. Boyer, Wilfred J. Legato and Victor W. Marek Abstract An often neglected part of proof automation is simply admitting recursive function
More informationLisp Introduction. Dr. Neil T. Dantam. Spring CSCI-498/598 RPM, Colorado School of Mines. Dantam (Mines CSCI, RPM) Lisp Spring / 88
Lisp Introduction Dr. Neil T. Dantam CSCI-498/598 RPM, Colorado School of Mines Spring 28 Dantam (Mines CSCI, RPM) Lisp Spring 28 / 88 Outline Lisp Common Lisp by Example Implementation Details Typing
More informationListing up Combinations of Resistances
Original Article 1 Listing up Combinations of Resistances ISOKAWA Yukinao* (Received 27 October, 2015) Abstract Circuits, nested connections of resistances in series and/or in parallel, are studied. We
More informationMeta-programming & you
Meta-programming & you Robin Message Cambridge Programming Research Group 10 th May 2010 What s meta-programming about? 1 result=somedb. customers. select 2 { first_name+ +last_name } 3 where name LIKE
More information6.001, Fall Semester, 1998 Problem Set 5 2 (define (adjoin-term term series) (cons-stream term series) Since this does not produce an error, he shows
1 MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Fall Semester, 1998 Issued: Thursday, October 15,
More informationSolutions to EoPL3 Exercises
Solutions to EoPL3 Exercises Release 0.1.0 Cheng Lian May 16, 2017 Contents 1 Contents 3 2 Overview 29 i ii Author Cheng Lian Contents 1 2 Contents CHAPTER 1 Contents Chapter 1.
More informationLecture 5: Sep. 23 &25
CIS 2168 Data Structures Fall 2014 Lecturer: Anwar Mamat Lecture 5: Sep. 23 &25 Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 5.1 Doubly Linked
More informationOutline Resource Introduction Usage Testing Exercises. Linked Lists COMP SCI / SFWR ENG 2S03. Department of Computing and Software McMaster University
COMP SCI / SFWR ENG 2S03 Department of Computing and Software McMaster University Week 10: November 7 - November 11 Outline 1 Resource 2 Introduction Nodes Illustration 3 Usage Accessing and Modifying
More informationMechanized Proof of Buchberger s Algorithm in ACL2
Mechanized Proof of Buchberger s Algorithm in ACL2 J.L. Ruiz-Reina, I. Medina and F. Palomo Departamento de Ciencias de la Computación e Inteligencia Artificial Univ. Sevilla Departamento de Lenguajes
More informationFunctional Programming Laboratory 3
Functional Programming Laboratory 3 Define new functions, Recursion Isabela Drămnesc March 12, 2014 1 Concepts Bound and free variables Recursive functions Simple and double recursion 2 Questions from
More informationforty-two XLII Equivalent Computers? Lecture 40: Computing with Glue and Photons What is 42? cuarenta y dos Meaning of Numbers Meaning of Numbers
), #, R #,, - ), #, R #,, - Lecture 40: Computing with Glue and Photons Equivalent Computers? z z z... term = variable term term (term) λ variable. term λy. M α λv. (M [y α v]) where v does not occur in
More information6.001 Recitation 22: Streams
6.001 Recitation 22: Streams RI: Gerald Dalley, dalleyg@mit.edu, 4 May 2007 http://people.csail.mit.edu/dalleyg/6.001/sp2007/ The three chief virtues of a programmer are: Laziness, Impatience and Hubris
More informationRecursion. Recursion. Steven Zeil. November 25, 2013
Steven Zeil November 25, 2013 Outline 1 2 Example: Compressing a Picture 3 Outline I 1 2 Example: Compressing a Picture 3 A function is recursive if it calls itself or calls some other function that eventually
More informationAccumulators More on Arithmetic and Recursion
Accumulators More on Arithmetic and Recursion Shakil M. Khan adapted from Gunnar Gotshalks listlen ( L, N ) L is a list of length N if... listlen ( [], 0 ). listlen ( [ H T ], N ) :- listlen ( T, N1 ),
More informationAssignment 4 - Solution
Assignment 4 - Solution Question 1 // The key point to take into account is that the values can be obtained from the promises // in any order but we still want to resolve an array of values where all the
More informationAssignment 4. CSci 3110: Introduction to Algorithms. Sample Solutions
Assignment 4 CSci 3110: Introduction to Algorithms Sample Solutions Question 1 Denote the points by p 1, p 2,..., p n, ordered by increasing x-coordinates. We start with a few observations about the structure
More informationCurrent State of the Noun Definition Algorithm and Associated Demonstrations
Current State of the Noun Definition Algorithm and Associated Demonstrations Scott Napieralski stn2@cse.buffalo.edu May 1, 2003 Abstract This document describes work on the Contextual Vocabulary Acquisition
More informationOutline Resource Introduction Usage Testing Exercises. Linked Lists COMP SCI / SFWR ENG 2S03. Department of Computing and Software McMaster University
COMP SCI / SFWR ENG 2S03 Department of Computing and Software McMaster University Week 10: November 10 - November 14 Outline 1 Resource 2 Introduction Nodes Illustration 3 Usage Adding Finding and Removing
More informationOrder Sorted Algebra. Japan Advanced Institute of Science and Technology. March 8, 2008
Order Sorted Algebra Daniel Găină Japan Advanced Institute of Science and Technology March 8, 2008 Introduction There are many examples where all items of one sort are necessarily also items of some other
More informationMechanized Operational Semantics
Mechanized Operational Semantics J Strother Moore Department of Computer Sciences University of Texas at Austin Marktoberdorf Summer School 2008 (Lecture 5: Boyer-Moore Fast String Searching) 1 The Problem
More informationFunctional Programming: Lists, Pattern Matching, Recursive Programming (CTM Sections , 3.2, , 4.7.2)
Functional Programming: Lists, Pattern Matching, Recursive Programming (CTM Sections 1.1-1.7, 3.2, 3.4.1-3.4.2, 4.7.2) Carlos Varela RPI September 9, 2016 Adapted with permission from: Seif Haridi KTH
More informationFinite-Domain Temporal Logic in ACL2: a semantics-based approach
Finite-Domain Temporal Logic in ACL2: a semantics-based approach Matteo Pradella CNR IEIIT-MI Dipartimento di Elettronica e Informazione Politecnico di Milano via Ponzio 34/5 20133 Milano, ITALY pradella@elet.polimi.it
More informationRelational-Database Design
C H A P T E R 7 Relational-Database Design Exercises 7.2 Answer: A decomposition {R 1, R 2 } is a lossless-join decomposition if R 1 R 2 R 1 or R 1 R 2 R 2. Let R 1 =(A, B, C), R 2 =(A, D, E), and R 1
More informationProving Type Soundness of Simple Languages in ACL2
Proving Type Soundness of Simple Languages in ACL2 Daniel J. Singer University of Michigan Department of Philosophy 435 South State Street Ann Arbor, MI 48109 singerdj@umich.edu ABSTRACT This paper discusses
More informationExtending the Lambda Calculus: An Eager Functional Language
Syntax of the basic constructs: Extending the Lambda Calculus: An Eager Functional Language canonical forms z cfm ::= intcfm boolcfm funcfm tuplecfm altcfm intcfm ::= 0 1-1... boolcfm ::= boolconst funcfm
More informationCOMP 204. Object Oriented Programming (OOP) Mathieu Blanchette
COMP 204 Object Oriented Programming (OOP) Mathieu Blanchette 1 / 14 Object-Oriented Programming OOP is a way to write and structure programs to make them easier to design, understand, debug, and maintain.
More informationRecursion: Introduction and Correctness
Recursion: Introduction and Correctness CSE21 Winter 2017, Day 7 (B00), Day 4-5 (A00) January 25, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Today s Plan From last time: intersecting sorted lists and
More informationCS156: The Calculus of Computation
Page 1 of 31 CS156: The Calculus of Computation Zohar Manna Winter 2010 Chapter 3: First-Order Theories Page 2 of 31 First-Order Theories I First-order theory T consists of Signature Σ T - set of constant,
More informationAccumulators More on Arithmetic and Recursion
Accumulators More on Arithmetic and Recursion Acc-1 L is a list of length N if... listlen ( [], 0 ). listlen ( L, N ) listlen ( [ H T ], N ) :- listlen ( T, N1 ), N is N1 + 1. > On searching for the goal,
More informationOn Lists and Other Abstract Data Types in the Calculus of Constructions
On Lists and Other Abstract Data Types in the Calculus of Constructions Jonathan P. Seldin Department of Mathematics Concordia University Montreal, Quebec, Canada seldin@alcor.concordia.ca January 29,
More informationCOMP Assignment 1 Solutions
COMP 409 - Assignment 1 Solutions 1 Show that there are no formulas of length 2,3, or 6, but that every other length is possible. Let p, q and r be atomic propositions. Then p is a formula of length 1,
More informationPropositional Logic. What is discrete math? Tautology, equivalence, and inference. Applications
What is discrete math? Propositional Logic The real numbers are continuous in the senses that: between any two real numbers there is a real number The integers do not share this property. In this sense
More informationDependent types. Paul Stansifer. March 16, 2012
Dependent types Paul Stansifer March 16, 2012 1 You ve seen this before I hope you like abstraction, because we re about to use it a lot. Here s the simply-typed lambda calculus with built-in list operations
More informationSGN Advanced Signal Processing Project bonus: Sparse model estimation
SGN 21006 Advanced Signal Processing Project bonus: Sparse model estimation Ioan Tabus Department of Signal Processing Tampere University of Technology Finland 1 / 12 Sparse models Initial problem: solve
More informationOutline / Reading. Greedy Method as a fundamental algorithm design technique
Greedy Method Outline / Reading Greedy Method as a fundamental algorithm design technique Application to problems of: Making change Fractional Knapsack Problem (Ch. 5.1.1) Task Scheduling (Ch. 5.1.2) Minimum
More informationLecture 5. Linear Systems. Gauss Elimination. Lecture in Numerical Methods from 24. March 2015 UVT. Lecture 5. Linear Systems. show Practical Problem.
Linear Systems. Gauss Elimination. Lecture in Numerical Methods from 24. March 2015 FIGURE A S UVT Agenda of today s lecture 1 Linear Systems. 2 Gauss Elimination FIGURE A S 1.2 We ve got a problem 210
More informationRecursion and Induction
Recursion and Induction Themes Recursion Recurrence Definitions Recursive Relations Induction (prove properties of recursive programs and objects defined recursively) Examples Tower of Hanoi Gray Codes
More informationSolutions. Problem 1: Suppose a polynomial in n of degree d has the form
Assignment 1 1. Problem 3-1 on p. 57 2. Problem 3-2 on p. 58 3. Problem 4-5 on p. 86 4. Problem 6-1 on p. 142 5. Problem 7-4 on p. 162 6. Prove correctness (including halting) of SelectionSort (use loop
More informationCS20a: Turing Machines (Oct 29, 2002)
CS20a: Turing Machines (Oct 29, 2002) So far: DFA = regular languages PDA = context-free languages Today: Computability 1 Church s thesis The computable functions are the same as the partial recursive
More informationLab Course: distributed data analytics
Lab Course: distributed data analytics 01. Threading and Parallelism Nghia Duong-Trung, Mohsan Jameel Information Systems and Machine Learning Lab (ISMLL) University of Hildesheim, Germany International
More informationQuery Processing. 3 steps: Parsing & Translation Optimization Evaluation
rela%onal algebra Query Processing 3 steps: Parsing & Translation Optimization Evaluation 30 Simple set of algebraic operations on relations Journey of a query SQL select from where Rela%onal algebra π
More informationLecture 5 Simplex Method. September 2, 2009
Simplex Method September 2, 2009 Outline: Lecture 5 Re-cap blind search Simplex method in steps Simplex tableau Operations Research Methods 1 Determining an optimal solution by exhaustive search Lecture
More informationAutomated Reasoning Lecture 17: Inductive Proof (in Isabelle)
Automated Reasoning Lecture 17: Inductive Proof (in Isabelle) Jacques Fleuriot jdf@inf.ed.ac.uk Recap Previously: Unification and Rewriting This time: Proof by Induction (in Isabelle) Proof by Mathematical
More informationICS141: Discrete Mathematics for Computer Science I
ICS141: Discrete Mathematics for Computer Science I Dept. Information & Computer Sci., Jan Stelovsky based on slides by Dr. Baek and Dr. Still Originals by Dr. M. P. Frank and Dr. J.L. Gross Provided by
More informationPart I: Definitions and Properties
Turing Machines Part I: Definitions and Properties Finite State Automata Deterministic Automata (DFSA) M = {Q, Σ, δ, q 0, F} -- Σ = Symbols -- Q = States -- q 0 = Initial State -- F = Accepting States
More informationApplied Logic for Computer Scientists. Answers to Some Exercises
Applied Logic for Computer Scientists Computational Deduction and Formal Proofs Springer, 2017 doi: http://link.springer.com/book/10.1007%2f978-3-319-51653-0 Answers to Some Exercises Mauricio Ayala-Rincón
More informationTheory Extension in ACL2(r)
Theory Extension in ACL2(r) R. Gamboa (ruben@cs.uwyo.edu) and J. Cowles (cowles@uwyo.edu) Department of Computer Science University of Wyoming Laramie, Wyoming, USA Abstract. ACL2(r) is a modified version
More informationEvery formula evaluates to either \true" or \false." To say that the value of (x = y) is true is to say that the value of the term x is the same as th
A Quick and Dirty Sketch of a Toy Logic J Strother Moore January 9, 2001 Abstract For the purposes of this paper, a \logic" consists of a syntax, a set of axioms and some rules of inference. We dene a
More informationOrganon: A Symbolic Constraint Framework & Solver Isaac Evans and Joseph Lynch
Computer Science and Artificial Intelligence Laboratory Technical Report MIT-CSAIL-TR-2013-010 May 24, 2013 Organon: A Symbolic Constraint Framework & Solver Isaac Evans and Joseph Lynch massachusetts
More informationCO 602/CM 740: Fundamentals of Optimization Problem Set 4
CO 602/CM 740: Fundamentals of Optimization Problem Set 4 H. Wolkowicz Fall 2014. Handed out: Wednesday 2014-Oct-15. Due: Wednesday 2014-Oct-22 in class before lecture starts. Contents 1 Unique Optimum
More informationAdapted with permission from: Seif Haridi KTH Peter Van Roy UCL. C. Varela; Adapted w. permission from S. Haridi and P. Van Roy 1
Higher-Order Programming: Iterative computation (CTM Section 3.2) Closures, procedural abstraction, genericity, instantiation, embedding (CTM Section 3.6.1) Carlos Varela RPI September 15, 2015 Adapted
More informationThe simplex algorithm
The simplex algorithm The simplex algorithm is the classical method for solving linear programs. Its running time is not polynomial in the worst case. It does yield insight into linear programs, however,
More informationEquivalent Computers. Lecture 39: Lambda Calculus. Lambda Calculus. What is Calculus? Real Definition. Why?
#,, - Lecture 39: Lambda Calculus Equivalent Computers z z z... term = variable term term (term) λ variable. term λy. M α λv. (M [y α v]) where v does not occur in M. (λx. M)N β M [ x α N ] Turing Machine
More informationCS156: The Calculus of Computation Zohar Manna Winter 2010
Page 3 of 31 Page 4 of 31 CS156: The Calculus of Computation Zohar Manna Winter 2010 First-Order Theories I First-order theory T consists of Signature ΣT - set of constant, function, and predicate symbols
More informationTDDD08 Tutorial 1. Who? From? When? 6 september Victor Lagerkvist (& Wªodek Drabent)
TDDD08 Tutorial 1 Who? From? Victor Lagerkvist (& Wªodek Drabent) Theoretical Computer Science Laboratory, Linköpings Universitet, Sweden When? 6 september 2015 1 / 18 Preparations Before you start with
More informationIntroduction to lambda calculus Part 6
Introduction to lambda calculus Part 6 Antti-Juhani Kaijanaho 2017-02-16 1 Untyped lambda calculus 2 Typed lambda calculi 2.1 Dynamically typed lambda calculus with integers 2.2 A model of Lisp 2.3 Simply
More informationSection Summary. Sequences. Recurrence Relations. Summations Special Integer Sequences (optional)
Section 2.4 Section Summary Sequences. o Examples: Geometric Progression, Arithmetic Progression Recurrence Relations o Example: Fibonacci Sequence Summations Special Integer Sequences (optional) Sequences
More informationCSE 211. Pushdown Automata. CSE 211 (Theory of Computation) Atif Hasan Rahman
CSE 211 Pushdown Automata CSE 211 (Theory of Computation) Atif Hasan Rahman Lecturer Department of Computer Science and Engineering Bangladesh University of Engineering & Technology Adapted from slides
More informationCSE613: Parallel Programming, Spring 2012 Date: May 11. Final Exam. ( 11:15 AM 1:45 PM : 150 Minutes )
CSE613: Parallel Programming, Spring 2012 Date: May 11 Final Exam ( 11:15 AM 1:45 PM : 150 Minutes ) This exam will account for either 10% or 20% of your overall grade depending on your relative performance
More informationOutline. A recursive function follows the structure of inductively-defined data.
Outline A recursive function follows the structure of inductively-defined data. With lists as our example, we shall study 1. inductive definitions (to specify data) 2. recursive functions (to process data)
More informationPerfect Numbers in ACL2
Perfect Numbers in ACL2 John Cowles Ruben Gamboa University of Wyoming perfect number n: n is a positive integer n equals the sum of all positive integer proper divisors of n. k is proper divisor of n
More informationIndependence, Variance, Bayes Theorem
Independence, Variance, Bayes Theorem Russell Impagliazzo and Miles Jones Thanks to Janine Tiefenbruck http://cseweb.ucsd.edu/classes/sp16/cse21-bd/ May 16, 2016 Resolving collisions with chaining Hash
More informationA Reduction Approach to Decision Procedures
A Reduction Approach to Decision Procedures Deepak Kapur and Calogero G. Zarba University of New Mexico Abstract. We present an approach for designing decision procedures based on the reduction of complex
More informationImplementation in Acl2 of Well-Founded Polynomial Orderings
Implementation in Acl2 of Well-Founded Polynomial Orderings I. Medina-Bulo, F. Palomo-Lozano, and J. A. Alonso-Jiménez Dept. de Lenguajes y Sistemas Informáticos (Univ. de Cádiz) Escuela Superior de Ingeniería
More informationGuest lecturer: Mark Reynolds, The University of Western Australia. May 7, 2014
Università degli studi di Udine Laurea Magistrale: Informatica Lectures for April/May 2014 La verifica del software: temporal logic Lecture 03 LTL tableau continued Guest lecturer: Mark Reynolds, The University
More informationHomework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4
Do the following exercises from the text: Chapter (Section 3):, 1, 17(a)-(b), 3 Prove that 1 3 + 3 + + n 3 n (n + 1) for all n N Proof The proof is by induction on n For n N, let S(n) be the statement
More informationFinite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions
Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017 Formal proofs; Simple/strong induction; Mutual induction; Inductively defined sets; Recursively defined functions. Lecture 3 Ana Bove
More informationA Denotational Approach to Measuring Complexity in Functional Programs
A Denotational Approach to Measuring Complexity in Functional Programs Kathryn Van Stone June 2003 CMU-CS-03-150 School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213 Thesis Committee:
More informationOn improving matchings in trees, via bounded-length augmentations 1
On improving matchings in trees, via bounded-length augmentations 1 Julien Bensmail a, Valentin Garnero a, Nicolas Nisse a a Université Côte d Azur, CNRS, Inria, I3S, France Abstract Due to a classical
More informationSolutions to Exercises. Solution to Exercise 2.4. Solution to Exercise 2.5. D. Sabel and M. Schmidt-Schauß 1
D. Sabel and M. Schmidt-Schauß 1 A Solutions to Exercises Solution to Exercise 2.4 We calculate the sets of free and bound variables: FV ((λy.(y x)) (λx.(x y)) (λz.(z x y))) = FV ((λy.(y x)) (λx.(x y)))
More informationLINEAR RECURSIVE SEQUENCES. The numbers in the sequence are called its terms. The general form of a sequence is
LINEAR RECURSIVE SEQUENCES BJORN POONEN 1. Sequences A sequence is an infinite list of numbers, like 1) 1, 2, 4, 8, 16, 32,.... The numbers in the sequence are called its terms. The general form of a sequence
More informationA Formal Model of Asynchronous Communication and Its Use in Mechanically Verifying a Biphase Mark Protocol
A Formal Model of Asynchronous Communication and Its Use in Mechanically Verifying a Biphase Mark Protocol J Strother Moore Technical Report 68 1992 Computational Logic Inc. 1717 W. 6th St. Suite 290 Austin,
More informationLecture 5: Loop Invariants and Insertion-sort
Lecture 5: Loop Invariants and Insertion-sort COMS10007 - Algorithms Dr. Christian Konrad 11.01.2019 Dr. Christian Konrad Lecture 5: Loop Invariants and Insertion-sort 1 / 12 Proofs by Induction Structure
More informationMathematical Background. Unsigned binary numbers. Powers of 2. Logs and exponents. Mathematical Background. Today, we will review:
Mathematical Background Mathematical Background CSE 373 Data Structures Today, we will review: Logs and eponents Series Recursion Motivation for Algorithm Analysis 5 January 007 CSE 373 - Math Background
More informationParsing with CFGs L445 / L545 / B659. Dept. of Linguistics, Indiana University Spring Parsing with CFGs. Direction of processing
L445 / L545 / B659 Dept. of Linguistics, Indiana University Spring 2016 1 / 46 : Overview Input: a string Output: a (single) parse tree A useful step in the process of obtaining meaning We can view the
More informationProgramming with classical quantum datatypes
Programming with classical quantum datatypes Robin Cockett & Brett Giles (robin,gilesb)@cpsc.ucalgary.ca University of Calgary FMCS 2006, Programming with classical quantum datatypes p. 1/49 Yet another
More informationParsing with CFGs. Direction of processing. Top-down. Bottom-up. Left-corner parsing. Chart parsing CYK. Earley 1 / 46.
: Overview L545 Dept. of Linguistics, Indiana University Spring 2013 Input: a string Output: a (single) parse tree A useful step in the process of obtaining meaning We can view the problem as searching
More information1 Algorithms for Permutation Groups
AM 106/206: Applied Algebra Madhu Sudan Lecture Notes 9 October 3, 2016 References: Based on text by Akos Seress on Permutation Group Algorithms. Algorithm due to Sims. 1 Algorithms for Permutation Groups
More informationMath Models of OR: Extreme Points and Basic Feasible Solutions
Math Models of OR: Extreme Points and Basic Feasible Solutions John E. Mitchell Department of Mathematical Sciences RPI, Troy, NY 1180 USA September 018 Mitchell Extreme Points and Basic Feasible Solutions
More informationRecursive Definitions
Recursive Definitions Example: Give a recursive definition of a n. a R and n N. Basis: n = 0, a 0 = 1. Recursion: a n+1 = a a n. Example: Give a recursive definition of n i=0 a i. Let S n = n i=0 a i,
More informationHOW TO FACILITATE THE PROOF OF THEORIES BY USING THe INDUCTION MATCHING. AND BY GENERALIZATION» Jacqueline Castaing
HOW TO FACILITATE THE PROOF OF THEORIES BY USING THe INDUCTION MATCHING. AND BY GENERALIZATION» Jacqueline Castaing IRI Bat 490 Univ. de Pans sud F 9140b ORSAY cedex ABSTRACT In this paper, we show how
More informationGeneral Physics (PHYC 252) Exam 4
General Physics (PHYC 5) Exam 4 Multiple Choice (6 points). Circle the one best answer for each question. For Questions 1-3, consider a car battery with 1. V emf and internal resistance r of. Ω that is
More informationMath 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction
Math 4 Summer 01 Elementary Number Theory Notes on Mathematical Induction Principle of Mathematical Induction Recall the following axiom for the set of integers. Well-Ordering Axiom for the Integers If
More informationMotivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis
Motivation Introduction to Algorithms Hash Tables CSE 680 Prof. Roger Crawfis Arrays provide an indirect way to access a set. Many times we need an association between two sets, or a set of keys and associated
More informationAside: Golden Ratio. Golden Ratio: A universal law. Golden ratio φ = lim n = 1+ b n = a n 1. a n+1 = a n + b n, a n+b n a n
Aside: Golden Ratio Golden Ratio: A universal law. Golden ratio φ = lim n a n+b n a n = 1+ 5 2 a n+1 = a n + b n, b n = a n 1 Ruta (UIUC) CS473 1 Spring 2018 1 / 41 CS 473: Algorithms, Spring 2018 Dynamic
More informationDepending on equations
Depending on equations A proof-relevant framework for unification in dependent type theory Jesper Cockx DistriNet KU Leuven 3 September 2017 Unification for dependent types Unification is used for many
More informationHigher-Order Chaotic Iteration Sequences
Higher-Order Chaotic Iteration Sequences Mads Rosendahl DIKU, University of Copenhagen Universitetsparken 1, DK-2100 Copenhagen Ø, Denmark E-mail rose@diku.dk 1993 Abstract Chaotic iteration sequences
More informationQueues. Principles of Computer Science II. Basic features of Queues
Queues Principles of Computer Science II Abstract Data Types Ioannis Chatzigiannakis Sapienza University of Rome Lecture 9 Queue is also an abstract data type or a linear data structure, in which the first
More informationActivity selection. Goal: Select the largest possible set of nonoverlapping (mutually compatible) activities.
Greedy Algorithm 1 Introduction Similar to dynamic programming. Used for optimization problems. Not always yield an optimal solution. Make choice for the one looks best right now. Make a locally optimal
More informationIntroduction to Statistics
MTH4106 Introduction to Statistics Notes 15 Spring 2013 Testing hypotheses about the mean Earlier, we saw how to test hypotheses about a proportion, using properties of the Binomial distribution It is
More informationStatistics for Managers Using Microsoft Excel/SPSS Chapter 4 Basic Probability And Discrete Probability Distributions
Statistics for Managers Using Microsoft Excel/SPSS Chapter 4 Basic Probability And Discrete Probability Distributions 1999 Prentice-Hall, Inc. Chap. 4-1 Chapter Topics Basic Probability Concepts: Sample
More informationEvolving a New Feature for a Working Program
Evolving a New Feature for a Working Program Mike Stimpson arxiv:1104.0283v1 [cs.ne] 2 Apr 2011 January 18, 2013 Abstract A genetic programming system is created. A first fitness function f 1 is used to
More informationThe Samson-Mills-Quine theorem
The Samson-Mills-Quine theorem Intermediate Logic The dnf simplification procedure can greatly simplify the complexity of truth-functional formulas, but it does not always turn up a simplest possible Boolean
More informationThe Samson-Mills-Quine theorem
The Samson-Mills-Quine theorem Intermediate Logic The dnf simplification procedure can greatly simplify the complexity of truth-functional formulas, but it does not always turn up a simplest possible Boolean
More informationLiveness based Garbage Collection
CS738: Advanced Compiler Optimizations Liveness based Garbage Collection Amey Karkare karkare@cse.iitk.ac.in http://www.cse.iitk.ac.in/~karkare/cs738 Department of CSE, IIT Kanpur Ideal Garbage Collection...
More information