Hi all,
In ATS, I expected proof terms only to prove some properties of dynamic terms at compile-time,
but not to affect the dynamic semantics at run-time.
I think the following example should be rejected because function 'f' contains a case-expression
by proof term 'p' as a dynamic value, but the ATS2 compiler accepts it:
dataprop PROP (int) =
| case1 (1)
| case2 (2)
fn f {n : int} (p : PROP n | a : int n) : int n =
case p of
| case1 () => (println!("case1"); 1)
| case2 () => (println!("case2"); a)
implement main0 () = {
val one : int(1) = f (case1 | 1) // case1
val () = println!(one) // 1
val two : int(2) = f (case2 | 2) // case1
val () = println!(two) // 1
}
It actually runs outputting such like the comments. The case-expression seems to always match
the first clause regardless of the proof. Indeed this behavior is not affected by the proof, but
differs from what I expected and seems to break type safety.
Then my questions are:
- Is it a bug of the compiler that the example passes type-checking?
- Is there another kind of dynamic expressions that appear to be affected by a proof?
- If we reject such dynamic case-expressions by a proof as the example, can another problem arise?
Thank you.