comp.lang.ada
 help / color / mirror / Atom feed
* Ada 2012 Constraints (WRT an Ada IR)
@ 2016-11-28 23:49 Shark8
  2016-11-29  8:17 ` G.B.
                   ` (2 more replies)
  0 siblings, 3 replies; 195+ messages in thread
From: Shark8 @ 2016-11-28 23:49 UTC (permalink / raw)


So, with Ada 2012 we gained some really nice possibilities with the way to express constraints, the downside is that there's now a fairly wide range of ways to express constraints on types. Obviously these differences must be accounted for, but the are functionally equivalent, for example:

Subtype P0 is Natural range Natural'Succ(Natural'First)..Natural'Last;
Subtype P1 is Integer range 1..Integer'Last;
Subtype P2 is Integer with Static_Predicate => P2 in 1..Integer'Last or else raise Constraint_Error;
Subtype P3 is Integer with
  Static_Predicate  => P3 in 1..Integer'Last,
  Predicate_Failure => raise Constraint_Error;

Now, these should be generally the same way of writing the same thing (ie "Positive") -- though I'm not completely certain that this is the case in terms of subtle semantics (am I missing something?) -- it certainly would be convenient if they were as then we could have an IR wherein the general form of a type-constraint is uniformly handled.

Comments? Insights?


^ permalink raw reply	[flat|nested] 195+ messages in thread
* Re: Ada 2012 Constraints (WRT an Ada IR)
@ 2016-12-09 21:41 Randy Brukardt
  2016-12-09 22:32 ` Niklas Holsti
  0 siblings, 1 reply; 195+ messages in thread
From: Randy Brukardt @ 2016-12-09 21:41 UTC (permalink / raw)


[I had to break the chain of replies as the headers got so long that the 
message wouldn't post.]

"Shark8" <onewingedshark@gmail.com> wrote in message
news:8e3b18a7-1e64-40bb-8d99-66fdeba58ace@googlegroups.com...
> On Tuesday, December 6, 2016 at 4:23:55 PM UTC-7, Randy Brukardt wrote:
...
>> You seem to be assuming that it is practical to represent all kinds of
>> predicates as some sort of set. That's definitely not true; one of the
>> major
>> reasons that you can't use divide or mod in a static predicate is the
>> difficulty of representing the set. For instance, consider:
>>
>>      subtype Even is new Natural with Dynamic_Predicate => Even mod 2 =
>> 0;
>>
>> If Natural is a 64 bit type, Even is a set of 2**63 items, no two are
>> contiguous. The representation of that is going to be a problem. One
>> could
>> imagine some special case to deal with this particular case, but then
>> there
>> are many other possible predicates with this property.
>
> Just because it's represented as a set doesn't mean that the set has to be
> represented as a bit-mask. (The obvious breaking example for that
> implementation here would be a string subtype constrained to contain only
> numeric characters.)

In existing Ada implementations, sets are represented as a list of ranges.
(They come up in a number of places, including case statements and
Ada.Strings.) That's the expected implementation for any Ada set, but that
would take 2**63 items for Even.

...
>> Thus, your hypothetical IR would have to represent ranges as predicates,
>> rather than as some sort of set. But that would make it hard to do
>> operations on the IR (such as merging and check elimination).
>
> Would it though? Don't we have tools (and entire programming languages)
> built around predicate-logic?

(1) Hard /= impossible.
(2) I have no idea about tools or programming languages built around
predicate logic. Ada systems usually are built around simpler things, the
most complex being set operations. Trying to put a predicate logic prover
into a compiler optimizer sounds challenging at best. (Yes, I realize this
argument is somewhat circular.)

                               Randy.




^ permalink raw reply	[flat|nested] 195+ messages in thread
* Re: Ada 2012 Constraints (WRT an Ada IR)
@ 2016-12-13 22:45 Randy Brukardt
  0 siblings, 0 replies; 195+ messages in thread
From: Randy Brukardt @ 2016-12-13 22:45 UTC (permalink / raw)


[Too many replies again, had to break the thread to post - RLB]

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:o2po6a$1hnq$1@gioia.aioe.org...
...
>> Right, Pre aspects are *not* body!
>
> They are being executed at run time.

So are constraint checks. So what?

The specification of a subprogram needs to contain whatever it is that the
caller needs to know. That's why traditionally one puts comments in a
specification. Pre is just one formalization of what the caller needs to
know. (Caller here means both the execution-time caller - that is the
program, and the programmer caller - that is the human that writes the
program.)

The body of a subprogram contains the remainder - the part the caller does
not need to know.

The separation has nothing to do with execution or compile-time, it's just a
need-to-know. You insist on thinking that execution can somehow be separated
from compile-time, but it's something with no firm boundary. It's all just
semantics in the end (think of a just-in-time compiler for an extreme
example).

                             Randy.



^ permalink raw reply	[flat|nested] 195+ messages in thread
* Re: Ada 2012 Constraints (WRT an Ada IR)
@ 2016-12-14 22:40 Randy Brukardt
  2016-12-15  8:48 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 195+ messages in thread
From: Randy Brukardt @ 2016-12-14 22:40 UTC (permalink / raw)


[Yet again had to break the thread because the thread has gotten too long to 
reply to - RLB]

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:o2s8l1$1fef$1@gioia.aioe.org...
> On 2016-12-14 20:23, Shark8 wrote:
...
>> You are observably wrong.
>> If you supply a negative number, the body of X never executes.
>
> Of course it does. Semantically any effect of a call to X is due to X's
> body. There is nothing else there.

This is clearly false. The definition of the execution of a subprogram call
(RM 6.4(10/2)) specifically says that the parameter associations are
evaluated before the subprogram body is executed. 6.4.1 says that evaluation
of the parameter associations include the conversion to the formal subtype -
that conversion does the check that raises Constraint_Error.

One of the reasons that we get into these extended arguments is that you
insist on inventing a model of semantics which is different than Ada's. So
most of us discuss things as they are, and you are discussing something
totally different but using the same terminology. No wonder most of us are
confused by what you say.

                                                   Randy.




^ permalink raw reply	[flat|nested] 195+ messages in thread
* Re: Ada 2012 Constraints (WRT an Ada IR)
@ 2016-12-21 22:03 Randy Brukardt
  2016-12-21 23:02 ` Shark8
  0 siblings, 1 reply; 195+ messages in thread
From: Randy Brukardt @ 2016-12-21 22:03 UTC (permalink / raw)


[Breaking the thread yet again because of too many replies. Sorry.]

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:o3e8nc$593$1@gioia.aioe.org...
> On 2016-12-21 01:59, Randy Brukardt wrote:
...
>> One certainly can reason about it.
>
> You can tell nothing about such subsets, they are general case subsets.

I suspect that most mathematicians would be surprised to hear that. :-)

> They are worse than that, if the constraint is allowed to use non-local
> dynamic Boolean functions. That would produce non-sets.

As I clearly said before, static_prediates require very restricted
expressions that correspond to a compile-time known set. No dynamic anything
is allowed (nor are any function calls), which should be obvious from the
name alone.

                                   Randy.





^ permalink raw reply	[flat|nested] 195+ messages in thread
* Re: Ada 2012 Constraints (WRT an Ada IR)
@ 2016-12-21 22:12 Randy Brukardt
  0 siblings, 0 replies; 195+ messages in thread
From: Randy Brukardt @ 2016-12-21 22:12 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:o3erdj$169p$1@gioia.aioe.org...
...
> When predicate is not a complete function of the argument, e.g.
>
>    P (x) = (Integer (Clock - Epoch) mod 2) = 1

Complete straw man -- this isn't legal for a static predicate, which is the
case in question.

It's legal for a dynamic predicate, but that's just an assertion, no more,
no less, and not the topic of this thread in any case.

Static and dynamic predicates are completely different things, especially in
terms of the reasoning that you can apply to them. I think it's evil that
GNAT allows confusing them by just calling the thing a "predicate", on top
of which that it is not portable.

                              Randy.




^ permalink raw reply	[flat|nested] 195+ messages in thread

end of thread, other threads:[~2016-12-22 10:16 UTC | newest]

Thread overview: 195+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-28 23:49 Ada 2012 Constraints (WRT an Ada IR) Shark8
2016-11-29  8:17 ` G.B.
2016-11-29 20:32   ` Shark8
2016-11-29 20:44     ` Dmitry A. Kazakov
2016-11-29 20:51       ` Shark8
2016-11-29 21:06         ` Dmitry A. Kazakov
2016-11-29 22:59           ` Shark8
2016-11-30  8:31             ` Dmitry A. Kazakov
2016-11-30 18:28               ` Shark8
2016-11-30 20:26                 ` Niklas Holsti
2016-12-01  0:16                   ` Shark8
2016-12-01 22:15                     ` Randy Brukardt
2016-11-30 20:45                 ` Dmitry A. Kazakov
2016-12-01  0:58                   ` Shark8
2016-12-01  8:55                     ` Dmitry A. Kazakov
2016-12-01 22:26                       ` Randy Brukardt
2016-12-02 16:21                         ` Dmitry A. Kazakov
2016-12-02 19:15                           ` Randy Brukardt
2016-12-03 10:21                             ` Dmitry A. Kazakov
2016-12-02 19:50                           ` G.B.
2016-12-03 10:23                             ` Dmitry A. Kazakov
2016-12-03 14:02                               ` G.B.
2016-12-03 16:26                                 ` Dmitry A. Kazakov
2016-12-04 15:28                                   ` Robert Eachus
2016-12-05  8:41                                     ` Stefan.Lucks
2016-12-05  8:58                                       ` Dmitry A. Kazakov
2016-12-05 11:09                                         ` Simon Wright
2016-12-05 18:42                                           ` Shark8
2016-12-05 22:13                                             ` Dmitry A. Kazakov
2016-12-06 20:51                                               ` Shark8
2016-12-06 21:07                                                 ` Dmitry A. Kazakov
2016-12-06 21:44                                                   ` Shark8
2016-12-06 23:23                                                     ` Randy Brukardt
2016-12-07 22:42                                                       ` Shark8
2016-12-07  1:08                                                     ` Dennis Lee Bieber
2016-12-07  6:36                                                       ` Niklas Holsti
2016-12-07 13:10                                                         ` Dennis Lee Bieber
2016-12-07 22:55                                                           ` Brian Drummond
2016-12-08  2:44                                                         ` Shark8
2016-12-07 10:04                                                       ` G.B.
2016-12-07 10:14                                                         ` G.B.
2016-12-07 10:51                                                         ` J-P. Rosen
2016-12-08 18:33                                                           ` G.B.
2016-12-09  8:26                                                             ` J-P. Rosen
2016-12-09  8:56                                                               ` G.B.
2016-12-10 15:13                                                                 ` Jacob Sparre Andersen
2016-12-11 19:50                                                                   ` Shark8
2016-12-05 22:07                                           ` Dmitry A. Kazakov
2016-12-06 23:09                                             ` Randy Brukardt
2016-12-07 10:03                                               ` Dmitry A. Kazakov
2016-12-07 22:37                                                 ` Randy Brukardt
2016-12-08  8:46                                                   ` Dmitry A. Kazakov
2016-12-10 15:24                                               ` Jacob Sparre Andersen
2016-12-09  9:12                                           ` Robert Eachus
2016-12-05 19:22                                         ` G.B.
2016-12-05 22:18                                           ` Dmitry A. Kazakov
2016-12-05 22:12                                         ` Randy Brukardt
2016-12-05 22:26                                           ` Dmitry A. Kazakov
2016-12-06  9:29                                             ` Simon Wright
2016-12-06 10:01                                               ` Dmitry A. Kazakov
2016-12-06 23:15                                             ` Randy Brukardt
2016-12-07 10:20                                               ` Dmitry A. Kazakov
2016-12-07 22:26                                                 ` Randy Brukardt
2016-12-08  8:57                                                   ` Dmitry A. Kazakov
2016-12-08  9:42                                                     ` G.B.
2016-12-08 10:03                                                       ` Dmitry A. Kazakov
2016-12-08 18:35                                                         ` G.B.
2016-12-09  9:38                                                           ` Dmitry A. Kazakov
2016-12-11 11:21                                                             ` G.B.
2016-12-11 12:28                                                               ` Dmitry A. Kazakov
2016-12-11 13:31                                                                 ` G.B.
2016-12-11 15:40                                                                   ` Dmitry A. Kazakov
2016-12-11 20:51                                                                     ` G.B.
2016-12-12  8:27                                                                       ` Dmitry A. Kazakov
2016-12-12 15:31                                                                         ` G.B.
2016-12-12 17:39                                                                           ` Dmitry A. Kazakov
2016-12-12 18:55                                                                             ` G.B.
2016-12-12 20:53                                                                               ` Dmitry A. Kazakov
2016-12-13  7:15                                                                                 ` G.B.
2016-12-13  8:27                                                                                   ` Dmitry A. Kazakov
2016-12-13 10:39                                                                                     ` G.B.
2016-12-13 11:19                                                                                       ` Dmitry A. Kazakov
2016-12-13 16:59                                                                                         ` G.B.
2016-12-13 21:11                                                                                           ` Dmitry A. Kazakov
2016-12-13 22:13                                                                                             ` Shark8
2016-12-14  8:42                                                                                               ` Dmitry A. Kazakov
2016-12-14 11:04                                                                                                 ` G.B.
2016-12-14 11:25                                                                                                   ` Dmitry A. Kazakov
2016-12-14 12:44                                                                                                     ` G.B.
2016-12-14 12:52                                                                                                       ` Dmitry A. Kazakov
2016-12-14 16:31                                                                                                         ` G.B.
2016-12-14 16:52                                                                                                           ` Dmitry A. Kazakov
2016-12-14 18:14                                                                                                             ` G.B.
2016-12-14 12:05                                                                                                 ` G.B.
2016-12-14 19:23                                                                                                 ` Shark8
2016-12-14 20:04                                                                                                   ` Dmitry A. Kazakov
2016-12-14 21:46                                                                                                     ` Shark8
2016-12-15  8:41                                                                                                       ` Dmitry A. Kazakov
2016-12-15 10:31                                                                                                         ` G.B.
2016-12-15 13:17                                                                                                           ` Dmitry A. Kazakov
2016-12-15 13:27                                                                                                             ` Dmitry A. Kazakov
2016-12-15 19:50                                                                                                             ` G.B.
2016-12-16 10:04                                                                                                               ` Dmitry A. Kazakov
2016-12-16 11:48                                                                                                                 ` G.B.
2016-12-16 12:56                                                                                                                   ` Stefan.Lucks
2016-12-16 19:59                                                                                                                     ` Randy Brukardt
2016-12-16 20:35                                                                                                                     ` G.B.
2016-12-17  9:33                                                                                                                       ` Stefan.Lucks
2016-12-19 22:57                                                                                                                         ` Randy Brukardt
2016-12-16 13:24                                                                                                                   ` Dmitry A. Kazakov
2016-12-15 14:34                                                                                                         ` Shark8
2016-12-15 14:53                                                                                                           ` Dmitry A. Kazakov
2016-12-15 22:34                                                                                                             ` Shark8
2016-12-16  8:28                                                                                                               ` Dmitry A. Kazakov
2016-12-17  3:46                                                                                                                 ` Shark8
2016-12-14 12:21                                                                                             ` G.B.
2016-12-14 12:55                                                                                               ` Dmitry A. Kazakov
2016-12-14 16:21                                                                                                 ` G.B.
2016-12-14 16:55                                                                                                   ` Dmitry A. Kazakov
2016-12-14 18:55                                                                                                     ` G.B.
2016-12-13 18:25                                                                                         ` Shark8
2016-12-13 21:11                                                                                           ` Dmitry A. Kazakov
2016-12-13 22:32                                                                                             ` Shark8
2016-12-14  8:54                                                                                               ` Dmitry A. Kazakov
2016-12-14 22:53                                                                                                 ` Randy Brukardt
2016-12-15  8:44                                                                                                   ` Dmitry A. Kazakov
2016-12-15 22:19                                                                                                     ` Randy Brukardt
2016-12-16  8:38                                                                                                       ` Dmitry A. Kazakov
2016-12-16 19:51                                                                                                         ` Randy Brukardt
2016-12-17  9:13                                                                                                           ` Dmitry A. Kazakov
2016-12-19 22:33                                                                                                             ` Randy Brukardt
2016-12-20 11:00                                                                                                               ` Dmitry A. Kazakov
2016-12-21  0:54                                                                                                                 ` Shark8
2016-12-21  0:59                                                                                                                 ` Randy Brukardt
2016-12-21 15:56                                                                                                                   ` Dmitry A. Kazakov
2016-12-21 18:26                                                                                                                     ` G.B.
2016-12-21 21:15                                                                                                                       ` Dmitry A. Kazakov
2016-12-22  9:54                                                                                                                         ` G.B.
2016-12-22 10:16                                                                                                                           ` Dmitry A. Kazakov
2016-12-14 11:46                                                                                             ` G.B.
2016-12-12 19:48                                                                             ` Shark8
2016-12-12 20:46                                                                               ` Dmitry A. Kazakov
2016-12-12 21:33                                                                                 ` Shark8
2016-12-13  8:28                                                                                   ` Dmitry A. Kazakov
2016-12-13 18:53                                                                                     ` Shark8
2016-12-13 21:11                                                                                       ` Dmitry A. Kazakov
2016-12-13 22:16                                                                                         ` Shark8
2016-12-14  9:00                                                                                           ` Dmitry A. Kazakov
2016-12-11 23:58                                                                   ` Paul Rubin
2016-12-12  8:33                                                                     ` Dmitry A. Kazakov
2016-12-12 15:23                                                                       ` G.B.
2016-12-12 15:51                                                                         ` G.B.
2016-12-09 21:46                                                     ` Randy Brukardt
2016-12-13 11:56                                         ` Alejandro R. Mosteo
2016-12-13 15:02                                           ` Dmitry A. Kazakov
2016-12-13 17:38                                             ` Alejandro R. Mosteo
2016-12-05 22:06                                       ` Randy Brukardt
2016-11-29 17:53 ` Niklas Holsti
2016-11-29 18:21   ` Dmitry A. Kazakov
2016-11-29 20:45   ` Shark8
2016-11-30  0:03     ` Randy Brukardt
2016-11-30  0:59       ` Shark8
2016-12-01 10:33   ` AdaMagica
2016-11-29 23:52 ` Randy Brukardt
2016-11-30  1:24   ` Shark8
2016-11-30 22:12     ` Randy Brukardt
2016-11-30  1:29   ` Shark8
2016-11-30 22:17     ` Randy Brukardt
2016-12-01  1:21       ` Shark8
2016-12-01 22:07         ` Randy Brukardt
2016-12-01 10:06   ` AdaMagica
  -- strict thread matches above, loose matches on Subject: below --
2016-12-09 21:41 Randy Brukardt
2016-12-09 22:32 ` Niklas Holsti
2016-12-13  0:41   ` Randy Brukardt
2016-12-13  2:34     ` Shark8
2016-12-13 22:35       ` Randy Brukardt
2016-12-14  0:38         ` Shark8
2016-12-13 20:45     ` Niklas Holsti
2016-12-13 23:19       ` Randy Brukardt
2016-12-14  0:53         ` Shark8
2016-12-14 22:22           ` Randy Brukardt
2016-12-13 22:45 Randy Brukardt
2016-12-14 22:40 Randy Brukardt
2016-12-15  8:48 ` Dmitry A. Kazakov
2016-12-15 22:24   ` Randy Brukardt
2016-12-16  8:40     ` Dmitry A. Kazakov
2016-12-16 19:46       ` Randy Brukardt
2016-12-16 20:14         ` Dmitry A. Kazakov
2016-12-19 22:52           ` Randy Brukardt
2016-12-20 10:59             ` Dmitry A. Kazakov
2016-12-21  0:50               ` Randy Brukardt
2016-12-21 15:56                 ` Dmitry A. Kazakov
2016-12-21 22:03 Randy Brukardt
2016-12-21 23:02 ` Shark8
2016-12-21 22:12 Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox