Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

A complex system that works is invariably found to have evolved from a simple system that works.


devel / comp.lang.prolog / Re: When you are standing in front of a Formal System

SubjectAuthor
* When you are standing in front of a Formal SystemMostowski Collapse
`* When you are standing in front of a Formal SystemMostowski Collapse
 `* When you are standing in front of a Formal SystemMostowski Collapse
  `- When you are standing in front of a Formal SystemMostowski Collapse

1
Re: When you are standing in front of a Formal System

<dbaaab17-198f-4c32-abbb-cc487ad96d17n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1965&group=comp.lang.prolog#1965

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:5a82:0:b0:3e9:9419:b153 with SMTP id c2-20020ac85a82000000b003e99419b153mr511521qtc.0.1681858560211;
Tue, 18 Apr 2023 15:56:00 -0700 (PDT)
X-Received: by 2002:a81:7646:0:b0:54f:b270:5e64 with SMTP id
j6-20020a817646000000b0054fb2705e64mr841691ywk.1.1681858559857; Tue, 18 Apr
2023 15:55:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Tue, 18 Apr 2023 15:55:59 -0700 (PDT)
In-Reply-To: <9d3f03af-9efc-4a84-a816-5396c4af4c76n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <b1757712-176a-4700-8d86-de860641e521n@googlegroups.com>
<fe8b319c-2a2b-4998-882f-bf60aa17ab5cn@googlegroups.com> <af14bd22-63a1-42e9-9ff1-f651b53d5429n@googlegroups.com>
<25fe5883-51a6-48ec-9d2c-c09d7846ae26n@googlegroups.com> <9d3f03af-9efc-4a84-a816-5396c4af4c76n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dbaaab17-198f-4c32-abbb-cc487ad96d17n@googlegroups.com>
Subject: Re: When you are standing in front of a Formal System
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Tue, 18 Apr 2023 22:56:00 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Mostowski Collapse - Tue, 18 Apr 2023 22:55 UTC

To solve the communicating variables problem, you can use
shift/1 and reset/3 which are available in SWI-Prolog. They are
from the Delimited continuations addition to SWI-Prolog.

The generic approach to use shift/reset for such purposes is:

run_state(Goal, StateIn, StateOut) :-
reset(Goal, Command, Cont),
( Cont == 0 % no more commands from Goal?
-> StateOut = StateIn
; run_state_(Command, Cont, StateIn, StateOut)
).
You have to define a couple of commands and a state. Lets
say we make a simple prototype, and only model P, the
clause space as a state. Then for embedded implication:

P, A |- B
--------------
P |- A -: B

The state would go from P, to [A|P] and then back to P.
We don’t need undo/1, this is part of shift/reset anyway.

Mostowski Collapse schrieb am Freitag, 12. Februar 2021 um 10:19:25 UTC+1:
> So the big gain of formal systems compared to working inside a
> domain theory T is that formal systems can more clearly see the
> context dependency of queries A. Interestingly for queries B => C, if
> the following conditions are met:
>
> - B is a ground fact
> - C does not throw an error
> - B => C is not used with an outside Prolog cut
>
> Then B => C can be safely realized in Prolog with a Pre-CRUD and
> a Post-CRUD. Concerning the number of backtracking, the logical
> update view of Prolog might give the best results? Otherwise C
> might even unnecessarily loop?
>
> (B => C) :-
> (assertz(B); retract(B), fail), /* Pre-CRUD */
> C,
> (retract(B); assertz(B), fail). /* Post-CRUD */
>
> λProlog extends the cases where (=>)/2 can be deployed. But I wonder
> what happens when B is tabled, i.e. when we combine hypothetical
> reasoning and tabling. SWI-Prolog has incremental and/or monotonic
> tabling? Are there some show cases? Both the Pre-CRUD and the Post-CRUD
> require that the tabling not only supports assertz/1 but also retract/1.
> Mostowski Collapse schrieb am Freitag, 12. Februar 2021 um 10:17:40 UTC+1:
> > Now sombody on SWI-Prolog discourse scriveled:
> > > I was thinking the exact query repeated would not
> > produce the same result (loss of idempotency).
> >
> > If the query is issued via DQL, and if the query depends on data.
> > And if the data is DMLed. It is to expect that the query might give
> > a different result. This is normal first order predicate logic. In formal
> > semantics proof is usually denoted by “|-”, it depends on domain
> > axioms T. So that a query A is a consequence of some domain
> > axioms is denoted by:
> >
> > T |- A
> >
> > Translated to Prolog, domain axioms T can be Prolog facts and Prolog
> > rules. Now when you are inside a formal system T and A are well formed,
> > but not necessary fixed. Only if your are inside a domain axiom system T,
> > then you have some invariant. But like you change the query A to A’, by
> > issuing another query:
> >
> > T |- A'
> >
> > You might also change T to T’, or even both:
> >
> > T' |- A'
> > For example if your domain axiom model ships in harbours, and a ship has
> > changed the harbour. The ship example is used in early logic programming,
> > that adds hypothethical reasoning to Prolog, as found in λProlog. λProlog
> > has (=>)/2 for hypothetical reasoning. The use of (=>)/2 for single sided
> > unification clashes with λProlog.
> >
> > But lets put aside this clash, λProlog allows this inference:
> >
> > T, B |- C
> > ------------------ (Hypo)
> > T |- B => C
> >
> > Which allows posing hypothetical questions, i.e. what-if questions, like
> > what if a ship is in this and that harbour. The (=>)/2 is found in every
> > classical logic, it is sometimes called the deduction theorem. It blurs the
> > distinction between DML and DQL. It is also found in DES, the deductive
> > educational system written on top of SWI-Prolog and SICStus Prolog.

Re: When you are standing in front of a Formal System

<ca461401-7a24-4fe0-99df-e15a54cff658n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1966&group=comp.lang.prolog#1966

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a05:6214:162f:b0:5ef:4c58:1a57 with SMTP id e15-20020a056214162f00b005ef4c581a57mr2555228qvw.3.1681858635974;
Tue, 18 Apr 2023 15:57:15 -0700 (PDT)
X-Received: by 2002:a81:ac28:0:b0:54c:a67:90b with SMTP id k40-20020a81ac28000000b0054c0a67090bmr825598ywh.5.1681858635742;
Tue, 18 Apr 2023 15:57:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Tue, 18 Apr 2023 15:57:15 -0700 (PDT)
In-Reply-To: <dbaaab17-198f-4c32-abbb-cc487ad96d17n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <b1757712-176a-4700-8d86-de860641e521n@googlegroups.com>
<fe8b319c-2a2b-4998-882f-bf60aa17ab5cn@googlegroups.com> <af14bd22-63a1-42e9-9ff1-f651b53d5429n@googlegroups.com>
<25fe5883-51a6-48ec-9d2c-c09d7846ae26n@googlegroups.com> <9d3f03af-9efc-4a84-a816-5396c4af4c76n@googlegroups.com>
<dbaaab17-198f-4c32-abbb-cc487ad96d17n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ca461401-7a24-4fe0-99df-e15a54cff658n@googlegroups.com>
Subject: Re: When you are standing in front of a Formal System
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Tue, 18 Apr 2023 22:57:15 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 6935
 by: Mostowski Collapse - Tue, 18 Apr 2023 22:57 UTC

So lets try this:

run_state_(push(A), Cont, StateIn, StateOut) :- !,
run_state(Cont, [A|StateIn], StateOut).
run_state_(pop, Cont, [_|StateIn], StateOut) :- !,
run_state(Cont, StateIn, StateOut).
run_state_(in(A), Cont, StateIn, StateOut) :- !,
member(A, StateIn),
run_state(Cont, StateIn, StateOut).

And then we can define embedded implication (:-)/2 as
follows. And I am also adopting (+)/1 from @philzock:

:- op(1200, xfy, -:).

(A -: B) :- shift(push(A)), B, shift(pop).

(+ A) :- shift(in(A)).
Lets see whether it works:

/* First Test Case, Communicating Variables, Ok! */
?- run_state((p(X) -: +p(Y)),[],S).
X = Y,
S = [].

/* Second Test Case, Backtracking, Ok! */
?- run_state((p(1) -: p(2) -: +p(X)),[],S).
X = 2,
S = [] ;
X = 1,
S = [].

Works fine! Maybe try the problematic Example 6 and Example 7
from the Bousi~Prolog paper as well.

Mostowski Collapse schrieb am Mittwoch, 19. April 2023 um 00:56:01 UTC+2:
> To solve the communicating variables problem, you can use
> shift/1 and reset/3 which are available in SWI-Prolog. They are
> from the Delimited continuations addition to SWI-Prolog.
>
> The generic approach to use shift/reset for such purposes is:
>
> run_state(Goal, StateIn, StateOut) :-
> reset(Goal, Command, Cont),
> ( Cont == 0 % no more commands from Goal?
> -> StateOut = StateIn
> ; run_state_(Command, Cont, StateIn, StateOut)
> ).
> You have to define a couple of commands and a state. Lets
> say we make a simple prototype, and only model P, the
> clause space as a state. Then for embedded implication:
>
> P, A |- B
> --------------
> P |- A -: B
>
> The state would go from P, to [A|P] and then back to P.
> We don’t need undo/1, this is part of shift/reset anyway.
> Mostowski Collapse schrieb am Freitag, 12. Februar 2021 um 10:19:25 UTC+1:
> > So the big gain of formal systems compared to working inside a
> > domain theory T is that formal systems can more clearly see the
> > context dependency of queries A. Interestingly for queries B => C, if
> > the following conditions are met:
> >
> > - B is a ground fact
> > - C does not throw an error
> > - B => C is not used with an outside Prolog cut
> >
> > Then B => C can be safely realized in Prolog with a Pre-CRUD and
> > a Post-CRUD. Concerning the number of backtracking, the logical
> > update view of Prolog might give the best results? Otherwise C
> > might even unnecessarily loop?
> >
> > (B => C) :-
> > (assertz(B); retract(B), fail), /* Pre-CRUD */
> > C,
> > (retract(B); assertz(B), fail). /* Post-CRUD */
> >
> > λProlog extends the cases where (=>)/2 can be deployed. But I wonder
> > what happens when B is tabled, i.e. when we combine hypothetical
> > reasoning and tabling. SWI-Prolog has incremental and/or monotonic
> > tabling? Are there some show cases? Both the Pre-CRUD and the Post-CRUD
> > require that the tabling not only supports assertz/1 but also retract/1..
> > Mostowski Collapse schrieb am Freitag, 12. Februar 2021 um 10:17:40 UTC+1:
> > > Now sombody on SWI-Prolog discourse scriveled:
> > > > I was thinking the exact query repeated would not
> > > produce the same result (loss of idempotency).
> > >
> > > If the query is issued via DQL, and if the query depends on data.
> > > And if the data is DMLed. It is to expect that the query might give
> > > a different result. This is normal first order predicate logic. In formal
> > > semantics proof is usually denoted by “|-”, it depends on domain
> > > axioms T. So that a query A is a consequence of some domain
> > > axioms is denoted by:
> > >
> > > T |- A
> > >
> > > Translated to Prolog, domain axioms T can be Prolog facts and Prolog
> > > rules. Now when you are inside a formal system T and A are well formed,
> > > but not necessary fixed. Only if your are inside a domain axiom system T,
> > > then you have some invariant. But like you change the query A to A’, by
> > > issuing another query:
> > >
> > > T |- A'
> > >
> > > You might also change T to T’, or even both:
> > >
> > > T' |- A'
> > > For example if your domain axiom model ships in harbours, and a ship has
> > > changed the harbour. The ship example is used in early logic programming,
> > > that adds hypothethical reasoning to Prolog, as found in λProlog.. λProlog
> > > has (=>)/2 for hypothetical reasoning. The use of (=>)/2 for single sided
> > > unification clashes with λProlog.
> > >
> > > But lets put aside this clash, λProlog allows this inference:
> > >
> > > T, B |- C
> > > ------------------ (Hypo)
> > > T |- B => C
> > >
> > > Which allows posing hypothetical questions, i.e. what-if questions, like
> > > what if a ship is in this and that harbour. The (=>)/2 is found in every
> > > classical logic, it is sometimes called the deduction theorem. It blurs the
> > > distinction between DML and DQL. It is also found in DES, the deductive
> > > educational system written on top of SWI-Prolog and SICStus Prolog.

Re: When you are standing in front of a Formal System

<3a12c58f-8ba3-4ffd-ae29-0b4e0c7e4487n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1969&group=comp.lang.prolog#1969

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ad4:4e03:0:b0:5ab:d0c:51af with SMTP id dl3-20020ad44e03000000b005ab0d0c51afmr1342547qvb.6.1682154479034;
Sat, 22 Apr 2023 02:07:59 -0700 (PDT)
X-Received: by 2002:a81:ef06:0:b0:54d:3afc:d503 with SMTP id
o6-20020a81ef06000000b0054d3afcd503mr2721604ywm.8.1682154478714; Sat, 22 Apr
2023 02:07:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Sat, 22 Apr 2023 02:07:58 -0700 (PDT)
In-Reply-To: <ca461401-7a24-4fe0-99df-e15a54cff658n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <b1757712-176a-4700-8d86-de860641e521n@googlegroups.com>
<fe8b319c-2a2b-4998-882f-bf60aa17ab5cn@googlegroups.com> <af14bd22-63a1-42e9-9ff1-f651b53d5429n@googlegroups.com>
<25fe5883-51a6-48ec-9d2c-c09d7846ae26n@googlegroups.com> <9d3f03af-9efc-4a84-a816-5396c4af4c76n@googlegroups.com>
<dbaaab17-198f-4c32-abbb-cc487ad96d17n@googlegroups.com> <ca461401-7a24-4fe0-99df-e15a54cff658n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3a12c58f-8ba3-4ffd-ae29-0b4e0c7e4487n@googlegroups.com>
Subject: Re: When you are standing in front of a Formal System
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Sat, 22 Apr 2023 09:07:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4136
 by: Mostowski Collapse - Sat, 22 Apr 2023 09:07 UTC

To get rid of the (+)/1 operator we can
introduce a directive hypo/1:

:- op(1150, fx, hypo).

term_expansion((:- hypo(F/N)), [(:- dynamic(F/N)),
(H :- shift(in(H)))]) :-
functor(H, F, N).

Now we can run Programming with Higher-Order
Logic, Figure 3.4, as follows:

:- hypo rev/2.
rev([X|Y], Z) :- rev(Y,[X|Z]).
reverse(X,Y) :- (rev([],Y) -: rev(X,[])).

?- run_state(reverse([1,2,3],X),[],_).
X = [3, 2, 1].

Works fine!

Mostowski Collapse schrieb am Mittwoch, 19. April 2023 um 00:57:16 UTC+2:
> So lets try this:
>
> run_state_(push(A), Cont, StateIn, StateOut) :- !,
> run_state(Cont, [A|StateIn], StateOut).
> run_state_(pop, Cont, [_|StateIn], StateOut) :- !,
> run_state(Cont, StateIn, StateOut).
> run_state_(in(A), Cont, StateIn, StateOut) :- !,
> member(A, StateIn),
> run_state(Cont, StateIn, StateOut).
>
> And then we can define embedded implication (:-)/2 as
> follows. And I am also adopting (+)/1 from @philzock:
>
> :- op(1200, xfy, -:).
>
> (A -: B) :- shift(push(A)), B, shift(pop).
>
> (+ A) :- shift(in(A)).
> Lets see whether it works:
>
> /* First Test Case, Communicating Variables, Ok! */
> ?- run_state((p(X) -: +p(Y)),[],S).
> X = Y,
> S = [].
>
> /* Second Test Case, Backtracking, Ok! */
> ?- run_state((p(1) -: p(2) -: +p(X)),[],S).
> X = 2,
> S = [] ;
> X = 1,
> S = [].
>
> Works fine! Maybe try the problematic Example 6 and Example 7
> from the Bousi~Prolog paper as well.
> Mostowski Collapse schrieb am Mittwoch, 19. April 2023 um 00:56:01 UTC+2:
> > To solve the communicating variables problem, you can use
> > shift/1 and reset/3 which are available in SWI-Prolog. They are
> > from the Delimited continuations addition to SWI-Prolog.
> >
> > The generic approach to use shift/reset for such purposes is:
> >
> > run_state(Goal, StateIn, StateOut) :-
> > reset(Goal, Command, Cont),
> > ( Cont == 0 % no more commands from Goal?
> > -> StateOut = StateIn
> > ; run_state_(Command, Cont, StateIn, StateOut)
> > ).
> > You have to define a couple of commands and a state. Lets
> > say we make a simple prototype, and only model P, the
> > clause space as a state. Then for embedded implication:
> >
> > P, A |- B
> > --------------
> > P |- A -: B
> >
> > The state would go from P, to [A|P] and then back to P.
> > We don’t need undo/1, this is part of shift/reset anyway.

Re: When you are standing in front of a Formal System

<a6b3e0a5-6be4-4f62-91d3-852509b71c36n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1970&group=comp.lang.prolog#1970

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:5c02:0:b0:3e4:ed8e:6dd8 with SMTP id i2-20020ac85c02000000b003e4ed8e6dd8mr2467861qti.6.1682155784653;
Sat, 22 Apr 2023 02:29:44 -0700 (PDT)
X-Received: by 2002:a81:7611:0:b0:541:693f:cdd1 with SMTP id
r17-20020a817611000000b00541693fcdd1mr2787631ywc.9.1682155784336; Sat, 22 Apr
2023 02:29:44 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Sat, 22 Apr 2023 02:29:44 -0700 (PDT)
In-Reply-To: <3a12c58f-8ba3-4ffd-ae29-0b4e0c7e4487n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.53.44; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.53.44
References: <b1757712-176a-4700-8d86-de860641e521n@googlegroups.com>
<fe8b319c-2a2b-4998-882f-bf60aa17ab5cn@googlegroups.com> <af14bd22-63a1-42e9-9ff1-f651b53d5429n@googlegroups.com>
<25fe5883-51a6-48ec-9d2c-c09d7846ae26n@googlegroups.com> <9d3f03af-9efc-4a84-a816-5396c4af4c76n@googlegroups.com>
<dbaaab17-198f-4c32-abbb-cc487ad96d17n@googlegroups.com> <ca461401-7a24-4fe0-99df-e15a54cff658n@googlegroups.com>
<3a12c58f-8ba3-4ffd-ae29-0b4e0c7e4487n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a6b3e0a5-6be4-4f62-91d3-852509b71c36n@googlegroups.com>
Subject: Re: When you are standing in front of a Formal System
From: bursejan@gmail.com (Mostowski Collapse)
Injection-Date: Sat, 22 Apr 2023 09:29:44 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2500
 by: Mostowski Collapse - Sat, 22 Apr 2023 09:29 UTC

Trying the comp.pl from Bousi~Prolog paper, it translates me
the reverse/2 predicate, from Programming with Higher-Order
Logic, Figure 3.4, into:

rev([A|B], C, [], 0, [], D) :-
rev(B, [A|C], _, _, _, D).
rev([], A, [A], 1, [_|_], B) :-
reg(1, [A], C),
chk(C, B).

reverse(A, B, [], 2, [], C) :-
=>([1-[B]], rev(A, [], _, _, _, [D|C]), D, C).

reverse(A, B) :-
reverse(A, B, [], _, _, []).

But it cannot do the query, X doesn’t get instantiated to the result:

?- reverse([1,2,3],X).
true.

So I guess there is still a hick-up with communicating variables after
their 6-th iteration. Maybe there is somewhere a 7-th iteration?
I am refering to this paper:

Planning for an Efficient Implementation of Hypothetical Bousi~Prolog
Pascual Julián-Iranzo - Fernando Sáenz-Pérez
Submitted on 8 Aug 2021
https://arxiv.org/abs/2108.03602

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor