1 % ID: $Id$ |
|
2 \chapter{Sets, Functions and Relations} |
1 \chapter{Sets, Functions and Relations} |
3 |
2 |
4 Mathematics relies heavily on set theory: not just unions and intersections |
3 Mathematics relies heavily on set theory: not just unions and intersections |
5 but least fixed points and other concepts. In computer science, sets are |
4 but least fixed points and other concepts. In computer science, sets are |
6 used to formalize grammars, state transition systems, etc. The set theory |
5 used to formalize grammars, state transition systems, etc. The set theory |
631 \rulename{vimage_Compl} |
630 \rulename{vimage_Compl} |
632 \end{isabelle} |
631 \end{isabelle} |
633 |
632 |
634 |
633 |
635 \section{Relations} |
634 \section{Relations} |
636 \label{sec:Relations} |
|
637 |
635 |
638 A \textbf{relation} is a set of pairs. As such, the set operations apply |
636 A \textbf{relation} is a set of pairs. As such, the set operations apply |
639 to them. For instance, we may form the union of two relations. Other |
637 to them. For instance, we may form the union of two relations. Other |
640 primitives are defined specifically for relations. |
638 primitives are defined specifically for relations. |
641 |
639 |
726 R\ \isacharcircum\ \isadigit{0}\ =\ Id\isanewline |
724 R\ \isacharcircum\ \isadigit{0}\ =\ Id\isanewline |
727 R\ \isacharcircum\ Suc\ n\ =\ R\ O\ R\isacharcircum n |
725 R\ \isacharcircum\ Suc\ n\ =\ R\ O\ R\isacharcircum n |
728 \rulename{RelPow.relpow.simps} |
726 \rulename{RelPow.relpow.simps} |
729 \end{isabelle} |
727 \end{isabelle} |
730 |
728 |
731 The \textbf{reflexive transitive closure} of a relation is particularly |
729 The \textbf{reflexive transitive closure} of the |
732 important. It has the postfix syntax \isa{r\isacharcircum{*}}. The |
730 relation~\isa{r} is written with the |
733 construction is defined to be the least fixedpoint satisfying the |
731 postfix syntax \isa{r\isacharcircum{*}}. It is the least solution of the |
734 following equation: |
732 equation |
735 \begin{isabelle} |
733 \begin{isabelle} |
736 r\isacharcircum{*}\ =\ Id\ \isasymunion\ (r\ O\ r\isacharcircum{*}) |
734 r\isacharcircum{*}\ =\ Id\ \isasymunion\ (r\ O\ r\isacharcircum{*}) |
737 \rulename{rtrancl_unfold} |
735 \rulename{rtrancl_unfold} |
738 \end{isabelle} |
736 \end{isabelle} |
739 % |
737 % |
872 \end{isabelle} |
870 \end{isabelle} |
873 |
871 |
874 |
872 |
875 |
873 |
876 \section{Well-founded relations and induction} |
874 \section{Well-founded relations and induction} |
877 \label{sec:Well-founded} |
|
878 |
875 |
879 Induction comes in many forms, including traditional mathematical |
876 Induction comes in many forms, including traditional mathematical |
880 induction, structural induction on lists and induction on size. |
877 induction, structural induction on lists and induction on size. |
881 More general than these is induction over a well-founded relation. |
878 More general than these is induction over a well-founded relation. |
882 Such A relation expresses the notion of a terminating process. |
879 Such A relation expresses the notion of a terminating process. |
883 Intuitively, the relation~$\prec$ is \textbf{well-founded} if it admits no |
880 Intuitively, the relation~$\prec$ is \textbf{well-founded} if it admits no |
884 infinite descending chains |
881 infinite descending chains |
885 \[ \cdots \prec a@2 \prec a@1 \prec a@0. \] |
882 \[ \cdots \prec a@2 \prec a@1 \prec a@0. \] |
886 If $\prec$ is well-founded then it can be used with the \textbf{well-founded |
883 If $\prec$ is well-founded then it can be used with the well-founded |
887 induction}\indexbold{induction!well-founded}\index{well-founded |
884 induction rule: |
888 induction|see{induction, well-founded}} rule: |
|
889 \[ \infer{P(a)}{\infer*{P(x)}{[\forall y.\, y\prec x \imp P(y)]}} \] |
885 \[ \infer{P(a)}{\infer*{P(x)}{[\forall y.\, y\prec x \imp P(y)]}} \] |
890 To show $P(a)$ for a particular term~$a$, it suffices to show $P(x)$ for |
886 To show $P(a)$ for a particular term~$a$, it suffices to show $P(x)$ for |
891 arbitrary~$x$ under the assumption that $P(y)$ holds for $y\prec x$. |
887 arbitrary~$x$ under the assumption that $P(y)$ holds for $y\prec x$. |
892 Intuitively, the well-foundedness of $\prec$ ensures that the chains of |
888 Intuitively, the well-foundedness of $\prec$ ensures that the chains of |
893 reasoning are finite. For a fuller account of well-founded relations and |
889 reasoning are finite. |
894 induction see, for example, \cite{Baader-Nipkow}. |
|
895 |
890 |
896 In Isabelle, the induction rule is expressed like this: |
891 In Isabelle, the induction rule is expressed like this: |
897 \begin{isabelle} |
892 \begin{isabelle} |
898 {\isasymlbrakk}wf\ r;\ |
893 {\isasymlbrakk}wf\ r;\ |
899 {\isasymAnd}x.\ {\isasymforall}y.\ (y,x)\ \isasymin\ r\ |
894 {\isasymAnd}x.\ {\isasymforall}y.\ (y,x)\ \isasymin\ r\ |
1038 A \textbf{bisimulation} is perhaps the best-known concept defined as a |
1033 A \textbf{bisimulation} is perhaps the best-known concept defined as a |
1039 greatest fixed point. Exhibiting a bisimulation to prove the equality of |
1034 greatest fixed point. Exhibiting a bisimulation to prove the equality of |
1040 two agents in a process algebra is an example of coinduction. |
1035 two agents in a process algebra is an example of coinduction. |
1041 The coinduction rule can be strengthened in various ways; see |
1036 The coinduction rule can be strengthened in various ways; see |
1042 theory {\isa{Gfp}} for details. |
1037 theory {\isa{Gfp}} for details. |
1043 An example using the fixed point operators appears later in this |
1038 This chapter ends with a case study concerning model checking for the |
1044 chapter, in the section on computation tree logic |
1039 temporal logic CTL\@. |
1045 (\S\ref{sec:ctl-case-study}). |
|