Philosophy

==Description==
Green's philosophy algorithms are an on-going project including Pedagogy so far.  They are in either Prolog or List Prolog, a programming language Green wrote.
The Philosophy Repository includes the following algorithms:
* plagiarism_checker.pl - Checks a file against a folder of sources, and returns the percentage of sentences with >=5 words with greater than 80% of the same words as another sentence.
* source_tagger2.pl - Allows entry of multiple tags for a text and reference, and querying the existing entries for multiple tags.
* true_vs_good.pl - Randomly generates a bar chart depicting "good", as against the constantly increasing "true" graph.
* ray_ratio.pl - Finds the ray ratio on two surfaces.
* 1. Pedagogy - Two Uses - Write Original Algorithms and Arguments.txt - contains algorithms that count duplicate lines, split a string into sentences, perform modus ponens, count a type of item, append two items, test two items are equal, test a number is a number, recursively choose the lesser of two numbers, get item N, demonstrate commutativity, demonstrate associativity, find the length of a list, optimise (replace) two numbers if their difference is the same as another pair of numbers, find a member of a list, subtract a list, find a substring, intersection, delete, conjunction, sum, greater than, maximum, sort and disjunction.
* 2 onwards Pedagogy Two Uses - Examples, Descriptions and Algorithms.txt - identify different writers, intersection, ethically assess 1 and 2
* pedagogy_lineup_pl.txt - tests pedagogy time points.
* meniscus_pl.txt - calculates a meniscus height
* vetusia - a single, multiple level, self-running maze and user-interface for a text-based adventure game set in a rainforest with the aim to find the crystal statuette.
* cc2fire.pl - Chemical Cascade demonstrates the fire chemical chain reaction in a room.
* quizmaze.pl - Generates a question in a maze room game.
* orienteering.pl - Finds the orientation and distance between points to finish an orienteering game.
=== Minimise DFA ===
* Minimise DFA deletes duplicate nodes in a List Prolog DFA and renames variables to replace deleted variables.
* Optimise DFA deletes unit nodes (a-->b , where there is a single variable on the right-hand side) and moves other nodes up.
=== Strings to Grammar ===
* Strings to Grammar converts a list of strings to a context-free grammar. It achieves this with the following algorithm.
* Example usage: strings_to_grammar(["[a,b]", "[a,c]"],G),writeln1(G).
* Output: G=[[[n, a1], "->", [[a], [[n, a2]]]], [[n, a2], "->", [[b]]], [[n, a2], "->", [[c]]]]
* The tmp.pl file contains the grammar in Prolog form: a1-->[a], a2. a2-->[b]. a2-->[c].
* group_non_lists1 - groups characters between brackets, and external characters into lists to find recursive structures in
*process_terms (including try and Find Lists) - finds recursive structures in sublists and the whole list
*decision_tree - converts a list of recursive structures into a single recursive structure
*find_g - converts a recursive structure into a grammar
*minimise_alg - deletes duplicate nodes
*optimise_alg - deletes unnecessary clauses 
* Find Lists finds recursive structures in lists, for example:
* find_lists3a([1,2,3,2,3,1,2,3,2,3],L). L = [[r, [1, [r, [2, 3]]]]]
* In this example, [r,_] denotes a recursive or repeating structure and [o,_] denotes an optional, or skippable structure. In addition, [nd,_] denotes non-deterministic or branching points in decision trees.
* Find Lists searches for repeating units in a list up to the (n/2)th item of a list.
* Find Grammar recursively converts the recursive expression and its parts into a set of grammars,
* Check Grammar verifies grammars by substituting strings back into grammars.
* Grammars may generate multiples of all parts to form strings they can parse.
* Strings to Grammar takes terms as strings as input and verifies this input with grammars by parsing it.
* To convert ordinary strings:
** Change e.g. "[1,2,3,2,3,1,2,3,2,3]" to "1232312323".
** Change term_to_atom(T1,S) to string_strings(S,T1).
** Change term_to_atom(S2,S),flatten_keep_brackets(S2,S1),append([_],S4,S1),append(S3,[_],S4) to string_strings(S,S3).
* Strings to Grammar’s grammars can be used for parsing or syntactical analysis.
=== Spec to Algorithm ===
* Spec to Algorithm converts a spec to a pattern-matching algorithm. It achieves this with the following algorithm.
* Example usage: spec_to_algorithm(algorithm,[[[input,[['A',[1,2]]]],[output,[['B',[2,1]]]]], [[input,[['A',[3,4]]]],[output,[['B',[4,3]]]]]],on,A),writeln1(A).
* Output: An algorithm that uses subterm with address (a custom Prolog predicate that searches for and replaces subterms in terms using their addresses) to put input into a recursive structure and map this input to output using previous data.
* The algorithm.pl file contains the algorithm in Prolog form.
==== Predicates used to generate the algorithm ====
* find_unique_variables - Finds 1:1 correspondence of values to variables in input and output, used to find recursive structures, constants, mapping and output.
* try - A Strings to Grammar predicate (see earlier on this page) that finds recursive structures from data or patterns that can accept and produce data in the same pattern.
* find_constants - Finds constants across spec, for verification and producing output in this format.
* decision_tree - A Strings to Grammar predicate that merges different specs.
* find_mapping - Finds mapping of input to output.
==== Predicates in the generated algorithm ====
* rs_and_data_to_term - Put input into the above recursive structure.
* move_vars - Moves variable values from the input to output recursive structures.
* term_to_list - Renders the output term from the output recursive structure.
==== Breakdown to Characters for Exact Pattern Matching ====
* Spec to Algorithm can break down strings, atoms, numbers and compounds in terms to characters, allowing conversion between types and production of terms with new combinations of characters.
==== Conclusion ====
* Spec to Algorithm can be used for automatic software generation, education, prototyping, rewriting and maintaining software clearly and easily and project planning.