Logic for computer science Transparency No. 2-0 Chapter 2 Mathematical Preliminaries.

Slides:



Advertisements
Similar presentations
Chapter 2 Revision of Mathematical Notations and Techniques
Advertisements

Relations Relations on a Set. Properties of Relations.
Equivalence, Order, and Inductive Proof
The Engineering Design of Systems: Models and Methods
Transparency No. 2-1 Formal Language and Automata Theory Chapter 2 Deterministic Finite Automata (DFA) (include Lecture 3 and 4)
Transparency No Formal Language and Automata Theory Chapter 10 The Myhill-Nerode Theorem (lecture 15,16 and B)
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
Theory and Applications
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
Partially Ordered Sets (POSets)
Relations Chapter 9.
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
Logics for Data and Knowledge Representation Introduction to Algebra Chiara Ghidini, Luciano Serafini, Fausto Giunchiglia and Vincenzo Maltese.
Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
Induction and recursion
Mathematics. Session Set, Relation & Function Session - 3.
Foundations of Discrete Mathematics Chapter 3 By Dr. Dalia M. Gil, Ph.D.
Mathematical Preliminaries Strings and Languages Preliminaries 1.
Mathematical preliminaries Episode 2 0 Sets Sequences Functions Relations Strings.
Chapter 9. Chapter Summary Relations and Their Properties Representing Relations Equivalence Relations Partial Orderings.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Discrete Math for CS Binary Relation: A binary relation between sets A and B is a subset of the Cartesian Product A x B. If A = B we say that the relation.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
Chapter 9. Section 9.1 Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)
Functions1 Elementary Discrete Mathematics Jim Skon.
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
Example Prove that: “IF 3n + 2 is odd, then n is odd” Proof by Contradiction: -p = 3n + 2 is odd, q = n is odd. -Assume that ~(p  q) is true OR -(p 
Math Chapter 6 Part II. POWER SETS In mathematics, given a set S, the power set of S, written P(S) or 2 n(S), is the set of all subsets of S. Remember.
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
Mathematical Induction
Formal Language Transparency No. 1-1 Formal Language and Automata Theory Cheng-Chia Chen September 2007.
Language: Set of Strings
Discrete Mathematics R. Johnsonbaugh
CHAPTER 3 FUZZY RELATION and COMPOSITION. 3.1 Crisp relation Product set Definition (Product set) Let A and B be two non-empty sets, the product.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
Sets. Definitions (I) Collection of elements such that: There are no duplicates There is no order Special sets Universe (U or E): all elements under consideration.
Mathematical Preliminaries
Sets and Subsets Set A set is a collection of well-defined objects (elements/members). The elements of the set are said to belong to (or be contained in)
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
Basic Structures: Sets, Functions, Sequences, and Sums.
1 Discrete and Combinatorial Mathematics R. P. Grimaldi, 5 th edition, 2004 Chapter 5 Relations and Functions.
Problem Statement How do we represent relationship between two related elements ?
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Unit II Discrete Structures Relations and Functions SE (Comp.Engg.)
1 Section 4.3 Order Relations A binary relation is an partial order if it transitive and antisymmetric. If R is a partial order over the set S, we also.
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
Discrete Mathematics ? Transparency No. 2-0 Chapter 3 Induction and Recursion Transparency No. 3-1 formal logic mathematical preliminaries.
RelationsCSCE 235, Spring Introduction A relation between elements of two sets is a subset of their Cartesian products (set of all ordered pairs.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Set Theory Concepts Set – A collection of “elements” (objects, members) denoted by upper case letters A, B, etc. elements are lower case brackets are used.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
FUNCTIONS.
Week 8 - Wednesday.  What did we talk about last time?  Relations  Properties of relations  Reflexive  Symmetric  Transitive.
1 Partial Orderings Epp, section Introduction An equivalence relation is a relation that is reflexive, symmetric, and transitive A partial ordering.
Relations, Functions, and Matrices
Unit-III Algebraic Structures
Equivalence Relations
Relations Chapter 9.
Relation and function.
CS201: Data Structures and Discrete Mathematics I
Sungho Kang Yonsei University
Chapter 1 Introduction to the Theory of Computation
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Presentation transcript:

Logic for computer science Transparency No. 2-0 Chapter 2 Mathematical Preliminaries

mathematical preliminaries Transparency No. 2-2 Contents Relations Functions Partial orders Induction (Formal) Language Trees

mathematical preliminaries Transparency No. 2-3 Cartesian products A, B: two sets AxB (Cartesian Product of A and B) is the set of all ordered pairs { | a  A and b  B }. Examples: A= {1,2,3}, B= {4,5,6} => AxB = ? A 1,A 2,...,A n (n > 0): n sets A 1 xA 2 x...xA n = { | a i  A i }. Example: 1. A 1 ={1,2},A 2 ={a,b},A 3 ={x,y} ==> |A 1 xA 2 xA 3 | = ? 2. A 1 = {}, A 2 ={a,b} => A 1 xA 2 = ?

mathematical preliminaries Transparency No. 2-4 Binary Relation Binary relation: A,B: two sets A binary relation R between A and B is any subset of AxB. Example: If A={1,2,3}, B ={4,5,6}, then which of the following is a binary relation between A and B ? R1 = {,, } R2 = {} R3 = {1,2,3,4} R4 = {,, }

mathematical preliminaries Transparency No. 2-5 Basic terminology about relation R: a binary relation between A and B (I.e., a subset of AxB), then The domain of R: dom(R) = {x  A |  y  B s.t.  R} The range of R: range(R) ={y  B, |  x  A, s.t.,  R}  R is usually written as x R y. If A = B, then R is simply called a relation over(on) A. An n-tuple relation R among A 1,A 2,...,A n is any subset of A 1 xA 2...xA n, n is called the arity of R If A 1 =A 2 =...=A n =A => R is called an n-tuple relation (on A).

mathematical preliminaries Transparency No. 2-6 Examples about relations A = the set of All human beings = {..., 蔣中正, 蔣經國, 蔣緯國,...} the-father-of ( 父子關係 ) = { | x,y are human and x is the father of y } is a binary relation over humans. the-brother-of ( 兄弟關係 ) = { | x and y are human and x is the brother of y } So,,  the-father-of and,  the-brother-of

mathematical preliminaries Transparency No. 2-7 (Partial) Functions A relation R between A and B is functional iff, for all x  A and y,z  B, x R y and x R z implies y = z. (I.e., for each x in A, there is at most one y in B, s.t., x R y.) A partial function is a triple f= where A and B are sets and G is a functional relation between A and B. A is called the domain of f B is called the codomain of f and G is called the graph of f. Notation:1. f : A  B; 2. A= dom(f); B=Codom(f); G=graph(f) Note: Dom(f)  Dom(G) in general. For every element x ∈ A, the unique y in the range of f with (x,y)  G is denoted f(x).

mathematical preliminaries Transparency No. 2-8 (partial) functions If Dom(f) = Dom(G), (I.e., for all x in A, there is y in B, s.t., x G y), then call f a (total) function f and its graph G are usually identified. G Dom(G) range(G) or imgae(G) A=Dom(f) B=Codom(f) f is a total function iff Dom(f) = Dom(G) Note: In the following, if not stated otherwise, all functions are assumed to be total function.

mathematical preliminaries Transparency No. 2-9 Classification of (total) functions f:A  B a (partial) function; X a subset of A, Y a subset of B; then f(X) : the image of X under f = {y  B | there is x in X s.t., f(x) = y } f -1 (Y):the inverse image of Y under f = {x  A | there is y  Y s.t., f(x) = y } f is surjective(onto) iff f(A) = B f is injective(1-1) iff for each y in B, there is at most one x in A, s.t., f(x) =y. f is bijective (or a bijection) iff f is 1-1 and onto. If f is 1-1 and onto then there exists a unique function g:B  A s.t., g(y)=x iff f(x) = y. g is called the inverse of f and is denoted f -1.

mathematical preliminaries Transparency No Example: A= {1,2,3}  B= {4,5,6} Let fi =. then dom(gi) = ?; range(gi) = ? which are total functions? which are 1-1 functions? which are surjective, bijective? g1 g3 g g g4

mathematical preliminaries Transparency No Operations on relations (and functions) R  AxB; S  B x C: two relations composition of R and S: R · S = { | there is b  B s.t.,  R and  S }. Identity relation: I A = { | a  A } Converse relation: R -1 = { |  R } f:A  B; g: B  C: two functions, then g·f:A  C defined by g·f(x) = g(f(x)). Note: function and relation compositions are associative, I.e., for any function or relation f,g,h, f· (g·h) = (f·g) ·h

mathematical preliminaries Transparency No Properties of binary relations R: A binary relation on S, 1. R is reflexive iff for all x in S, x R x. 2. R is irreflexive iff for all x in S, not x R x. 3. R is symmetric iff for all x, y in S, xRy ⇒ yRx. 4. R is asymmetric iff for all x,y in S, xRy ⇒ yRx. 5. R is antisymmetric iff for all x,y in S, xRy and yRx ⇒ x=y. 6. R is transitive iff for all x,y,z in S, xRy and yRz ⇒ xRz. Graphical realization of a binary relation and its properties. xx yy ss rule: if xRy then draw an arc from x on left S to y on right S.

mathematical preliminaries Transparency No Examples The relation  on the set of natural numbers N. What properties does  satisfy ? ref. irref, or neither ? symmetric, asymmetric or antisymmetric ? transitive ? The relation  on the set of natural numbers N. The divide | relation on integers N ? x | y iff x divides y. (eg. 2 | 10, but not 3 | 10) What properties do  and | satisfy ? The BROTHER relation on males (or on all people) (x,y)  BROTHER iff x is y’s brother. The ANCESTOR relation in a family. (x,y)  ANCESTOR if x is an ancestor of y. What properties does BROTHER(ANCESTOR) have ?

mathematical preliminaries Transparency No Some special relations R: a binary relation on S 1. R is a preorder iff it is ref. and trans. 2. R is a partial order (p.o.) iff R is ref.,trans. and antisym. (usually written as  ). 3. R is a strict partial order (s.p.o) iff it is irref. and transitive. usually written <. 4. R is a total (or linear) order iff it is a partial order and every two element are comparable (i.e., for all x,y either xRy or yRx.) 5. R is an equivalence relation iff it is ref. sym. and trans. If R is a preorder (resp. po or spo) then (S,R) is called a preorder set (resp. poset, strict poset). What order sets do (N, <), (N,  ) and (N, |) belong to ?

mathematical preliminaries Transparency No Relationship between properties of relations R: a nonempty binary relation on a nonempty set S. 1. If R is ref., then it is not irref. (ref. ⇒ not irref.) 2. irref. and antisym.  asym. 3. If  is a partial order, then the relation < defined by “x < y iff x  y and x  y” is a strict partial order. 4. If <  is a strict partial order, then the relation  defined by “x  y iff x < y or x = y” is a partial order. 5. According to 3 and 4, basically there is no difference b/t partial order and strict partial order. Note: In the literature, 1. if  is given first, then x < y means x  y /\ x  y. 2. If < is given first, then x  y means x < y \/ x = y. 3. x > y means y < x; x  y means y  x.

mathematical preliminaries Transparency No Properties of ordered set (S,  ): a poset, X: a subset of S. 1. b  X is the least (or called minimum) element of X iff b  x for all x  X. 2. b  X is the greatest (or called maximum or largest) element of X iff X  b for all x  X. Least element and greatest element, if existing, is unique for any subset X of a poset (S,  ) pf: let x, y be least elements of X. Then, x  y and y  x. So by antisym. of , x = y. 3. X is a chain iff (X,R) is a linear order(, i.e., for all x, y  X, either x  y or y  x). 4. b  S is a lower bound (resp., upper bound) of X iff b  x (resp., x  b) for all x  X. Note: b may not belong to X.

mathematical preliminaries Transparency No Properties of ordered sets (S,  ) : a poset, X: a nonempty subset of S. 5. b in X is minimal in X iff there is no element less than it. i.e., there is no x ∈ X, s.t., (x < b), or “for all x, x  b ⇒ x =b.” 6. b in X is a maximal element of X iff there is no element greater then it. i.e., there is no x ∈ X, s.t., (b < x), or “for all x, b  x ⇒ x=b.” Note: 1.Every maximum element is maximal, but not the converse in general. 2. Maximal and minimal are not unique in general.

mathematical preliminaries Transparency No well-founded set and minimum conditions (S,  ) : a poset ( 偏序集 ).  is said to be well-founded ( 良基性 ) iff there is no infinite descending sequence. (i.e., there is no infinite sequence x 1,x 2,x 3,.... s.t., x 1 > x 2 > x 3 >... ). Note: x > y means y < x (i.e., y  x and y  x) if  is well-founded => (S,  ) is called a well-founded set. 2. (S,  ) is said to satisfy the minimal condition iff every nonempty subset of S has a minimal element. (S,  ): a total ordered set ( 全序集 ).  is said to be a well-ordering( 良序 ) iff every nonempty subset of S has a least (or equivalently, minimal) element. If  is well ordered, then (S,  ) is called a well-ordered set.

mathematical preliminaries Transparency No Examples of ordered sets Among the relations (N,  ), (N,  ), (N, |), (Z,  ), (Z,  ), (Z,|) and (R,  ), 1. Which are well-founded ? 2. Which are well-ordered ?

mathematical preliminaries Transparency No Equivalence of well-foundness and minimal condition (S,  ) is well-founded (w.f.) iff it satisfies the minimum conditions (m.c.). pf: scheme: (1) not w.f => not m.c. (2) not m.c. => not w.f. (1) Let x1,x2,... be any infinite sequence s.t. x1 > x2 > x3 >.... Now let X={x1,x2,...}. Then X has no minimal element. Hence, S does not satisfy m.c. (2) Let X be any nonempty subset of S w/o minimal elements. Now (*) chose arbitrarily an element a1 from X,let X1 = {x | x  X and a1 > x } (i.e. the set of elements in X < a1 ) since a1 is not minimal, X1 is nonempty and has no minimal element, too. So we can repeat the procedure (*) infinitely to find a2, X2, a3, X3,... and obtain the infinite descending sequence a1 > a2 > a3 >... So S is not w.f. Q.E.D.

mathematical preliminaries Transparency No Equivalence of w.f. and w.o. If (S,  ) is linear ordered then S is well- founded(or equ., satisfies the m.c.) iff S is well- ordered. pf: (1): w.f. => well-ordered. In total ordered set, every minimum element is a least element. x: minimal in X, let y  x be any element in X => either y < x (impossible!) or x  y. Hence x is least in X. Existence of minimum elements is implied by m.c. (2) well-ordered => w.f. Trivial. Since every nonempty subset have a least element, which is a minimal element. qed

mathematical preliminaries Transparency No Variants of Inductions Mathematical Induction: To prove a property P(n) holds for all natural number n  N, it suffices to show that (1) P(0) holds --- (base step) and (2) For all n  N, p(n) => p(n+1) --- (induction step)  P(n) in (2) is called induction hypothesis (h.p.) Well-order induction: (S,  ) a well-ordered set; P(x): a property about S. To show that P(x) holds for all x in S, it suffices to show (1) P(x) holds for the least element x of S. --- (base step) (2) for all x in S, (for all y in S y P(y)) => p(x) ---(ind. step)  (1) is a special case of (2) [i.e., (2) implies (1)]  (for all y in S y P(y)) in (2) is called the ind. hyp. of (2).

mathematical preliminaries Transparency No Variants of inductions Well-founded induction: (S,  ) a well-founded set. P(x) a property about S. w.f. induction says that to prove that P(x) holds for all x in S, it suffices to show that (1) P(x) holds for all minimal elements x of S --- base step, and (2) for all x in S, (for all y in S y P(y)) => p(x) ---ind. step  (1) is already implied by (2)  (for all y in S y P(y)) in (2) is the ind. hyp. of the proof. Facts: w.f. Ind. => well-ordered ind. => math ind. (I.e., If w.f ind. is true, then so is well-ordered ind. and if well-ordered ind. is true, then so is math. ind.)

mathematical preliminaries Transparency No relationship between types of inductions Show that w.f. Ind. => well-ordered ind. If 1. (S,  ) is any well-ordered set, and 2. for all x in S (for all y in S, y P(x)) => P(x) holds, then for all x  S, P(x) holds. Pf: Since (S,  ) is well-ordered, (S,  ) is well-founded. By condition 2, (w.f. ind and w.o. ind. have the same form) for all x in S (for all y in S, y P(x)) => P(x) holds Hence (by w.f. induction) P(x) holds for all x in S. Show that math ind. is implied by well-order ind. pf: left as an exercise.

mathematical preliminaries Transparency No Correctness of w.f. induction (S,  ) : a well-founded set. P(x) : a property about S. Then P(x) holds for all x  S, if (1) P(x) holds for all minimal elements x  S --- base step, and (2) for all x  S, (for all y  S y P(y)) = > p(x) ---ind. step pf: Assume NP = { x | x  S and P(x) is not true } is not empty. ==> Let x be any minimal element of NP. case (1): x is minimal in S. --> impossible! (violating (1) ) by (1), P(x) holds and x  NP. case (2): x is not minimal. --> impossible, either! (hence NP has no minimal element and NP is empty, ie. P(x) holds for all x in S) x not minimal ==> L = {y | y  S /\ y < x} is not empty. ==> L  NP = { } (o/w x would not be minimal in NP.) ==> (ind. hyp. holds for x, i.e., for all y  S, y p(y) is true) ==> (by (2).) p(x) holds ==> x  NP. qed

mathematical preliminaries Transparency No Definition by induction (or recursion) Consider the following ways of defining a set. 1. the set of even numbers Even = {0,2,4,...}: Initial rule : 0  Even. closure rule: if x  Even then x +2  ven. 2. The set of strings  + over an alphabets  = {a,b,c,...,z} Initial: if x  , then x   +. closure: If x   and    +, then x    The set of lists of numbers. Initial: [ ] is a (empty) list, closure: If x is number and L is a list, then [x | L] is a list.  [x | L] is the result of inserting x into the head position of L.  e.g., [ 5 | [2,3,4]] = [5,2,3,4] Problem:All definitions well-defined? What’s wrong?

mathematical preliminaries Transparency No Problems about recursive definition The above definitions are incomplete in the sense that there are multiple sets satisfy each definition Example: Let N i = {0,2,4,6,...} U { 2i+1, 2i+3,...}. Then {0,2,4,6,...} and N i (i >  all satisfy Def. 1. Among {0,2,4,6,...} and N i (i > 0), which one is our intended set ? How to overcome the incompleteness ? Relationship between {0,2,4,...} and the collection of sets satisfying the definitions? {0,2,4,...} is the least set among all sets. {0,2,4,...} is equal to the intersection of all sets. Every other set contains at least one element which is not grounded.

mathematical preliminaries Transparency No General form of inductively defining a set (or domain)  : a set, Init: a subset of  F: a set of functions on , we define a subset  of  as follows: 1. Initialization: Every element of Init is an element of . (or simply Init   ) 2. closure: If f:  n ->  in F and t 1,...,t n are members of , then so are f(t 1,...,t n ) 3. plus one of the following 3 phrases. 3.1  is the least subset of  with the above two properties. 3.2  is the intersection of all subsets of  with property 1, Only elements obtainable by a finite number of applications of rules 1 and 2 are elements of . Note: Although phrase 3. is necessary, it is usually replaced by an adv. “inductively” or “recursively” before “define”, and sometimes even totally omitted if it is understood in mind.

mathematical preliminaries Transparency No Define functions on recursively defined domains Consider the following function: Na :  +  N with Na(x) = def number of a’s in string x. Now we can define Na as follows: Initial: specify the value Na(x) of x for each x in Init = . ==> Na(a) = 1 ; Na(x) = 0 if x  a. recursion: specify the value Na(f(t 1,...,t n ) of element f(t 1,...,t n ) for each f  F and t 1,...,t n   =  +. ==> for any y   +, Na(ay) = 1 + Na(y) and Na(xy) = Na(y) if x is any symbol  a. Such kind of definitions are well defined. why ? sufficient condition: The recursively defined domain is not multi-defined. [I.e., There is exactly one way to form (or derive ) each element in the domain. ]

mathematical preliminaries Transparency No Example of a multi-defined Domain Arithmetic expression (Ar1   *) : Init: Constants a,b,c,… and variables x,y,z,… are arithmetic expressions Closure: If  and  are arithmetic expressions then so are , , ,  x  and . ambiguous arithmetic expressions: 2 – 3 x 5 ; x – y + 2 two ways to form “ 2 – 3 x 5 “: 1. 2, 3, 2-3, 5, 2-3 x , 3, 5, 3x5, 2- 3x 5. x  5 32  x 532

mathematical preliminaries Transparency No Structural induction(SI)  : an inductively defined domain P(x): a property on . To show that P(x) holds for all x in , it suffices to show Base step: P(x) holds for all x  Init. Ind. step: P(t1),...,P(tn)  P(f(t1,...,tn)) for all f  F, and for all t1,...,tn  . Example: show P(x)  “Na(x)  0” holds for all x. Base step: x  Init = (  = {a,b,c,...})  x = a => Na(x) = 1  0.  x  a => Na(x) = 0  0 Ind. step: x: any element in , y: any element in  . Assume (ind. hyp.) Na(y)  0. then  if x = a => Na(x y) = 1 + N(y)  0  if x  a => Na(x y) = N(y)  0.

mathematical preliminaries Transparency No Correctness of structural induction (SI) Structural induction is a special case of well-founded induction. Why? Let  be an inductively defined domain. We can define a (strict) partial ordering < on  as follows: [All elements of Init are minimal in <.] t i < f(t 1,...,t n ) i=1,..,n, for each f in F and for all t 1,..,t n  . moreover, if s < t and t < u then s < u for all s,t,u  . Notes: 1. < may not be a s.p.o. 2. However, if every element of  is not multi-defined, then < must be a s.p.o. Ex of multi-defined set: Even = 0  E | x + 2, x - 4  E. 3. If < is a spo, then structural ind. is just w.f. ind. on the ordered set ( , <). 4. Even if < is not a spo, SI still holds. (a more complicated ordering then < is needed to show its correctness)

mathematical preliminaries Transparency No Correctness of recursively defining a function on a recursively defined domain without ambiguous elements.  : a recursively defined domain s.t. every element has exactly one form. g:   T defined as follows: (1) Init: g(i) = c i is given explicitly for each i  Init. (2) recursion: for each operation f of arity n and for all t 1, t1,…,t n  , g(f  t ,…,t n )) = h(g(t 1 ),…,(t n )) is given in terms of g(t 1 ),..,g(t n ). Then there is exactly one function from  to T satisfying conditions (1) and (2). pf: (I) : Existence: Assume the set N = { y  D | y cannot be assigned value by (1) and (2)} is not empty. =>let x be any element minimal N.  (1) x ∉ Init.  (2) let x = f(t 1,…,t n ) for some f and some t 1,…,t n.

mathematical preliminaries Transparency No  (by ind. hyp.,) t 1,…,t n can be assigned values g(t 1 ),…,g(t n )  by closure rule x can be assigned value h(g(t 1 ),…,g(t n ).  x ∉ N, a contradiction!. (II) : Uniquess: Assume there are two distinct functions g1, g2: D  T satisfying condition (1) and (2). Let N = {y  D | g1(y) ≠ g2(y) } and let x be any minimal element  N. ⇒ (1) x ∉ Init. [since both g1(x) and g2(x) must equal to c x.]  (2) let x = f(t 1,…,t n ) for some f and some t 1,…,t n ∉ N  (g1(t 1 ),…,g1(t n )) = (g2(t 1 ),…,g2(t n ))  by closure rule g1(x) = h(g(t 1 ),…,g(t n ). = h(g(t 1 ),…,g(t n )=g2(x).  x ∉ N, a contradiction!.

mathematical preliminaries Transparency No More example: Define the set of labeled binary trees as follows:  : a set of labels = {a,b,c,..}  =  U {(, )},  * = the set of strings over . T  is a subset of  * defined inductively as follows: Init: () is a tree. closure: if x is a label, and L and R are trees, then (x L R) is a tree. Examples: (), (a ()()), ((a), (b),()), For each tree T, lf(T) = # of “(“ and lb(T) =# of labels in T; e(T) = number of empty subtrees “()”, can be defined as Init: l(()) = 1; lb(()) = 0; e(()) = 1. recursion: lf((x LR)) = 1+ l(L) + l(R) ; lb((x L R)) = 1 + lb(L) +lb(R) ; e((x L R)) = e(L) + e(R).

mathematical preliminaries Transparency No more example(cont’d) Use structural ind. to prove properties of trees. Show that for all tree T  T , P(T) = def “ lf(T) = lb(T) + e(T)” holds for all tree T. Base step: lf(()) = 1, lb(())=0, e(())=1. OK. ind. step: x: any label, L, R: any trees. assume (ind.hyp.:) lf(L) = lb(L) + e(L) and lf(R) = lb(R) + e(R), then lf((x L R)) = 1 + lf(L) + lf(R) = 1 +lb(L) +lb(R) + e(L) +e(R) e((x L R)) = e(L) +e(R) lb((x L R)) =1 + lb(L) + lb(R) ==> lf((X L R)) = lb((X L R)) + e((X L R)). qed

mathematical preliminaries Transparency No math. induction revisited Math. ind. is a special case of structural ind. why? Inductively define N={0,1,2,...}. Init: 0 is a natural number. closure: if n is a natural number, then n’ (called the successor of n, ie., n+1) is a natural number. Example of natural numbers and non natural numbers: 0, 0’, 0’’, 0’’’, unary representation of numbers. 00, 0’0, 0’’ not numbers. Now applying structural Ind. on N based on the above def. To prove p(x) holds for all natural number x, it suffices to show: Base step: P(0) Ind. step: Let x be any number, If P(x) then P(x’) This is just the math. ind.

mathematical preliminaries Transparency No More Example Let N = {0, s0,ss0,sss0,…}. Define + : N 2  N by recursion: for all x in N Basis: +(x, 0) = x, Recursion: for all y in N, +(x, y’) = +(x,y) + 1 =s. +(x,y) Prove by SI that for all x, y  N 1. x + (y + z) = (x+y) + z 2. x + y = y + x

mathematical preliminaries Transparency No Languages  : any arbitrary set (called alphabet, or set of symbols) any finite sequence of symbols in  is called a string over . Ex:  = {0, 1} => , 000, 10, 1111,... are strings over {0,1}. Concatenation of strings: x= x 1 x 2...x m ; y = y 1...y n => xy = x 1 x 2...x m y 1...y n Definitions  * is the set of all strings over .  + =  * \ {  } is the set of strings of positive length. Any subset  of  * is called a language over . Ex: {},{  }, {0,1}, {0,1}*, {0,00,000,...}, { , 10,1010,1010,...} are all languages over {0,1}.