News for hackers. Stuff that matters.
Re:Kind: A Modern Proof Language by captainmuon on Wednesday August 11, 2021 @03:43PM (#28146759)
I don't know, for me this doesn't look enough like C (or anything familiar).

I would love a language like C# or Python where you could just put in preconditions using the expression syntax of the language, and it would try to prove it. If it can't prove it, it might ask for more facts, give a warning, or add a runtime assertion. As far as I know the only language that does this was the experimental Spec#.

I would even go further and have complex preconditions as part of the types, so you could have say a Person with field "age" < 18 is of type Minor. (I know this is tricky. The objects would be immutable, or you'd only be able to specify Person|Minor and only narrow it with an assertion, for example). Nim has something a little bit in this direction with distinct types, and integer range types.

Re:Kind: A Modern Proof Language by touisteur on Wednesday August 11, 2021 @04:04PM (#28147025)
That's exactly what Ada2012 and SPARK2014 did. You write your contracts (preconditions, postconditions, assertions, contract-cases, invariants, type predicates) in Ada syntax and you get both runtime assertions and proof depending on which tool you call (compiler or prover). You give more facts when proof fails. You can tag code as 'ghost' and it's only available for proof tools...

To be able to be a bit more 'terse' in assertions, they added quantifiers, expression functions, case- and if-expressions. Lots of small improvements to allow contracts, that are finally a boon to write simpler and clearer code.

Everything you're asking for here is available in Ada2012 and SPARK2014.

Re:Kind: A Modern Proof Language by nextaccountic on Wednesday August 11, 2021 @04:26PM (#28147301)
also what https://github.com/facebookexperimental/MIRAI does for rust: you add contracts (preconditions, postconditions, and invariants) using https://docs.rs/contracts/0.6.0/contracts/ and it checks whether they are true

here is an example using mirai and contracts:

https://github.com/facebookexperimental/MIRAI/blob/master/ex...

(note: the contracts crate can be used for verifying at runtime as well)

Re:Kind: A Modern Proof Language by touisteur on Thursday August 12, 2021 @07:14AM (#28154801)
Ah yes, the power of rust's macros.

I think there is danger in proposing 'assume' without at least trying to prove it and say you're wrong. I think in spark 'assume' is a guide, but it is checked and it is great, because footguns.

Re:Kind: A Modern Proof Language by rjbwork on Wednesday August 11, 2021 @04:29PM (#28147326)
C# has https://docs.microsoft.com/en-us/dotnet/framework/debug-trac...

But honestly it's not that great of a user experience, though it does seem to have been improved at least a little bit since the last time I used it in ~2016 or so.

Re:Kind: A Modern Proof Language by lostmsu on Monday August 16, 2021 @06:02PM (#28203507)
Code Contracts are mostly abandoned AFAIK.
Re:Kind: A Modern Proof Language by dash2 on Wednesday August 11, 2021 @08:01PM (#28149840)
I think Perl 6 aka Raku allows this, you can say something like `Person but $age < 18`.
Re:Kind: A Modern Proof Language by b2gills on Tuesday August 24, 2021 @04:15PM (#28294371)
The `but` keyword takes an instance and something to mix into it.

So you can say something like this:

    0 but True
---

Since `True` is a `Bool` it automatically creates a role that has a method `Bool` that returns `True`.

    my $role = role { method Bool { True }}
You can do that manually if you want.

    0 but role { method Bool { True }}
---

It creates a new subclass of Int and mixes in the role.

So:

    0 but True
Is roughly equivalent to:

    do {
      my constant but-true = anon role { method Bool { True }}
      my $class = anon class :: is Int does but-true {}

      $class.new( 0 )
    }
Re:Kind: A Modern Proof Language by lizmat on Friday August 13, 2021 @05:17AM (#28166964)
I think the you mean: `subset Minor of Person where *.age < 18`