- Inductively defined sets
- BNF

- Inductively defined functions
- Proofs by structural induction

An inductively defined set is a set where the elements are constructed by a finite number of applications of a given set of rules.

Examples:

- the set N of natural numbers is the set of elements defined by the following rules:
- 0 ∈ N
- If
*n*∈ N then*S**n*∈ N.

thus the elements of N are {0,

*S*0,*S**S*0,*S**S**S*0, …}.*S*stands for successor. You can then define 1 as*S*0, 2 as*S**S*0, and so on. - the set Σ
^{ * }of strings with characters in Σ is defined by*ε*∈ Σ^{ * }- If
*a*∈ Σ and*x*∈ Σ^{ * }then*x**a*∈ Σ^{ * }.

thus the elements of Σ

^{ * } - the set
*R**E*of regular expressions with characters in Σ is defined by*ε*∈*R**E*- ∅ ∈
*R**E* - if
*a*∈ Σ then*a*∈*R**E* - if
*r*_{1}∈*R**E*and*r*_{2}∈*R**E*then*r*_{1}*r*_{2}∈*R**E* - if
*r*_{1}∈*R**E*and*r*_{2}∈*R**E*then*r*_{1}+*r*_{2}∈*R**E* - if
*r*∈*R**E*then*r*^{ * }∈*R**E*

Compact way of writing down inductively defined sets: BNF (Backus Naur Form)

Only the name of the set and the rules are written down; they are separated by a "::=", and the rules are separated by vertical bar (∣).

Examples (from above):

*n*∈ N: : = 0∣*S**n**x*∈ Σ^{ * }: : =*ε*∣*x**a**a*∈ Σ*r*∈*R**E*: : =*ε*∣∅∣*a*∣*r*_{1}*r*_{2}∣*r*_{1}+*r*_{2}∣*r*^{ * }*a*∈ Σ

Here, the variables to the left of the ∈ indicate *metavariables*. When the same characters appear in the rules on the right-hand side of the : : = , they indicate an arbitrary element of the set being defined. For example, the *r*_{1} and *r*_{2} in the *r*_{1} + *r*_{2} rule could be arbitrary elements of the set *R**E*, but + is just the symbol + .

If *X* is an inductively defined set, you can define a function from *X* to *Y* by defining the function on each of the types of elements of *X*; i.e. for each of the rules. In the inductive rules (i.e. the ones containing the metavariable being defined), you can assume the function is already defined on the subterms.

Examples:

*a**d**d*2: N→N is given by*a**d**d*2: 0↦*S**S*0 and*a**d**d*2:*S**n*↦*S*(*a**d**d*2(*n*)).*p**l**u**s*: N × N→N given by*p**l**u**s*: (0,*n*)↦*n*and*p**l**u**s*: (*S**n*,*n*ʹ)↦*S*(*p**l**u**s*(*n*,*n*ʹ)). Note that we don't need to use induction on both of the inputs.*L*:*R**E*→2^{Σ * }*δ̂*:*Q*× Σ^{ * }→*Q*

If *X* is an inductively defined set, then you can prove statements of the form ∀ *x* ∈ *X*, *P*(*x*) by giving a separate proof for each rule. For the inductive/recursive rules (i.e. the ones containing metavariables), you can assume that *P* holds on all subexpressions of *x*.

Examples:

Proof that

*M*is correct (see homework solutions) can be simplified using structural inductionProof that every regular expression has an equivalent NFA is a structural induction proof.

A proof by structural induction on the natural numbers as defined above is the same thing as a proof by weak induction. You must prove

*P*(0) and also prove*P*(*S**n*) assuming*P*(*n*).