```
"""{ defOK perms(0) == 1
defOK perms(n) == perms(n-1) * n  }"""
#PREMISES FOR NEXT LINE:
# PRECONDITION VERIFIED FOR CALL:

#PREMISES FOR ATTACHED PROOF, IF ANY:
# True
#PREMISES FOR NEXT LINE:
i = 0
#PREMISES FOR ATTACHED PROOF, IF ANY:
# (i == 0)
#PREMISES FOR NEXT LINE:
# (i == 0)
fac = 1
#PREMISES FOR ATTACHED PROOF, IF ANY:
# (fac == 1)
# (i == 0)
"""{ 1.OK perms(0) == 1       def
2.OK fac == 1           premise
3.OK fac == perms(0)     subst 1 2
}"""
#PREMISES FOR NEXT LINE:
# (fac == perms(0))
# INVARIANT VERIFIED ON LOOP ENTRY
while i != n :
"""{ invariant  fac == perms(i)
modifies i, fac }"""
#PREMISES FOR LOOP BODY:
# (i != n)
# (fac == perms(i))
"""{ 1.OK fac == perms(i)   premise   }"""
#PREMISES FOR NEXT LINE:
# (fac == perms(i))
i = i + 1
#PREMISES FOR ATTACHED PROOF, IF ANY:
# (i == (i_old + 1))
# (fac == perms(i_old))
"""{ 1.OK i == i_old + 1          premise
2.OK fac == perms(i_old)     premise  # from the invariant
4.OK fac == perms(i-1)       algebra 1 2
}"""
#PREMISES FOR NEXT LINE:
# (fac == perms((i - 1)))
fac = fac * i
#PREMISES FOR ATTACHED PROOF, IF ANY:
# (fac == (fac_old * i))
# (fac_old == perms((i - 1)))
"""{ 1.OK fac == fac_old * i           premise
2.OK fac_old == perms(i-1)        premise
3.OK fac == perms(i-1) * i        subst 2 1
4.OK perms(i) == perms(i-1) * i   def
5.OK fac == perms(i)              subst 4 3
}"""
#PREMISES FOR NEXT LINE:
# (fac == perms(i))
# INVARIANT VERIFIED AT END OF LOOP BODY
#PREMISES FOR NEXT LINE:
# (fac == perms(i))
# not (i != n)

"""{ 1.OK not(i != n)       premise
2.OK i == n            algebra 1
3.OK fac == perms(i)   premise
4.OK fac == perms(n)   subst 2 3
}"""
#PREMISES FOR NEXT LINE:
# (fac == perms(n))
```