src/HOL/ex/Factorization.thy
author wenzelm
Thu, 29 Jun 2000 22:31:53 +0200
changeset 9195 29f1e53f9937
parent 8353 57a163920480
permissions -rw-r--r--
fixed is_semicolon (keyword instead of command!);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8353
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
     1
(*  Title:      HOL/ex/Factorization.thy
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
     2
    ID:         $Id$
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
     3
    Author:     Thomas Marthedal Rasmussen
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
     4
    Copyright   2000  University of Cambridge
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
     5
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
     6
Fundamental Theorem of Arithmetic (unique factorization into primes)
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
     7
*)
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
     8
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
     9
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    10
Factorization = Primes + Perm +
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    11
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    12
consts
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    13
  primel  :: nat list => bool 
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    14
  nondec  :: nat list => bool 
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    15
  prod    :: nat list => nat
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    16
  oinsert :: [nat, nat list] => nat list
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    17
  sort    :: nat list => nat list
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    18
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    19
defs
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    20
  primel_def "primel xs == set xs <= prime"
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    21
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    22
primrec
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    23
  "nondec []     = True"
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    24
  "nondec (x#xs) = (case xs of [] => True | y#ys => x<=y & nondec xs)"
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    25
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    26
primrec
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    27
  "prod []     = 1"
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    28
  "prod (x#xs) = x * prod xs"
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    29
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    30
primrec
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    31
  "oinsert x []     = [x]"
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    32
  "oinsert x (y#ys) = (if x<=y then x#y#ys else y#oinsert x ys)"
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    33
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    34
primrec
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    35
  "sort []     = []"
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    36
  "sort (x#xs) = oinsert x (sort xs)"  
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    37
57a163920480 new theory ex/Factorization
paulson
parents:
diff changeset
    38
end