Liste des Groupes | Revenir à cl c++ |
On Mon, 2024-12-09 at 09:35 -0800, Tim Rentsch wrote:(I think usually one might call that "compiled FSM",wij <wyniijj5@gmail.com> writes:>
>Because I said: C++ is the best language to model general>
problems. So it is.
>
Almost all are logical propositions. Except those few keywords,
such programwon't be recognized as a C++ program, instead of some
kind of declarative language.
>
Zebra puzzle is an interesting programing exercise because it is
not too easy and also not too difficult.
>
------------
/* Copyright is licensed by GNU LGPL, see file COPYING. by I.J.Wang 2023
>
Example of solving the zebra puzzle by using propositional logic.
Zebra Puzzle https://en.wikipedia.org/wiki/Zebra_Puzzle
>
[...]
*/
#include <Wy.stdio.h>
#include <Sc/PropExpr.h>
>
using namespace Wy;
using namespace Sc;
>
[...]
You're asking a question that cannot be answered because much or
most of the program is in the two include files, which are not
shown.
>
As a general rule, when posting code there should be enough posted
so that readers can at least compile it. In cases like the program
asked about here, what is posted should be enough to both compile
the program and run the generated executable.
I thought nobody will be interested with the implement, and what is shown
should be enough for the moment. The include files refer to two separate
libraries. I had just updated libsc to save 'unupdate' explanations.
https://sourceforge.net/projects/cscall/
https://sourceforge.net/projects/symbcomp/
>
The Zebra Puzzle program has two version, a_puzzle_21.cpp (has shown) takes too
long to complete. a_puzzle_2.cpp (736 lines, too long to post, I thought) is
the realistic one written in way I feel just solving the prolem is enough.
>
-------------------
[]$ make a_puzzle_p2
[]$ ./a_puzzle_p2
....
(3,Red,Englishman,Milk,OldGold,Snails)
(0,Green,Japanese,Coffee,Parliament,Zebra)
(1,Yellow,Norwegian,-,Kools,Fox)
(0,Ivory,Spaniard,OrangeJuice,LuckyStrike,Dog)
(2,Blue,Ukrainian,Tea,Chesterfield,Horse)
....
>
Repeatedly dumping the same thing says there is only one answer.
Ans: Japanese owns the Zebra.
Norwegian drinks water (only one possibility left)
---------------------
>
My whole point is that C++(and other programing languages, but less optimal,IMO)
could be a languge of mathmatics/logic, nearly the base of formal knowledges (so
don't make it too arbitrarily like a commercial product. Anyway, C++ is created
'for fun', a mathmatician's fun).
In short and roughly, inference is a kind of manipulation of model (I did not
predict what anyone's brain can do, human brain can create model)
We already use simulators to predict things, simulation is a kind of inference
based on all the 'pure' theories we presumed must be correct or 'tautologic' (
olcott's word).
[Snippet from README_en]
3. Theory is 'fabricated' after-events, starting entirely from current
theory totally misplaces the goal and the problem.
...
>
>
Les messages affichés proviennent d'usenet.