Article AMI_4, MML version 4.99.1005

:: AMI_4:funcnot 1 => AMI_4:func 1
definition
  let a1 be natural set;
  let a2 be Element of the Instructions of SCM;
  redefine func a1 .--> a2 -> finite programmed Element of sproduct the Object-Kind of SCM;
end;

:: AMI_4:funcnot 2 => AMI_4:func 2
definition
  func Euclide-Algorithm -> finite programmed Element of sproduct the Object-Kind of SCM equals
    (0 .--> ((dl. 2) := dl. 1)) +* ((1 .--> Divide(dl. 0,dl. 1)) +* ((2 .--> ((dl. 0) := dl. 2)) +* ((3 .--> ((dl. 1) >0_goto il. 0)) +* (4 .--> halt SCM))));
end;

:: AMI_4:def 1
theorem
Euclide-Algorithm = (0 .--> ((dl. 2) := dl. 1)) +* ((1 .--> Divide(dl. 0,dl. 1)) +* ((2 .--> ((dl. 0) := dl. 2)) +* ((3 .--> ((dl. 1) >0_goto il. 0)) +* (4 .--> halt SCM))));

:: AMI_4:th 4
theorem
proj1 Euclide-Algorithm = 5;

:: AMI_4:th 5
theorem
for b1 being Element of product the Object-Kind of SCM
   st Euclide-Algorithm c= b1
for b2 being Element of NAT
      st IC Computation(b1,b2) = 0
   holds IC Computation(b1,b2 + 1) = 1 &
    (Computation(b1,b2 + 1)) . dl. 0 = (Computation(b1,b2)) . dl. 0 &
    (Computation(b1,b2 + 1)) . dl. 1 = (Computation(b1,b2)) . dl. 1 &
    (Computation(b1,b2 + 1)) . dl. 2 = (Computation(b1,b2)) . dl. 1;

:: AMI_4:th 6
theorem
for b1 being Element of product the Object-Kind of SCM
   st Euclide-Algorithm c= b1
for b2 being Element of NAT
      st IC Computation(b1,b2) = 1
   holds IC Computation(b1,b2 + 1) = 2 &
    (Computation(b1,b2 + 1)) . dl. 0 = ((Computation(b1,b2)) . dl. 0) div ((Computation(b1,b2)) . dl. 1) &
    (Computation(b1,b2 + 1)) . dl. 1 = ((Computation(b1,b2)) . dl. 0) mod ((Computation(b1,b2)) . dl. 1) &
    (Computation(b1,b2 + 1)) . dl. 2 = (Computation(b1,b2)) . dl. 2;

:: AMI_4:th 7
theorem
for b1 being Element of product the Object-Kind of SCM
   st Euclide-Algorithm c= b1
for b2 being Element of NAT
      st IC Computation(b1,b2) = 2
   holds IC Computation(b1,b2 + 1) = 3 &
    (Computation(b1,b2 + 1)) . dl. 0 = (Computation(b1,b2)) . dl. 2 &
    (Computation(b1,b2 + 1)) . dl. 1 = (Computation(b1,b2)) . dl. 1 &
    (Computation(b1,b2 + 1)) . dl. 2 = (Computation(b1,b2)) . dl. 2;

:: AMI_4:th 8
theorem
for b1 being Element of product the Object-Kind of SCM
   st Euclide-Algorithm c= b1
for b2 being Element of NAT
      st IC Computation(b1,b2) = 3
   holds ((Computation(b1,b2)) . dl. 1 <= 0 or IC Computation(b1,b2 + 1) = 0) &
    ((Computation(b1,b2)) . dl. 1 <= 0 implies IC Computation(b1,b2 + 1) = 4) &
    (Computation(b1,b2 + 1)) . dl. 0 = (Computation(b1,b2)) . dl. 0 &
    (Computation(b1,b2 + 1)) . dl. 1 = (Computation(b1,b2)) . dl. 1;

:: AMI_4:th 9
theorem
for b1 being Element of product the Object-Kind of SCM
   st Euclide-Algorithm c= b1
for b2, b3 being Element of NAT
      st IC Computation(b1,b2) = 4
   holds Computation(b1,b2 + b3) = Computation(b1,b2);

:: AMI_4:th 10
theorem
for b1 being Element of product the Object-Kind of SCM
   st b1 starts_at 0 & Euclide-Algorithm c= b1
for b2, b3 being integer set
      st b1 . dl. 0 = b2 & b1 . dl. 1 = b3 & 0 < b2 & 0 < b3
   holds (Result b1) . dl. 0 = b2 gcd b3;

:: AMI_4:funcnot 3 => AMI_4:func 3
definition
  func Euclide-Function -> Function-like Relation of FinPartSt SCM,FinPartSt SCM means
    for b1, b2 being finite Element of sproduct the Object-Kind of SCM holds
       [b1,b2] in it
    iff
       ex b3, b4 being integer set st
          0 < b3 & 0 < b4 & b1 = (dl. 0,dl. 1)-->(b3,b4) & b2 = (dl. 0) .--> (b3 gcd b4);
end;

:: AMI_4:def 2
theorem
for b1 being Function-like Relation of FinPartSt SCM,FinPartSt SCM holds
      b1 = Euclide-Function
   iff
      for b2, b3 being finite Element of sproduct the Object-Kind of SCM holds
         [b2,b3] in b1
      iff
         ex b4, b5 being integer set st
            0 < b4 & 0 < b5 & b2 = (dl. 0,dl. 1)-->(b4,b5) & b3 = (dl. 0) .--> (b4 gcd b5);

:: AMI_4:th 11
theorem
for b1 being set holds
      b1 in proj1 Euclide-Function
   iff
      ex b2, b3 being integer set st
         0 < b2 & 0 < b3 & b1 = (dl. 0,dl. 1)-->(b2,b3);

:: AMI_4:th 12
theorem
for b1, b2 being integer set
      st 0 < b1 & 0 < b2
   holds Euclide-Function . ((dl. 0,dl. 1)-->(b1,b2)) = (dl. 0) .--> (b1 gcd b2);

:: AMI_4:th 13
theorem
(Start-At il. 0) +* Euclide-Algorithm computes Euclide-Function;