Click here for more information

SAMPLE Program Examples: Logics @ Regularities




Please go to
http://sampletalk.8m.com ,
which is updated version of this homepage.
Information below is out-of-date and remains here only for keeping old links.






Build a program immediately from data processing examples




SAMPLE Language & Technology: http://www.webspawner.com/users/samplex/.

Build a program immediately from data processing examples. Program Examples


Logic Formula Transformation (shifting quantifiers)


The main clause of this program almost literally quotes a well-known formal rule from a student textbook for Mathematical Logic, along with informal constraints for application of this rule. See also next 2 programs, modifications of this one, and miscellaneous SAMPLE program examples -- for explanation of the last clauses of these programs.






% Goal:

(/\ x0)[a(x0,y)] \/ (/\ x0)[b(x0,t)] --> W..

% (here /\ denotes universal quantifier; W stands for the resulting formula)

% Program (knowledge base):

% transformation rule

(Q X)[F] \/ (Q X)[H] --> (Q X)(Q Z)([F] \/ [G]) :- X is variable,, Z is variable,, not(F contains Z),, (Z/X)[H]=[G]..

%rules for definition of logic variables

x0 is variable..

X10 is variable :- X0 is variable..


% explanation what is "contains" by example

AXB contains X..

% rules for change of variables

(Y/X)[AXM]=[AYN] :- (Y/X)[M]=[N]..

(Y/X)[A]=[A]..



Output: (/\ x0)[a(x0,y)] \/ (/\ x0)[b(x0,t)] --> (/\ x0)(/\ x10)([a(x0,y)] \/ [b(x10,t)]).


This and the next two programs demonstrate that complex algorithms for logic formula transformations may be derived just from their semiformal descriptions!


 


Inverse Logic Formula Transformation (elimination of parentheses and distribution of quantifiers).


The program is the same as the previous one, but its goal is "opposite" (W at the beginning is to be filled by the resulting formula):






% Goal

W --> (/\ x0)(/\ x10)([a(x0,y)] \/ [b(x10,t)])..

% Knowledge base:

(Q X)[F] \/ (Q X)[H] --> (Q X)(Q Z)([F] \/ [G]) :- X is variable,, Z is variable,, not(F contains Z),, (Z/X)[H]=[G]..

x0 is variable..

X10 is variable :- X0 is variable..

AXB contains X..

(Y/X)[AXM]=[AYN] :- (Y/X)[M]=[N]..

(Y/X)[A]=[A]..



Output: the same as in the previous example.


 


Logic Formula Transformation 2


In this version of the same program we use more natural description language. Rule identification (see variable R in the goal) is added. You can run these programs using special FIND ALL DECISIONS option. The programs will form words x10, x110, x1110 etc. for representation of logic variable Z under the second quantifier /\. Note that no previous parsing of the goal is required!






%Goal:

according to the rule R, the result of shifting quantifiers in the formula (/\ x0)[a(x0,y)] \/ (/\ x0)[b(x0,t)] is formula W..

% Knowledge base:

according to the rule 2a from chapter 5, the result of shifting quantifiers in the formula (Q X)[F] \/ (Q X)[H] is formula (Q X)(Q Z)([F] \/ [G]) :- X is notation for variable,, Z is notation for variable,, not(word F contains word Z),, the result of replacing X by Z in formula H is G..

x0 is notation for variable..

X10 is notation for variable :- X0 is notation for variable..

word AXB contains word X..

the result of replacing X by Y in formula AXM is AYN :- the result of replacing X by Y in formula M is N..


the result of replacing X by Y in formula A is A..



Output:

according to the rule 2a from chapter 5, the result of shifting quantifiers in the formula (/\ x0)[a(x0,y)] \/ (/\ x0)[b(x0,t)] is formula (/\ x0)(/\ x10)([a(x0,y)] \/ [b(x10,t)]).


Have you noticed already that we are programming in a natural language?!


 


Genetics: Recognition of regularities in word codes






%Possible goals:

a12zb and cz21de have inversion fragments X and Y..

axyzxyzxyzxyzb contains repetition of Z..

[##1#3#2##4#9# and |0|1|2||3|4|5||6|7|||8|9|] have common sub-sequence W..


% Knowledge base:

AXB and CYD have inversion fragments X and Y :- reverse of X is Y..

reverse of AM is NA :- reverse of M is N..

reverse of AB is BA..


AXB contains repetition of Z :- X is repetition of Z..

XX is repetition of X..

ZX is repetition of X :- Z is repetition of X..


[AXV and BXW] have common sub-sequence X S :-[V and W] have common sub-sequence S..

[A and B] have common sub-sequence ..



After running, X will match 12z, Y - z21, Z - xyzxyz, then xyz, then yzx etc., W will match sequence 1 3 4 9 and hen 1 2 4 9. This program can be used for detecting of sub-word repetitions, inversions, and other special features of symbol lines, which represent a genetic structure. Note its natural language form: it is constructed from expressions occurring in literature about genetics, without involving any special knowledge about computer programming!


SAMPLE Language & Technology: http://www.webspawner.com/users/samplex/.




Back to SAMPLE Language & Technology
Other examples: NL processing
Other examples: misc. SAMPLE programs
Metaphoric Conclusions about SAMPLE Technology

Send E-Mail to: gleibman@yahoo.com

Free Webpages This page created using the webpage creation facilities of Webspawner.
Copyright © 2001 Andrew Gleibman. All Rights Reserved