[m-users.] Mercury to c# workflow?

Zoltan Somogyi zoltan.somogyi at runbox.com
Thu Jan 6 05:52:09 AEDT 2022



On Wed, 5 Jan 2022 18:42:17 +0200, David Epstein <davideps at umich.edu> wrote:
> For example, given:
> 
> mortal(X) :- man(X).
> 
> How would I dynamically (from c#) declare "man(Socrates)." and then query
> if "human(Socrates)"?

While a Prolog program allows the set of clauses in a predicate
to be altered during runtime with assert and retract, Mercury does not.
Please read section 4 of the Prolog to Mercury transition guide
for the reason why it doesn't, and the many other solutions
Mercury programmers can choose from.

Note that this has nothing to do with C#, or with pragma foreign_export.

You should also note that a fact of the form "man(Socrates)" would
in fact assert that *everyone* is a man, because

- "Socrates" starts with an upper case letter, which means it is a variable,
- any value in the declared argument type of the "man/1" predicate,
  which presumably is a type representing people, is an instance of this variable.

Zoltan.





More information about the users mailing list