Hello,
Just a small update.
Code for my PCL (Propositional Clausal Logic) and RCL (Relational Clausal Logic) theorem prover and model searcher can be found at my github:
git://github.com/mmxgn/generic-logic.git
I was hoping to finish it before giving the link, but I am going to give it anyway.
I hope the usage becomes obvious at the last lines of logic2.oz.
There are some personal life issues that will forbid me to work on it for a long time.
Πέμπτη 31 Μαΐου 2012
Πέμπτη 3 Μαΐου 2012
Propositional Clausal Logic in Oz
Okay,
Just a little update. I wanted to see how one could implement a model searcher/theorem prover in Oz. I found some very useful presentation slides for Declarative Programming by Coen De Roover at:
Just a little update. I wanted to see how one could implement a model searcher/theorem prover in Oz. I found some very useful presentation slides for Declarative Programming by Coen De Roover at:
http://prog.vub.ac.be/~cderoove/declarative_programming/Which I use as a guide for what I am trying to accomplish. Up to now, I have managed to create a PCL model searcher that can do proof by refutation using resolution. Here is some spoiler code:
% Set up a new Propositional Clausal Logic Knowledge base
PCLKB = {New KnowledgeBase init(PCL)}
% Assert some facts in it.
{List.forAll
[
[happy ':-' has_friends]
[friendly ':-' happy]
[wet ':-' rains]
[':-' wet]
]
proc {$ I}
{PCLKB assert(I)}
end
}
% Prove takes place with resolution by refutation
{List.forAll
[
[friendly ':-' has_friends]
[friendly]
[':-' rains]
]
proc {$ I}
{Browse prove(I)}
{Browse
{PCLKB prove(I $)}
}
end
}
and the necessary browser output:
prove([friendly ':-' has_friends])For the moment, I will move to relational clausal logic so I am not going to bother with fixing up and releasing the code, unless someone asks for it of course.
true
prove([friendly])
false
prove([':-' rains])
true
Τρίτη 1 Μαΐου 2012
Set of Subsets in Oz and other stuff
Hello,
I think it is time to start posting to this blog again. I will try and keep it updated with things that have more or less bothered me and other people will more likely find them in their way. These posts will mainly concern Oz and its implementation Mozart, stuff in Inductive Logic Programming, and things about Digital Music .
Generally, what are some interesting things I have been up to these last months:
i.e if we feed the following:
P.S. Is there a way to easily embed code to blogspot posts?
Edit: I just wrote a dummy Propositional Clausal Logic (PCL) model searcher in Oz. I will return to this once it's in a usable form.
I think it is time to start posting to this blog again. I will try and keep it updated with things that have more or less bothered me and other people will more likely find them in their way. These posts will mainly concern Oz and its implementation Mozart, stuff in Inductive Logic Programming, and things about Digital Music .
Generally, what are some interesting things I have been up to these last months:
- Re-factoring the code I have published with my Diploma Thesis. I am planning to re-create it at last as a pure Oz/Strasheela implementation (I have done some progress on that).
- Functional AUdio STream: Faust is a functional programming language that allows rapid development of efficient digital music instruments in C++. It allows easy implementation of VST technology instruments and effects, as well as PureData, etc.
- Fun with wavelets and music.
I am also searching for postgraduate studies in the fields of digital music/music technology.
I will generally update my blog mainly with progress on the above.
I will generally update my blog mainly with progress on the above.
To begin, I have come to the following problem in Oz:
Given a list of distinct elements L, give me a list that contains all the possible sub-lists with distinct elements of L.This could be helpful, for example if you want to, given a set S, to construct the powerset of S.
So, I have come to the following implementation. I hope someone finds that useful:
As you can see here, I implemented it using a search strategy and finite domain constraints. I will change it to a purely algorithmic one.
What do the functions do?
In order to produce the powerset, we must call SearchAllSubsets as {SearchAllSubsets L {List.length L}}.
fun {SearchSubsets L N}
{SearchAll
proc {$ Sol}
SolT in
SolT = {FD.list N 1#{List.length L}}
{FD.distinct SolT}
for K in 1..{List.length SolT}-1 do
{Nth SolT K} <: {Nth SolT K+1}
end
{FD.distribute naive SolT}
{List.map SolT fun {$ I} {Nth L I} end Sol}
end
}
end
fun {SearchAllSubsets L N}
case N of
0 then
nil|nil
else
{List.append
{SearchSubsets L N}
{SearchAllSubsets L N-1}
}
end
end
As you can see here, I implemented it using a search strategy and finite domain constraints. I will change it to a purely algorithmic one.
What do the functions do?
- {SearchSubsets L N}: Returns the subsets of L with exactly N elements. For example, given L=[a b c] and N=2 it will return [a b], [b c] and [a c].
- {SearchAllSubsets L N}: Returns the subsets of L with at most N elements. In the example above, it will return [a b], [b c] and [a c] as well as [a], [b], [c] and the empty set nil.
In order to produce the powerset, we must call SearchAllSubsets as {SearchAllSubsets L {List.length L}}.
i.e if we feed the following:
S = [a b c d]we will get in the browser window the list with 16 elements:
{Browse {SearchAllSubsets S {List.length S}}}
[[a b c d] [a b c] [a b d] [a c d] [b c d] [a b]OK, I think that is all for now. Stay tuned.
[a c] [a d] [b c] [b d] [c d] [a] [b] [c] [d] nil]
P.S. Is there a way to easily embed code to blogspot posts?
Edit: I just wrote a dummy Propositional Clausal Logic (PCL) model searcher in Oz. I will return to this once it's in a usable form.
Εγγραφή σε:
Αναρτήσεις (Atom)