# How to solve this error ?

22 views

### Christophe MASSON

Apr 7, 2021, 3:10:01 PMApr 7
to tlaplus
Hello,

I've a question concerning this code. Indeed this is an TLA+ algorithm that calculate x^5
in the model I've set v=8

Here is the error :
TLC threw an unexpected exception.
This was probably caused by an error in the spec or model.
See the User Output or TLC Console for clues to what happened.
The exception was a tlc2.tool.EvalException
The first argument of Assert evaluated to FALSE; the second argument was:
"Failure of assertion at line 16, column 13."

The error occurred when TLC was evaluating the nested
expressions at the following positions:
0. Line 85, column 7 to line 90, column 79 in power5
1. Line 85, column 10 to line 85, column 18 in power5
2. Line 86, column 10 to line 87, column 62 in power5

Here is my code :

------------------------------- MODULE power5 -------------------------------

EXTENDS Naturals, Integers, TLC
CONSTANTS v

(*
--algorithm power5 {
{
l0: skip;
x:= v;
l1: assert a=0 /\ b=0 /\ c=0 /\ d=0 /\ e=1 /\ f=0 /\ g=0 /\ h=5 /\ j=10 /\  k=10 /\ l=0 /\ m=20 /\ o=30 /\ p=60 /\ z=0;

l2: while(z < x){
l3: assert a=a+b+c+d+e /\ b=b+f+g+h /\ c=c+g+h /\ d=d+k /\ e=e+5 /\ f=f+l+m /\ g=g+o /\  h=h+20 /\ j=j+30 /\ k=k+20 /\ l=l+p /\ m=m+60 /\o=o+60 /\ p=p+120 /\ z=z+1;
};
l4: skip;

l5: assert a=0 /\ b=0 /\ c=0 /\ d=0 /\ e=1 /\ f=0 /\ g=0 /\ h=5 /\ i=0 /\ j=10 /\  k=10 /\ l=0 /\ m=20 /\ o=30 /\ p=60 /\  z=0
/\ aa=a /\ ab=b /\ ac=c /\ ad=d /\ ae=e /\ af=f /\ ag=g /\ ah=h /\ai=i /\ aj=j /\ ak=k /\ al=l /\ am=m /\ ao=o /\ ap=p;
l6: while(z<x){
l7: assert aa=a /\ ab=b /\ ac=c /\ ad=d /\ ae=e /\ af=f /\ ag=g /\ ah=h /\ai=i /\ aj=j /\ ak=k /\ al=l /\ am=m /\ ao=o /\ ap=p /\ a=a+b+c+d+e /\ b=b+f+g+h  /\ c=c+i+j /\ d=d+k /\ e=e+5 /\ f=f+l+m /\ g=g+o /\ i=i+o /\ h=h+20 /\ j=j+30 /\ k=k+20 /\ l=l+p /\ m=m+60 /\ o=o+60 /\ p=p+120 /\ z=z+1;
l9: skip;
l10: assert aa=a /\ ab=b /\ad=d /\ ae=e /\af=f /\ ag=g /\ ah=h /\ ai=i /\ aj=j /\ ak=k /\ al=l /\ am=m /\ ao=o /\ ap=p;
};
l11: skip;
}
}
*)
ModelError.PNG

### Andrew Helwer

Apr 7, 2021, 5:00:43 PMApr 7
to tlaplus
What do the expressions at those lines say?

### Christophe MASSON

Apr 7, 2021, 5:28:14 PMApr 7

The error on line 85 concerns the assert of l1 "Failure of assertion at line 16, column 13."

Le 7 avr. 2021 à 23:00, Andrew Helwer <andrew...@gmail.com> a écrit :

﻿What do the expressions at those lines say?
--
You received this message because you are subscribed to a topic in the Google Groups "tlaplus" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tlaplus/pGbdbsDE8nM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tlaplus+u...@googlegroups.com.

### Martin

Apr 7, 2021, 6:07:11 PMApr 7
Hello Christophe,

I was checking for Termination (deadlock disabled). In my case it's line 12
which invalidates the assertion. I have an error trace in the bottom right box
that shows the sequence of states that lead to this situation. All variables
there are assigned the defaultInitValue which seems to contradict your
assertion. In case you would like to know which conjunct was responsible, you
could also split your assertion up into multiple ones.

kind regards,
Martin
>> To unsubscribe from this group and all its topics, send an email to
>
> --
> You received this message because you are subscribed to the Google Groups
> "tlaplus" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> To view this discussion on the web visit

### Hillel Wayne

Apr 7, 2021, 6:38:43 PMApr 7

assert checks if the condition is true, and if it's false, raises an error. Are you trying to do an assignment? If so, you want  b := b+f+g+h, not assert b=b+f+g+h.

H

--
You received this message because you are subscribed to the Google Groups "tlaplus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tlaplus+u...@googlegroups.com.