src/HOL/Hoare/List_Examples.ML
author paulson
Fri, 19 Sep 1997 16:12:21 +0200
changeset 3685 5b8c0c8f576e
parent 2031 03a843f0f447
child 4089 96fba19bcbe2
permissions -rw-r--r--
Full version of TLS including session resumption, but no Oops
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1363
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
     1
goal thy
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
     2
"{x=X} \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
     3
\ y := []; \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
     4
\ WHILE x ~= [] \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
     5
\ DO { rev(x)@y = rev(X)} \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
     6
\    y := hd x # y; x := tl x \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
     7
\ END \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
     8
\{y=rev(X)}";
2031
03a843f0f447 Ran expandshort
paulson
parents: 1875
diff changeset
     9
by (hoare_tac 1);
03a843f0f447 Ran expandshort
paulson
parents: 1875
diff changeset
    10
by (asm_full_simp_tac (!simpset addsimps [neq_Nil_conv]) 1);
03a843f0f447 Ran expandshort
paulson
parents: 1875
diff changeset
    11
by (safe_tac (!claset));
03a843f0f447 Ran expandshort
paulson
parents: 1875
diff changeset
    12
by (Asm_full_simp_tac 1);
03a843f0f447 Ran expandshort
paulson
parents: 1875
diff changeset
    13
by (Asm_full_simp_tac 1);
1363
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
    14
qed "imperative_reverse";
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
    15
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
    16
goal thy
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
    17
"{x=X & y = Y} \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
    18
\ x := rev(x); \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
    19
\ WHILE x ~= [] \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
    20
\ DO { rev(x)@y = X@Y} \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
    21
\    y := hd x # y; x := tl x \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
    22
\ END \
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
    23
\{y = X@Y}";
2031
03a843f0f447 Ran expandshort
paulson
parents: 1875
diff changeset
    24
by (hoare_tac 1);
03a843f0f447 Ran expandshort
paulson
parents: 1875
diff changeset
    25
by (asm_full_simp_tac (!simpset addsimps [neq_Nil_conv]) 1);
03a843f0f447 Ran expandshort
paulson
parents: 1875
diff changeset
    26
by (safe_tac (!claset));
03a843f0f447 Ran expandshort
paulson
parents: 1875
diff changeset
    27
by (Asm_full_simp_tac 1);
03a843f0f447 Ran expandshort
paulson
parents: 1875
diff changeset
    28
by (Asm_full_simp_tac 1);
1363
7bdc4699ef4d Added List_Examples
nipkow
parents:
diff changeset
    29
qed "imperative_append";