# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

20 Pages

### 08-Induction

Course: COMP 2600, Fall 2009
School: Allan Hancock College
Rating:

Word Count: 1313

#### Document Preview

Induction COMP2600 Structural Formal Methods for Software Engineering Ben Lippmeier Australian National University Semester 2, 2008 COMP 2600 Structural Induction 1 Structural Induction What is covered in this topic. Induction on the natural numbers. Structural induction over Lists. Structural induction over Trees. The principle that the structural induction rule for a particular data type follows from...

Register Now

#### Unformatted Document Excerpt

Coursehero >> California >> Allan Hancock College >> COMP 2600

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Induction COMP2600 Structural Formal Methods for Software Engineering Ben Lippmeier Australian National University Semester 2, 2008 COMP 2600 Structural Induction 1 Structural Induction What is covered in this topic. Induction on the natural numbers. Structural induction over Lists. Structural induction over Trees. The principle that the structural induction rule for a particular data type follows from its denition. COMP 2600 Structural Induction 2 Natural Number Induction This is the induction you already know. To prove a property P for all natural numbers: Prove it for 0 Prove that, if it is true for n it is true for n + 1. The principle is usually expressed as a rule of inference: P(0) n. P(n) P(n + 1) n. P(n) COMP 2600 Structural Induction 3 Why does it Work? The natural numbers are an inductively dened set: 1. 0 is a natural number; 2. If n is a natural number, so is n+1; No object is a natural number unless justied by these clauses. From the assumptions: P(0) n. P(n) P(n + 1) we get a sequence of deductions: P(0), P(1), P(2), P(3), ... justifying the conclusion. COMP 2600 Structural Induction 4 Example of Mathematical Induction Lets prove this property of natural numbers: i=0 n n (n + 1) i = 2 First the Base case P(0) i=0 0 i = 0 (+1) 2 0 = 0 This is obviously true because both sides have the same form. COMP 2600 Structural Induction 5 Now the Step case n. P(n) P(n + 1) Following the rules of natural deduction, we will rst prove P(a) P(a + 1) for a particular number a, then generalise. Assume P(a). This assumption is called the induction hypothesis. a i=0 i = a . (a + 1) 2 Now prove P(a + 1) a+1 i=0 i = (a + 1) . ((a + 1) + 1) 2 ( COMP 2600 Structural Induction a i=0 a . (a + 1) + (a + 1) i) + (a + 1) = 2 6 Subtracting (a + 1) from both sides gives: i=0 a i = a . (a + 1) 2 This is true because it has the same form as our assumption. Using (I) we have: P(a) P(a + 1) Generalising over a gives n. P(n) P(n + 1) We have now satised both premises of the induction rule. Theorem proved! COMP 2600 Structural Induction 7 Induction on Lists Like natural numbers, lists are also inductively dened. 1. [ ] :: [a] 2. If x :: a and xs :: [a] then (x : xs) :: [a] No object is a list of as unless justied by these clauses. To prove a property for all lists (whos elements have type a) Prove it for [ ] Prove that, whenever it is true for xs it is also true for x : xs. COMP 2600 Structural Induction 8 Why does it Work? Suppose we have proved: The base case: P([ ]) The step case: x. xs. P(xs) P(x : xs) We can use these facts to prove that P([4, 2, 6]) is true. 1. P([ ]) is given 2. P([6]) follows from P([]) by the inductive step 3. P([2, 6]) follows from P([6]) by the inductive step 4. P([4, 2, 6]) follows from P([2, 6]) by the inductive step QED COMP 2600 Structural Induction 9 Thats Induction on Structure The rule of Structural Induction for Lists is usually written as: P([ ]) x. xs. P(xs) P(x : xs) xs. P(xs) or, being fussy with types: P([ ] :: [a]) (x :: a). (xs :: [a]). P(xs) P(x : xs) (xs :: [a]). P(xs) COMP 2600 Structural Induction 10 Standard functions Many of our examples will use some standard functions. We will use each line of the function denition as a rewrite rule. length [] = 0 -- ( L1 ) -- ( L2 ) -- ( M1 ) -- ( M2 ) -- ( A1 ) -- ( A2 ) length ( x : xs ) = 1 + length xs map f [] map f ( x : xs ) [] ++ ys = [] = f x : map f xs = ys = x : ( xs ++ ys ) ( x : xs ) ++ ys COMP 2600 Structural Induction 11 length f (map xs) = length xs Were doing induction over the list xs , so our rst step is to substitute [] for xs and prove the base case. Base Case: P([ ]) length ( map f []) = length [] Now look for rewrite rules to make one side obviously equal to the other. length [] Easy! = length [] -- by ( M1 ) COMP 2600 Structural Induction 12 Step Case: x. xs. P(xs) P(x : xs) Once again, we prove this for a particular list a:as, then generalise. Assume P(as) length ( map f as ) Prove P(a : as) length ( map f ( a : as )) = length ( a : as ) -- by ( M2 , L2 ) -- by ( L2 ) -- by ( IH ) = length as -- ( IH ) length ( f a : map f as ) = 1 + length as 1 + length ( map f as ) 1 + length as = 1 + length as = 1 + length as Now one side is equal to the other, so the nal statement is obviously true. Well skip the formal generalisation step and call our theorem proved. COMP 2600 Structural Induction 13 What are we really doing here? The statement S = S is always true. Our step case demonstrates that we can derive P(a : as) from S = S, though we do it in reverse. a as P(as) S=S . . . P(a : as) P(as) P(a : as) xs. P(xs) P(a : xs) x. xs. P(xs) P(x : xs) COMP 2600 Structural Induction 14 length (xs ++ ys) = length xs + length ys We do induction over one list only. When proving the above theorem, treat ys as a constant. Base Case: P([ ]) length ([] ++ ys ) = length [] + length ys length ys length ys = 0 = length ys + length ys -- by ( A1 , L1 ) -- by ( arith ) COMP 2600 Structural Induction 15 Step Case: x. xs. P(xs) P(x : xs) Assume P(as) length ( as ++ ys ) Prove P(a : as) length (( a : as ) ++ ys ) = length ( a : as ) + length ys length ( a :( as ++ ys )) = 1 + length as + length ys -- by ( A2 , L2 ) 1 + length ( as ++ ys ) = 1 + length as + length ys -- by ( L2 ) 1 + length ( as ++ ys ) = 1 + length ( as ++ ys ) Both sides are now the same. Theorem proved! -- by ( IH ) = length as + length ys -- ( IH ) COMP 2600 Structural Induction 16 A few meta-points: On the induction hypothesis: The induction hypothesis ties the recursive knot in the proof. If you havent used the induction hypothesis the pro...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Allan Hancock College - COMP - 3600
The Australian National University Department of Computer ScienceCOMP3600/COMP6466 in 2008 Assignment Two(Due: 5pm Friday, October 24 Late Penalty: 25% per day) Question 1.(50/50 for COMP3600 and 40/50 for COMP6466) Given two integers n and M wit
Allan Hancock College - COMP - 8400
THE AUSTRALIAN NATIONAL UNIVERSITY First Semester Examination June 2008 COMP8400 Algorithms and Techniques for Data Mining Study Period: 15 minutes Time Allowed: 3 hours Permitted Materials: One A4 page with notes on both sides. NO calculator permit
Allan Hancock College - COMP - 3420
DataPreprocessing Lecture12:Overviewofdatapreprocessing Lecture13:Descriptivedatasummarization Lecture14:Datacleaning Lecture15:Dataintegration/transformationanddata reduction Lecture16:Discretizationandconcepthierarchy generationandsummaryL
Allan Hancock College - COMP - 2400
SQL&gt; - cae August 2006SQL&gt; SQL&gt; drop table VideoHistory;Table dropped.SQL&gt; SQL&gt; create table VideoHistory as 2 select * from tvs.video;Table created.SQL&gt; SQL&gt; alter table VideoHistory 2 add YearSold number(4);Table altered.SQL&gt;
Allan Hancock College - COMP - 2400
- copy the file student.sql into the SQL*Plus buffer and - execute by typing '/' on the next line.SQL&gt; get student.sql 1 - A V Peterson 05-07-2005 2 - Student( StudentId, Surname, Initials, Degree ) 3 CREATE TABLE Student 4 ( 5 S
Allan Hancock College - COMP - 2400
SQL&gt; start enrolment.sqlSQL&gt; - AV Peterson 05-07-2005SQL&gt; SQL&gt; - Enrolment( StudentId, CourseCode, Mark, Year, Sem, Grade )SQL&gt; SQL&gt; CREATE TABLE Enrolment 2 ( 3 StudentId NUMBER(7), 4 CourseCode VARCHAR(8), 5 Year NUMBER(4),
Allan Hancock College - COMP - 2400
SQL&gt; - cae August 2006SQL&gt; SQL&gt; select length, incolor, count(*) 2 from movie 3 group by length, incolor; LENGTH INCOL COUNT(*)- - - 34 true 34 false 19 83 true
Allan Hancock College - COMP - 2400
SQL&gt; start q16.sqlSQL&gt; - A V Peterson 26-07-2005SQL&gt; - Q16 How many students are enrolled in COMP2400 in 2005?SQL&gt; SQL&gt; SELECT COUNT(*) 2 FROM Enrolment 3 WHERE CourseCode = 'COMP2400' 4 AND Year = 2005 5 / COUNT(*)
Allan Hancock College - COMP - 2400
SQL&gt; set pagesize 250SQL&gt; select nvl(soldto, 'No-one'), movieid 2 from video;NVL(SOLDTO MOVIEID- -No-one 1No-one 2No-one 3No-one 5No-one 72001/00002 112001/0000
Allan Hancock College - COMP - 2031
0 1 2 3 4 5 6 7 -19 3 5 6 2 -12 3 -10 -1
Allan Hancock College - COMP - 2300
2006 COMP2300 Exam Q2 (C Programming)[20 marks](a) Write a function int palindrome(char *str, int len) which for thegiven input string str of length len determines if it is a palindrome ornot. A palindrome is defined as a sequence of charact
Allan Hancock College - COMP - 2300
COMP2300-2006-CourseAdminThe Australian National University1Faculty of Engineering &amp; Information TechnologyDepartment of Computer Science COMP2300-2006-CourseAdmin 2006 Course Administration1 PreambleThis document gives a brief description o
Allan Hancock College - COMP - 2300
COMP2300-2007-CourseAdminThe Australian National University1Faculty of Engineering &amp; Information TechnologyDepartment of Computer Science COMP2300-2007-CourseAdmin 2007 Course Administration1 PreambleThis document gives a brief description o
Allan Hancock College - COMP - 2300
Data Representationq Refs: O'H&amp;Bryant sect 2.1,2.4, Null&amp;Lobur sect 2.52.7, Tanembaum appendix B,related web linksq bit, byte and word q characters and strings, ASCII q big-endian, little-endian q representing real numbersCOMP2300 D2: Data Rep
Allan Hancock College - COMP - 2300
PeANUt Module OverviewPeANUt The Basicsq a simple microprocessor simulator for teaching purposes q main topics: s s s sPeANUt architecture, machine and assembly language programming branches and conditions, loops, input/output, traps, macros p
Allan Hancock College - COMP - 2300
From Physical Memory To Virtual Memory: Understanding the Memory HierarchyAlistair RendellMemory Chips: DRAM Alternative to SRAM 1 capacitor and 1 transistorData off line Capacitor stores (10-15F) Just 40,000 electrons!Address LineTransi
Allan Hancock College - COMP - 2300
THE AUSTRALIAN NATIONAL UNIVERSITY Mid Semester Examination, April 2007 COMP2300 (Introduction to Computer Systems ) Writing Period: 1 hour duration Study Period: 0 minutes duration Permitted Materials: One A4 page with notes on both sides. NO calcul
Allan Hancock College - COMP - 2300
PeANUt Module Overviewq a simple microprocessor simulator for teaching purposes q main topics: s s s sPeANUt architecture, machine language and assembler programming branches and conditions, loops, input/output, traps, macros procedures and functi
Allan Hancock College - COMP - 2300
Allan Hancock College - COMP - 2300
Consider ( x 1)( x 7) y= ( x 11)With x = 10 we may proceed as (10-1) = 9 (10-7) = 3 Writing (9*3) = 27 intermediates on paper (10-11) = -1 27/(-1) = -27A Stack A Last In First Out (LIFO) data structure Consider a pile of paper we can pu
Allan Hancock College - COMP - 2300
COMP2300: OS and VM-related exam questions, 2007Q4(b) In both paging and set-associative caches, the least recently used(LRU), first-in-first-out (FIFO) and random replacement policies may beused. In general, which of these performs best and wh
Allan Hancock College - C - 2300
#include &lt;stdio.h&gt;int main(){ int i, total; total=0; for (i=0; i&lt;20; i+) { if (i &lt; 8 ){ continue; } else if (i &gt; 4 &amp; i &lt; 12){ total=total+i; } else if (i &gt; 10) { break; } else { tota
Allan Hancock College - COMP - 2300
#include &lt;stdio.h&gt;int main(){ int i, total; total=0; for (i=0; i&lt;20; i+) { if (i &lt; 8 ){ continue; } else if (i &gt; 4 &amp; i &lt; 12){ total=total+i; } else if (i &gt; 10) { break; } else { tota
Allan Hancock College - COMP - 2300
Assembly Level Machine OrganisationLecture 4Procedures in PeANUt Number systems (bases) in .mli les Procedure / function calls Nested procedures The stack Stack pointer Stack addressing mode Stack frame Reference: Specication of the PeANU
Allan Hancock College - COMP - 2300
Assembly Level Machine OrganisationLecture 9Bit operations and traps in PeANUt Bitwise operations Traps Trap concept PeANUt traps Trap handler and trap table Debugging References: Specification of the PeANUt computer (2.8.3 and Appendix B
Allan Hancock College - COMP - 2300
Module 2: The C programming languageLecture 4Various C assert(.) Multi-module programs #dene (Macros) Compilation and linking revisited The last word on C1COMP2300, 2006Module 2: The C programming languageLecture 4assert(.) assert
Allan Hancock College - COMP - 2300
Assembly Level Machine OrganisationLecture 1PeANUt Module Overview A simple microprocessor simulator for teaching purposes Main topics PeANUt architecture, machine language and assembly programming Branches and conditions, loops, input/outpu
Allan Hancock College - COMP - 2300
Assembly Level Machine OrganisationLecture 7Some announcements Assignment 1 is due next Wednesday 5th April at 12:00 (noon) Assignment 2 will be released towards the end of next week (draft version rst) (due in week 11, Wednesday 17th May) Lab
Allan Hancock College - COMP - 2300
Welcome to COMP2300 Introduction to Computer SystemsUltraSPARC III Cu processor layout(a rather advanced computer system!)COMP2300 2006 Lecture 1: Introduction20061Course Contactq Course web site: http:/cs.anu.edu.au/Student/comp23
Allan Hancock College - COMP - 2300
Examination Preparation LectureFinal examination Saturday, 17 June, 9:15 am 12:30 am, Sports Hall Please verify date, time and location 15 minutes reading time (9:15-9:30) Permitted material: A4 page (one sheet) with notes on both sides (no a
Allan Hancock College - COMP - 2300
Memory Systems and Modern MachinesLecture 2Announcements Assignment 1 will be returned in labs this week and marks will become available in StReaMS tomorrow (Tuesday) Some students will not see any marks (but will receive an e-mail.) :-( Lab 5
Allan Hancock College - COMP - 2300
#include&lt;stdio.h&gt; int main(void) { FILE *fp; int i; fp = fopen(&quot;myfile.txt&quot;,&quot;r+&quot;);
Allan Hancock College - C - 2300
#include &lt;stdio.h&gt;int main(void) { short int *x; /* x is a pointer to a variable of type int */ short int a = 2; printf(&quot; sizeof(a) = %d\n&quot;,sizeof(a); printf(&quot; sizeof(x) = %d\n&quot;,sizeof(x); x = &amp;a; /* The address of a is assigned to
Allan Hancock College - COMP - 2300
#include &lt;stdio.h&gt;int main(void) { short int *x; /* x is a pointer to a variable of type int */ short int a = 2; printf(&quot; sizeof(a) = %d\n&quot;,sizeof(a); printf(&quot; sizeof(x) = %d\n&quot;,sizeof(x); x = &amp;a; /* The address of a is assigned to
Allan Hancock College - C - 2300
#include &lt;stdio.h&gt; void next_year(int *y); int main(void) { int this_year; this_year = 1981; next_year(&amp;this_year); printf(&quot;Year: %d\n&quot;, this_year); return 0;}void next_year(int *y) {
Allan Hancock College - COMP - 2300
#include &lt;stdio.h&gt; void next_year(int *y); int main(void) { int this_year; this_year = 1981; next_year(&amp;this_year); printf(&quot;Year: %d\n&quot;, this_year); return 0;}void next_year(int *y) {
Allan Hancock College - COMP - 2300
Welcome to COMP2300 Introduction to Computer SystemsUltraSPARC III Cu processor layout(a rather advanced computer system!)COMP2300 Lecture 1: Introduction20071Course Contactq course web site: http:/cs.anu.edu.au/Student/comp2300 q
Allan Hancock College - COMP - 2300
COMP2300 - TuteLab 05file:/home/peter/comp2300/doc/html/TuteLab05.htmlCOMP2300 Tutorial / Laboratory 05 - PeANUt ExperimentsSemester 1, 2007 Week 6 (26 March - 30 March)Note that for this session, there is a submitable laboratory exersise which
East Los Angeles College - GEOG - 5025
GEOG5021M: Using Databases and GIS Unit 1 PracticalUsing Access: Database Creation, Query Construction and Reporting IntroductionThe practical is in three parts. The first part gets you started with Microsoft Access by requiring you to build your o
Allan Hancock College - COMP - 2300
Evolution of the Computerq Refs: [O'H&amp;Bryant, ch 1,3.1]; TextRefNull&amp;Loburch 1; [Tanembaum, Ch 1,2];related web linksq history q computer technology &amp; and von Neumann architecture q architecture s central processing unit (CPU) s arithmetic logic
Allan Hancock College - COMP - 2300
Further PeANUtq Ref: [PeANUt Spec, ]; also [OH&amp;Bryant, sect 3.6] q traps: s input and output s relationship with exceptions q conditional branches: s condition codes (part of PSW register) s branch instructions s repetition q index register and inde
Allan Hancock College - COMP - 2300
Course Review and Exam Discussionq review Q4(a) from 2006 exam (maybe a few others) q final examination: s details s topics q review of major underlying themes q outlook for computer systems q other issues: s 14:0014:15: CEDAM Surveys x please take
Allan Hancock College - COMP - 2300
COMP2300-2007-02The Australian National University1Faculty of Engineering &amp; Information TechnologyDepartment of Computer Science COMP2300-2007-02 Notes for Tutorial/Laboratory Session 03: C I/O, Pointers and StructuresNo preparation exercise a
Allan Hancock College - COMP - 2300
Procedure Calls and Address Parameters in PeANUtq ref: [PeANUt Spec, sect 4] q procedure calls s with local variables s with return values (non-void functions) q address parameters s ability to modify data s indirect memory reference via pointers q
Allan Hancock College - COMP - 2300
Virtual Memory in PeANUtq ref: [PeANUt Spec, sect 3]; additionally [O'H&amp;Bryant, sect 10.110.7] or[Null&amp;Lobur, sect 6.5]q virtual memory implementation s page tables q virtual memory in PeANUt s page replacement s paging behaviour s working sets q
Allan Hancock College - COMP - 2300
42
Allan Hancock College - COMP - 2300
/* Rename this file as: factorial.c */#include &lt;assert.h&gt;#include &quot;factorial.h&quot;int factorial(int n){ int value,i; assert(n&gt;=0); value=1; i=2; while (i &lt;= n) value*=i+; return value;}
Allan Hancock College - COMP - 2300
COMP2300: SPARC &amp; OS, 20064(e) Consider the SPARC assembler program example0.s below, annotatedwith the corresponding C program in comments (the C code can assumed tobe equivalent). The programs compiled using the commands gcc -c exa
Allan Hancock College - C - 2300
#include &lt;stdio.h&gt;int main(void) { short int *x; /* x is a pointer to a variable of type int */ short int a = 2; printf(&quot; sizeof(a) = %d\n&quot;, sizeof(a); printf(&quot; sizeof(x) = %d\n&quot;, sizeof(x); x = &amp;a; /* the address of a is assigned
Allan Hancock College - COMP - 2300
#include &lt;stdio.h&gt;int main(void) { short int *x; /* x is a pointer to a variable of type int */ short int a = 2; printf(&quot; sizeof(a) = %d\n&quot;, sizeof(a); printf(&quot; sizeof(x) = %d\n&quot;, sizeof(x); x = &amp;a; /* the address of a is assigned
Allan Hancock College - C - 2300
#include &lt;stdio.h&gt; void nextYear(int *y); int main(void) { int thisYear; thisYear = 1981; nextYear(&amp;thisYear); printf(&quot;Year: %d\n&quot;, thisYear); return 0;}void nextYear(int *y) { *y = *y + 1;
Allan Hancock College - COMP - 2300
#include &lt;stdio.h&gt; void nextYear(int *y); int main(void) { int thisYear; thisYear = 1981; nextYear(&amp;thisYear); printf(&quot;Year: %d\n&quot;, thisYear); return 0;}void nextYear(int *y) { *y = *y + 1;
Allan Hancock College - COMP - 2300
/ simple C program to demmonstate loop unriolling#include &lt;stdio.h&gt;#define VEC_LEN 10int main(void) { int i, n = VEC_LEN; int x[VEC_LEN]; / original loop for (i=0; i &lt; n; i+) { x[i] = 2*i; } / unrolled loop for (i=0; i+1 &lt;
Allan Hancock College - C - 2300
#include &lt;stdio.h&gt; #include &quot;myLibrary.h&quot;int main(void) { float x = pi(); displayFloat(x); return 0;}
Allan Hancock College - COMP - 2300
#include &lt;stdio.h&gt; #include &quot;myLibrary.h&quot;int main(void) { float x = pi(); displayFloat(x); return 0;}
East Los Angeles College - GEOG - 5041
Geog5041M Advanced Proprietary GIS Unit 4 NotesTables, Map Display and ProjectionsThe aims of this unit are to explain: how to manipulate attribute tables in ArcMap methods for displaying data and saving map output projections and coordinate sy
Allan Hancock College - C - 2300
/* Examples of GCC-style inline assembler in C code.These are used in a parallel implmeentation of the Valgrind instructionset simulation framework (www.valgrind.org).Below is the code currently used to simulate an x86 an atomic exchange instr
Allan Hancock College - COMP - 2300
/* Examples of GCC-style inline assembler in C code.These are used in a parallel implmeentation of the Valgrind instructionset simulation framework (www.valgrind.org).Below is the code currently used to simulate an x86 an atomic exchange instr
Allan Hancock College - C - 2300
#include&lt;stdio.h&gt;#include&lt;string.h&gt; void uppercase(char string[]); int main(void) { char vowels[6]; strcpy(vowels, &quot;aeiou&quot;); printf(&quot;%s\n&quot;, vowels
Allan Hancock College - COMP - 2300
#include&lt;stdio.h&gt;#include&lt;string.h&gt; void uppercase(char string[]); int main(void) { char vowels[6]; strcpy(vowels, &quot;aeiou&quot;); printf(&quot;%s\n&quot;, vowels
Allan Hancock College - COMP - 2300
Data RepresentationCharacters and Stringsq Refs: [O'H&amp;Bryant, sect 2.1,2.4], [Null&amp;Lobur, sect 2.52.7], [Tanembaum,appendix B], related web linksq text can be stored in memory by using a number to represent every character s ASCII (American St