src/HOL/Induct/ABexp.thy
author nipkow
Thu, 05 Nov 1998 14:05:57 +0100
changeset 5802 614f2f30781a
parent 5737 31fc1d0e66d5
child 11046 b5f5942781a0
permissions -rw-r--r--
Shortened names and added new thm.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5737
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
     1
(*  Title:      HOL/Induct/ABexp.thy
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
     2
    ID:         $Id$
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
     3
    Author:     Stefan Berghofer, TU Muenchen
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
     4
    Copyright   1998  TU Muenchen
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
     5
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
     6
Arithmetic and boolean expressions
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
     7
*)
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
     8
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
     9
ABexp = Main +
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    10
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    11
datatype
5802
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    12
  'a aexp = IF ('a bexp) ('a aexp) ('a aexp)
5737
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    13
          | Sum ('a aexp) ('a aexp)
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    14
          | Diff ('a aexp) ('a aexp)
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    15
          | Var 'a
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    16
          | Num nat
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    17
and
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    18
  'a bexp = Less ('a aexp) ('a aexp)
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    19
          | And ('a bexp) ('a bexp)
5802
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    20
          | Neg ('a bexp)
5737
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    21
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    22
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    23
(** evaluation of arithmetic and boolean expressions **)
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    24
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    25
consts
5802
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    26
  evala :: ('a => nat) => 'a aexp => nat
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    27
  evalb :: ('a => nat) => 'a bexp => bool
5737
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    28
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    29
primrec
5802
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    30
  "evala env (IF b a1 a2) =
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    31
     (if evalb env b then evala env a1 else evala env a2)"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    32
  "evala env (Sum a1 a2) = evala env a1 + evala env a2"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    33
  "evala env (Diff a1 a2) = evala env a1 - evala env a2"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    34
  "evala env (Var v) = env v"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    35
  "evala env (Num n) = n"
5737
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    36
5802
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    37
  "evalb env (Less a1 a2) = (evala env a1 < evala env a2)"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    38
  "evalb env (And b1 b2) = (evalb env b1 & evalb env b2)"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    39
  "evalb env (Neg b) = (~ evalb env b)"
5737
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    40
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    41
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    42
(** substitution on arithmetic and boolean expressions **)
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    43
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    44
consts
5802
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    45
  substa :: ('a => 'b aexp) => 'a aexp => 'b aexp
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    46
  substb :: ('a => 'b aexp) => 'a bexp => 'b bexp
5737
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    47
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    48
primrec
5802
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    49
  "substa f (IF b a1 a2) =
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    50
     IF (substb f b) (substa f a1) (substa f a2)"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    51
  "substa f (Sum a1 a2) = Sum (substa f a1) (substa f a2)"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    52
  "substa f (Diff a1 a2) = Diff (substa f a1) (substa f a2)"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    53
  "substa f (Var v) = f v"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    54
  "substa f (Num n) = Num n"
5737
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    55
5802
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    56
  "substb f (Less a1 a2) = Less (substa f a1) (substa f a2)"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    57
  "substb f (And b1 b2) = And (substb f b1) (substb f b2)"
614f2f30781a Shortened names and added new thm.
nipkow
parents: 5737
diff changeset
    58
  "substb f (Neg b) = Neg (substb f b)"
5737
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    59
31fc1d0e66d5 New example for using the datatype package:
berghofe
parents:
diff changeset
    60
end