rubylog 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -1
- data/README.hu.rb +58 -0
- data/README.rdoc +248 -89
- data/Rakefile +6 -1
- data/VERSION +1 -1
- data/bin/rubylog +18 -0
- data/examples/dcg.rb +35 -0
- data/examples/dcg2.rb +42 -0
- data/examples/enumerators.rb +30 -0
- data/examples/factorial.rb +9 -8
- data/examples/hanoi.rb +24 -0
- data/examples/hello.rb +11 -5
- data/examples/parsing.rb +27 -0
- data/examples/primitives.rb +24 -0
- data/examples/theory.rb +22 -10
- data/lib/rubylog/builtins/default.rb +10 -0
- data/lib/rubylog/builtins/file_system.rb +15 -0
- data/lib/rubylog/builtins/logic.rb +109 -0
- data/lib/rubylog/builtins/reflection.rb +94 -0
- data/lib/rubylog/builtins/term.rb +47 -0
- data/lib/rubylog/dsl/array_splat.rb +25 -0
- data/lib/rubylog/dsl/primitives.rb +17 -0
- data/lib/rubylog/dsl/thats.rb +22 -0
- data/lib/rubylog/dsl/variables.rb +30 -0
- data/lib/rubylog/dsl.rb +35 -17
- data/lib/rubylog/errors.rb +19 -1
- data/lib/rubylog/interfaces/assertable.rb +16 -0
- data/lib/rubylog/interfaces/callable.rb +18 -0
- data/lib/rubylog/interfaces/composite_term.rb +47 -0
- data/lib/rubylog/interfaces/predicate.rb +8 -0
- data/lib/rubylog/interfaces/procedure.rb +60 -0
- data/lib/rubylog/interfaces/term.rb +41 -0
- data/lib/rubylog/mixins/array.rb +118 -0
- data/lib/{class.rb → rubylog/mixins/class.rb} +2 -2
- data/lib/rubylog/mixins/hash.rb +8 -0
- data/lib/rubylog/mixins/kernel.rb +5 -0
- data/lib/rubylog/mixins/method.rb +3 -0
- data/lib/rubylog/mixins/object.rb +8 -0
- data/lib/rubylog/mixins/proc.rb +37 -0
- data/lib/rubylog/mixins/string.rb +104 -0
- data/lib/rubylog/mixins/symbol.rb +44 -0
- data/lib/rubylog/simple_procedure.rb +8 -0
- data/lib/rubylog/{clause.rb → structure.rb} +32 -31
- data/lib/rubylog/theory.rb +368 -79
- data/lib/rubylog/variable.rb +102 -23
- data/lib/rubylog.rb +33 -25
- data/logic/builtins/file_system_logic.rb +23 -0
- data/logic/builtins/reflection_logic.rb +40 -0
- data/logic/dereference_logic.rb +23 -0
- data/logic/directory_structure_logic.rb +19 -0
- data/logic/dsl_logic.rb +29 -0
- data/logic/errors_logic.rb +9 -0
- data/logic/guard_logic.rb +115 -0
- data/logic/list_logic.rb +55 -0
- data/logic/map_logic.rb +15 -0
- data/logic/multitheory.rb +23 -0
- data/logic/recursion_logic.rb +12 -0
- data/logic/string_logic.rb +41 -0
- data/logic/thats_logic.rb +51 -0
- data/logic/variable_logic.rb +24 -0
- data/rubylog.gemspec +85 -46
- data/spec/bartak_guide_spec.rb +57 -62
- data/spec/builtins/all_spec.rb +99 -0
- data/spec/builtins/and_spec.rb +22 -0
- data/spec/builtins/array_spec.rb +16 -0
- data/spec/builtins/branch_or_spec.rb +27 -0
- data/spec/builtins/cut_spec.rb +44 -0
- data/spec/builtins/fail_spec.rb +5 -0
- data/spec/builtins/false_spec.rb +5 -0
- data/spec/builtins/in_spec.rb +38 -0
- data/spec/builtins/is_false_spec.rb +12 -0
- data/spec/builtins/is_spec.rb +26 -0
- data/spec/builtins/matches_spec.rb +23 -0
- data/spec/builtins/or_spec.rb +22 -0
- data/spec/{rubylog/builtins → builtins}/splits_to.rb +0 -0
- data/spec/builtins/then_spec.rb +27 -0
- data/spec/builtins/true_spec.rb +5 -0
- data/spec/clause_spec.rb +82 -0
- data/spec/compilation_spec.rb +61 -0
- data/spec/custom_classes_spec.rb +43 -0
- data/spec/dereference.rb +10 -0
- data/spec/{inriasuite.rb → inriasuite_spec.rb} +2 -9
- data/spec/queries_spec.rb +150 -0
- data/spec/recursion_spec.rb +4 -4
- data/spec/ruby_code_spec.rb +52 -0
- data/spec/rules_spec.rb +97 -0
- data/spec/spec_helper.rb +6 -2
- data/spec/theory_spec.rb +28 -0
- data/spec/unification_spec.rb +84 -0
- data/spec/variable_spec.rb +26 -0
- metadata +153 -180
- data/examples/4queens.rb +0 -10
- data/examples/calculation.rb +0 -12
- data/examples/concepts.rb +0 -46
- data/examples/fp.rb +0 -56
- data/examples/historia_de_espana.rb +0 -31
- data/examples/idea.rb +0 -143
- data/examples/lists.rb +0 -5
- data/examples/mechanika.rb +0 -409
- data/examples/parse.rb +0 -15
- data/lib/array.rb +0 -24
- data/lib/method.rb +0 -4
- data/lib/object.rb +0 -5
- data/lib/proc.rb +0 -4
- data/lib/rubylog/builtins.rb +0 -193
- data/lib/rubylog/callable.rb +0 -20
- data/lib/rubylog/composite_term.rb +0 -38
- data/lib/rubylog/dsl/constants.rb +0 -15
- data/lib/rubylog/dsl/first_order_functors.rb +0 -9
- data/lib/rubylog/dsl/global_functors.rb +0 -3
- data/lib/rubylog/dsl/second_order_functors.rb +0 -8
- data/lib/rubylog/internal_helpers.rb +0 -16
- data/lib/rubylog/predicate.rb +0 -34
- data/lib/rubylog/proc_method_additions.rb +0 -69
- data/lib/rubylog/term.rb +0 -20
- data/lib/rubylog/unifiable.rb +0 -19
- data/lib/symbol.rb +0 -35
- data/script/inriasuite2spec +0 -0
- data/script/inriasuite2spec.pl +0 -22
- data/spec/rubylog/clause_spec.rb +0 -81
- data/spec/rubylog/variable_spec.rb +0 -25
- data/spec/rubylog_spec.rb +0 -914
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'rubylog'
|
2
|
-
require 'pp'
|
3
|
-
|
4
|
-
class << Rubylog::Theory.new!
|
5
|
-
Symbol.rubylog_functor :lugar_historico, :during
|
6
|
-
Integer.rubylog_functor :during
|
7
|
-
|
8
|
-
A.lugar_historico.if A.in [
|
9
|
-
:Hispania_prehistorica,
|
10
|
-
:Hispania_romana,
|
11
|
-
:Hispania_visigoda,
|
12
|
-
:Al_Andalus,
|
13
|
-
:Imperio_espanol,
|
14
|
-
:Reino_Constitucional_Espanol
|
15
|
-
]
|
16
|
-
|
17
|
-
:Hispania_prehistorica.during! [-800000,200]
|
18
|
-
A.during([X,Y]).if A.matches(Integer).and {|a,x,y| (x..y) === a}
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def self.solve k
|
24
|
-
pp *k.solutions
|
25
|
-
end
|
26
|
-
|
27
|
-
puts
|
28
|
-
pp *(A.lugar_historico.and A.during(P).and 200.during(P)).variable_hashes
|
29
|
-
|
30
|
-
|
31
|
-
end
|
data/examples/idea.rb
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# ActiveSpec
|
5
|
-
user = User.new(:username => 'luke')
|
6
|
-
spec = SizeSpecification.new(6, :username)
|
7
|
-
spec.satisfied_by? user
|
8
|
-
|
9
|
-
spec = CompositeSpecification.new
|
10
|
-
spec.add_specification(SizeSpecification.new(6, :username))
|
11
|
-
spec.add_specification(CollectionSpecification.new(18..30, :age))
|
12
|
-
spec.add_specification(ConfirmationSpecification.new(:password))
|
13
|
-
spec.satisfied_by?(User.new)
|
14
|
-
#=> false
|
15
|
-
|
16
|
-
# Rubylog
|
17
|
-
user = User.new(:username => 'luke')
|
18
|
-
U.username_valid.if U.size_of(:username,6)
|
19
|
-
user.username_valid?
|
20
|
-
|
21
|
-
# ActiveSpec
|
22
|
-
spec = CollectionSpecification.new(1..10, :age)
|
23
|
-
# or validates_inclusion_of :age, :in => 1..10
|
24
|
-
spec_two = NotSpecification.new(CollectionSpecification.new(1..10, :age))
|
25
|
-
# or validates_exclusion_of :age, :in => 1..10
|
26
|
-
|
27
|
-
# Rubylog
|
28
|
-
U.age_valid.if ~ U.is_included(:age, 1..10)
|
29
|
-
|
30
|
-
# ActiveSpec
|
31
|
-
spec = ProcSpecification.new(proc{ |object|
|
32
|
-
# do something with object
|
33
|
-
# and return true or false
|
34
|
-
})
|
35
|
-
spec.satisfied_by? some_object
|
36
|
-
|
37
|
-
U.everything_valid.if {|u|
|
38
|
-
# do something w/ u and return true/false
|
39
|
-
}
|
40
|
-
|
41
|
-
# ActiveSpec
|
42
|
-
class UserSpecification < ActiveSpec::Base
|
43
|
-
requires_presence_of :username, :password
|
44
|
-
requires_size 6, :password
|
45
|
-
requires_confirmation_of :password
|
46
|
-
requires_inclusion_in 18..30, :age
|
47
|
-
end
|
48
|
-
UserSpecification.satisfied_by?(some_user)
|
49
|
-
|
50
|
-
# Rubylog
|
51
|
-
UserValidationTheory = Rubylog::Theory.new do
|
52
|
-
protected
|
53
|
-
U.invalid.if (U.username=N) & N.blank
|
54
|
-
U.invalid.if (U.password=P) & P.size=K & K.is_not 6
|
55
|
-
U.invalid.if (U.password_confirmation=C) & (U.password=P) & (K.is_not P)
|
56
|
-
U.invalid.if (U.age=A) & ~:include[18..30, A]
|
57
|
-
public
|
58
|
-
U.valid_user.if ~U.invalid
|
59
|
-
end
|
60
|
-
|
61
|
-
User.include_theory UserValidationTheory
|
62
|
-
some_user.valid_user?
|
63
|
-
|
64
|
-
|
65
|
-
# ActiveSpec
|
66
|
-
specification :valid_user do
|
67
|
-
requires_presence_of :username, :password
|
68
|
-
requires_confirmation_of :password
|
69
|
-
must_satisfy :another_specification
|
70
|
-
end
|
71
|
-
|
72
|
-
ValidUserSpecification.satisfied_by?(some_user)
|
73
|
-
|
74
|
-
# Rubylog
|
75
|
-
# app/theories/valid_user_theory.rb
|
76
|
-
theory :valid_user do
|
77
|
-
U.valid_user.if ~U.invalid
|
78
|
-
protected
|
79
|
-
U.invalid.if (U.username=N) & N.blank
|
80
|
-
U.invalid.if (U.password=P) & P.size=K & K.is_not 6
|
81
|
-
U.invalid.if (U.password_confirmation=C) & (U.password=P) & (K.is_not P)
|
82
|
-
U.invalid.if (U.age=A) & ~:include[18..30, A]
|
83
|
-
end
|
84
|
-
|
85
|
-
User.include_theory :valid_user
|
86
|
-
some_user.valid_user?
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
# ActiveSpec
|
93
|
-
class User
|
94
|
-
must_satisfy :valid_user_specification
|
95
|
-
|
96
|
-
# optional :if argument takes a symbol or a block
|
97
|
-
# and can be used for conditional evaluation of
|
98
|
-
# specifications
|
99
|
-
must_satisfy :activated_user_specification, :if => :activated?
|
100
|
-
end
|
101
|
-
|
102
|
-
user = User.new
|
103
|
-
user.satisfies_specs?
|
104
|
-
# evaluates ValidUserSpecification
|
105
|
-
user.activated = true
|
106
|
-
user.satisfies_specs?
|
107
|
-
# evaluates both specifications
|
108
|
-
|
109
|
-
|
110
|
-
# Rubylog
|
111
|
-
class User
|
112
|
-
include_theory :valid_user, :activated_user
|
113
|
-
def satisfies_specs?
|
114
|
-
!bad?
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
theory :valid_user do
|
119
|
-
U.bad.if ~U.valid_user
|
120
|
-
protected
|
121
|
-
#...
|
122
|
-
end
|
123
|
-
|
124
|
-
theory :activated_user do
|
125
|
-
U.bad.if U.activated.and ~U.valid_activated_user
|
126
|
-
protected
|
127
|
-
# ...
|
128
|
-
end
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
data/examples/lists.rb
DELETED
data/examples/mechanika.rb
DELETED
@@ -1,409 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'rubylog'
|
3
|
-
require 'pp'
|
4
|
-
|
5
|
-
class Range
|
6
|
-
def choose
|
7
|
-
self.begin + rand(self.end-self.begin+1)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class Array
|
12
|
-
def choose
|
13
|
-
self[(rand*size).to_i]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
class << TimeTheory = Rubylog::Theory.new!
|
19
|
-
TimeTheory.predicate [:elt,2]
|
20
|
-
end
|
21
|
-
|
22
|
-
class << MechanikaTheory = Rubylog::Theory.new!
|
23
|
-
Symbol.send :include, TimeTheory.public_interface
|
24
|
-
Object.rubylog_functor \
|
25
|
-
:egy
|
26
|
-
Symbol.rubylog_functor \
|
27
|
-
:nobel_dijas,
|
28
|
-
:ember,
|
29
|
-
:modszer,
|
30
|
-
:def,
|
31
|
-
:of,
|
32
|
-
:kutatott,
|
33
|
-
:felfedezte,
|
34
|
-
:kidolgozta,
|
35
|
-
:javasolta,
|
36
|
-
:megmagyarazza,
|
37
|
-
:igazolja,
|
38
|
-
:mennyiseg,
|
39
|
-
:during,
|
40
|
-
:mertekegysege
|
41
|
-
Rubylog::Clause.rubylog_functor\
|
42
|
-
:learn,
|
43
|
-
:all_learn,
|
44
|
-
:see,
|
45
|
-
:all_see,
|
46
|
-
:during
|
47
|
-
MechanikaTheory.predicate [:fizikus,1]
|
48
|
-
MechanikaTheory.discontinuous [:def,2], [:ember,1], [:elt,2], [:modszer,1], [:of,2], [:egy,2], [:during,2], [:nobel_dijas, 3]
|
49
|
-
|
50
|
-
|
51
|
-
X.ember.if X.egy :filozofus
|
52
|
-
X.ember.if X.egy :fizikus
|
53
|
-
|
54
|
-
X.egy(:filozofus).if X.in [:Szokratesz, :Demokritosz, :Platon, :Arisztotelesz, :Arkhimedesz, :Ptolemaiosz]
|
55
|
-
|
56
|
-
:Szokratesz. elt! [-469,-399]
|
57
|
-
:Demokritosz. elt! [-460,-370]
|
58
|
-
:Platon. elt! [-427,-347]
|
59
|
-
:Arisztotelesz.elt! [-384,-322]
|
60
|
-
:Arkhimedesz. elt! [-287,-212]
|
61
|
-
:Ptolemaiosz. elt! [ 85, 161]
|
62
|
-
|
63
|
-
X.modszer.if X.in [
|
64
|
-
:megfigyeles,
|
65
|
-
:kiserlet,
|
66
|
-
:meres,
|
67
|
-
:torveny,
|
68
|
-
:elmelet,
|
69
|
-
:hipotezis,
|
70
|
-
:modell,
|
71
|
-
:korrespondancia_elv
|
72
|
-
]
|
73
|
-
|
74
|
-
:kiserlet.def! "Kísérlet az, amikor az általunk kiválasztott esemény számára tudatosan olyan feltételeket teremtünk, hogy az megismételhető legyen különböző, általunk előírt körülmények között."
|
75
|
-
|
76
|
-
:meres.def! "Valamilyen önkényesen választott egységgel történő összehasonlítás"
|
77
|
-
|
78
|
-
:torveny.def! "Mérhető mennyiségek közti összefüggés."
|
79
|
-
:torveny.def! "A mért eredmények közti kapcsolat megfogalmazása matematikai összefüggés formájában"
|
80
|
-
|
81
|
-
:hipotezis.def! "Az elmélet kidolgozása közben tett feltételezés. Ha az elmélet következtetéseit a tapasztalat megerősíti, akkor el kell fogadni a hipotézist, különben el kell vetni"
|
82
|
-
|
83
|
-
:modell.def! "Egyszerűsítő feltevés a valóság vizsgálata során."
|
84
|
-
X.egy(:modell).if X.in [:merev_test, :tomegpont, :abszolut_rugalmas_test, :idealis_gaz]
|
85
|
-
|
86
|
-
:korrespondancia_elv.def! "A jelenségeket általánosabban leíró elmélet a speciálisabb elmélet eredményeit tartalmazza, mint határesetet."
|
87
|
-
[:relativisztikus_sebessegformula, :galilei_fele_sebessegosszegzesi_keplet].egy :korrespondancia_elv
|
88
|
-
|
89
|
-
:Leonardo_da_Vinci.ember!.elt! [1452, 1519]
|
90
|
-
|
91
|
-
:Galileo_Galilei.egy!(:fizikus).elt! [1564,1642]
|
92
|
-
|
93
|
-
:Isaac_Newton.egy!(:fizikus).elt!([1642,1727]).kutatott!(:optika)
|
94
|
-
|
95
|
-
:Albert_Einstein.egy!(:fizikus).elt!([1879,1955]).nobel_dijas!(:fizika, 1921)
|
96
|
-
|
97
|
-
:Blaise_Pascal.egy!(:fizikus).elt!([1623,1662])
|
98
|
-
|
99
|
-
:Robert_Hooke.egy!(:fizikus).elt!([1635,1703])
|
100
|
-
|
101
|
-
:Daniel_Bernoulli.egy!(:fizikus).elt!([1700,1782])
|
102
|
-
|
103
|
-
:Roger_Bacon.egy!(:filozofus).elt!([1214,1292])
|
104
|
-
|
105
|
-
:Karl_Gauss.egy!(:fizikus).egy!(:matematikus).elt!([1777,1855])
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
:indukcio.modszer!.of!(:kiserleti_fizika).def!("Tapasztalatgyűjtés után általánosítás útján elméletek felépítése")
|
110
|
-
:dedukcio.modszer!.of!(:elmeleti_fizika).def!("Alapelvekből levezeti a konkrét összefüggéseket, és összeveti a valósággal")
|
111
|
-
|
112
|
-
(X.egy :Kepler_torveny).all(:gravitacios_torveny.megmagyarazza(X)).egy! :deduckio
|
113
|
-
:specialis_relativitaselmelet.of!(:Einstein).megmagyarazza(:merkur_perihelium_mozgasa).egy!(:indukcio)
|
114
|
-
:altalanos_relativitaselmelet.of!(:Einstein).megmagyarazza(:fenysebesseg_keplet?.of!(:Armand_Fizeau.egy!(:fizikus).elt! [1819,1896])).egy!(:indukcio)
|
115
|
-
(:elektromagneses_hullamok_kiserleti_igazolasa.of!(:Heinrich_Hertz.egy!(:fizikus).elt!([1857,1897])).igazolja :elektromagneses_hullamok_elmelete.of!(:Maxwell)).egy!(:dedukcio)
|
116
|
-
|
117
|
-
:CERN_kutatasok.egy! :alapkutatas.modszer!
|
118
|
-
|
119
|
-
# Mérés
|
120
|
-
|
121
|
-
X.mennyiseg.if X.in [:ut, :ido, :sebesseg, :tomeg]
|
122
|
-
|
123
|
-
:SI.during! [1790,ANY]
|
124
|
-
|
125
|
-
:hosszusag.mertekegysege! :m
|
126
|
-
:m.def("A Föld Dunquerque-Barcelona délkörének 40-milliomod része.").during! [1790,1874]
|
127
|
-
:m.def("A mintaméter két vonása közötti távolság").during! [1874,1960]
|
128
|
-
:m.def("1650763.73 * a kripton 2p10 és 5d5 energiaszintjei közötti átmenet során kibocsátott fény hullámhossza").during! [1960,1983]
|
129
|
-
:Bay_Zoltan.egy!(:fizikus).elt!([1900,1992]).javasolta!( :m.def("A vákumban terjedő fénysebesség 1/299792458 s alatti útja").during! [1983,ANY] )
|
130
|
-
|
131
|
-
Symbol.rubylog_functor :per
|
132
|
-
Rubylog::Clause.rubylog_functor :per
|
133
|
-
MechanikaTheory.discontinuous [:per,3]
|
134
|
-
|
135
|
-
:km.per! :m, 1000
|
136
|
-
:dm.per! :m, 0.1
|
137
|
-
:cm.per! :m, 0.01
|
138
|
-
:mm.per! :m, 0.001
|
139
|
-
:um.per! :m, 1e-6
|
140
|
-
:nm.per! :m, 1e-9
|
141
|
-
:angstrom.per! :m, 1e-10
|
142
|
-
|
143
|
-
:inch.per! :cm, 2.54
|
144
|
-
:foot.per! :inch, 12
|
145
|
-
:yard.per! :foot, 3
|
146
|
-
:mile.per! :km, 1.61
|
147
|
-
|
148
|
-
:fenyev.per! :km, 9.4605e12
|
149
|
-
:parsec.per! :fenyev, 3.2616
|
150
|
-
|
151
|
-
:negyszogol.per! :m2, 3.6
|
152
|
-
:katasztralis_hold.per! :negyszogol, 1600
|
153
|
-
|
154
|
-
A.per(B,N).if A.per(X,N1).and X.per(B,N2).and N.is{|a,b,n,x,n1,n2|n1*n2}
|
155
|
-
|
156
|
-
Symbol.rubylog_functor :mero_eszkoz, :tavolsaga, :magassaga, :atmeroje,
|
157
|
-
:hossza, :vastagsaga, :mero_modszer, :sugara, :pontossaga
|
158
|
-
Symbol.rubylog_functor :megmerte
|
159
|
-
Rubylog::Clause.rubylog_functor :using
|
160
|
-
MechanikaTheory.discontinuous [:tavolsaga,3], [:magassaga,2], [:hossza,2],
|
161
|
-
[:vastagsaga,2], [:atmeroje,2], [:sugara,2], [:megmerte,2], [:pontossaga, 2]
|
162
|
-
|
163
|
-
X.egy(:hosszusag.mero_eszkoz).if X.in [
|
164
|
-
:merorud,
|
165
|
-
:meroszalag,
|
166
|
-
:tolomero,
|
167
|
-
:mikrometercsavar,
|
168
|
-
:szferometer,
|
169
|
-
:katetometer,
|
170
|
-
:komparator
|
171
|
-
]
|
172
|
-
:haromszogeles.egy! :hosszusag.mero_modszer
|
173
|
-
:Bay_Zoltan.megmerte(:Fold.tavolsaga :Hold, X).using!(:radiohullamos_tavolsagmeres.egy! :hosszusag.mero_modszer).if :true
|
174
|
-
|
175
|
-
Symbol.rubylog_functor :galaxis, :csillag
|
176
|
-
MechanikaTheory.discontinuous [:csillag,1]
|
177
|
-
Numeric.rubylog_functor :m, :szogperc
|
178
|
-
|
179
|
-
:Fold.tavolsaga! :Andromeda.galaxis!, 2e22.m
|
180
|
-
:Fold.tavolsaga! :Proxima_Centauri.csillag!, 4e16.m
|
181
|
-
:Fold.tavolsaga! :Nap.csillag!, 1.5e11.m
|
182
|
-
:Fold.tavolsaga! :Hold, 3.8e8.m
|
183
|
-
:Fold.sugara! 6.4e6.m
|
184
|
-
:muhold_foldkozeli_pontja.magassaga! 2e5.m
|
185
|
-
:focipalya.hossza! 1e2.m
|
186
|
-
:zsilettpenge.vastagsaga! 1e-4.m
|
187
|
-
:sejt.atmeroje! 1e-5.m
|
188
|
-
:virus.atmeroje! 1e-7.m
|
189
|
-
:mikroaramkor_huzaljai.vastagsaga! 1e-7.m
|
190
|
-
:molekula.atmeroje 1e-9.m
|
191
|
-
:atom.atmeroje 1e-10.m
|
192
|
-
:atommag.atmeroje 1e-14.m
|
193
|
-
|
194
|
-
X.egy(:szog.mero_eszkoz).if X.in [
|
195
|
-
:egyetemes_szogmero.def!("Két egymáshoz pontosan hajló szárból álló, nóniuszos skálával ellátott készülék"),
|
196
|
-
:teodolit.def!("Függőlegesen és vízszintesen elforgatható, fonalkeresztes távcsővel ellátott készülék. Körnóniusz és nagyító.").pontossaga(1.szogperc)
|
197
|
-
]
|
198
|
-
|
199
|
-
:ultrahangos
|
200
|
-
:interferogramos
|
201
|
-
|
202
|
-
# Idomeres
|
203
|
-
#
|
204
|
-
|
205
|
-
"Valamilyen periodikusan ismétlődő jelenség"
|
206
|
-
|
207
|
-
:nap.per! :s, 86400
|
208
|
-
:tropikus_ev.per! :nap, 365.2422
|
209
|
-
:csillagmasodperc.per(:s, K).if :tropikus_ev.per(:nap,N) & K.is{|_,n| n/(n+1)}
|
210
|
-
|
211
|
-
Symbol.rubylog_functor :hasznal
|
212
|
-
MechanikaTheory.discontinuous [:hasznal,2]
|
213
|
-
|
214
|
-
X.egy(:ido.mero_eszkoz).if X.in [
|
215
|
-
:mechanikus_ora.hasznal!(:csavarrugo),
|
216
|
-
:elektromos_ora.hasznal!(:elektromotor),
|
217
|
-
:ingaora.hasznal!(:rugo),
|
218
|
-
:regi_elektronikus_ora.hasznal!(:halozati_50Hz),
|
219
|
-
:elektronikus_ora.hasznal!(:kvarcoszcillator),
|
220
|
-
]
|
221
|
-
|
222
|
-
:metronom.egy! :ingaora
|
223
|
-
|
224
|
-
Symbol.rubylog_functor :szarmaztatott_mennyiseg, :alapmennyiseg, :mennyiseg
|
225
|
-
MechanikaTheory.discontinuous [:mennyiseg,1]
|
226
|
-
|
227
|
-
X.szarmaztatott_mennyiseg.if X.mennyiseg.and X.alapmennyiseg.is_false
|
228
|
-
X.mennyiseg.if X.alapmennyiseg
|
229
|
-
|
230
|
-
X.alapmennyiseg.if X.in [
|
231
|
-
:hosszusag, :tomeg, :ido, :aramerosseg, :homerseklet, :anyagmennyiseg, :fenyerosseg
|
232
|
-
]
|
233
|
-
|
234
|
-
Symbol.rubylog_functor :otta, :zeta, :exa, :peta, :tera, :giga, :mega, :kilo,
|
235
|
-
:hekto, :deka, :deci, :centi, :milli, :mikro, :nano, :piko, :femto, :atto
|
236
|
-
|
237
|
-
X.otta.per X, 1e24
|
238
|
-
X.zeta.per X, 1e21
|
239
|
-
X.exa. per X, 1e18
|
240
|
-
X.peta.per X, 1e15
|
241
|
-
X.tera.per X, 1e12
|
242
|
-
X.giga.per X, 1e9
|
243
|
-
X.mega.per X, 1e6
|
244
|
-
X.kilo.per X, 1e3
|
245
|
-
X.hekto.per X, 1e2
|
246
|
-
X.deka.per X, 1e1
|
247
|
-
X.deci.per X, 1e-1
|
248
|
-
X.centi.per X, 1e-2
|
249
|
-
X.milli.per X, 1e-3
|
250
|
-
X.mikro.per X, 1e-6
|
251
|
-
X.nano.per X, 1e-9
|
252
|
-
X.piko.per X, 1e-12
|
253
|
-
X.femto.per X, 1e-15
|
254
|
-
X.atto. per X, 1e-18
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
[:hl, :hPa, :dag, :dkg, :dm, :cm, :cg, :cl, :cGy, :cSv]
|
260
|
-
|
261
|
-
|
262
|
-
# Méréshibák
|
263
|
-
|
264
|
-
:parallaxishiba.def! "A leolvasás értéke függ a szemünk helyzetétől, ha a tárgy nem érintkezik a skálával."
|
265
|
-
|
266
|
-
:szisztematikus_hiba.def! "A mérőeszköz felépítéséből, környezete rá gyakorolt hatásából, használatának módjából eredő hiba."
|
267
|
-
|
268
|
-
:statisztikus_hiba.def! "Olyan kísérletekben, amelyek kimenetelében a véletlen is szerepet játszik, bizonyos eloszlású (tipikusan normál vagy logaritmikus normál eloszlású) lesz az eredmény."
|
269
|
-
|
270
|
-
Symbol.rubylog_functor :hibacsokkento_modszer
|
271
|
-
|
272
|
-
X.hibacsokkento_modszer.if X.in [
|
273
|
-
:finomabb_meroeszkoz_hasznalata,
|
274
|
-
:tukros_leolvasas,
|
275
|
-
:mereshatar_beallitasa,
|
276
|
-
:a_mennyiseg_tobbszoroset_merjuk,
|
277
|
-
:az_emberi_tenyezo_kiiktatasa,
|
278
|
-
:kiugro_ertekek_elhagyasa
|
279
|
-
]
|
280
|
-
|
281
|
-
Numeric.rubylog_functor :pm
|
282
|
-
Rubylog::Clause.rubylog_functor :times, :gives
|
283
|
-
|
284
|
-
100.0.pm(1.0).times(3.1415.pm(0.00005)).gives!((100 * 3.1415).pm(100*3.1415*(1.0/100.0 + 0.00005/3.1415)))
|
285
|
-
|
286
|
-
|
287
|
-
Symbol.rubylog_functor :eletkora, :idotartama, :periodusideje, :athaladasi_ideje
|
288
|
-
Numeric.rubylog_functor :s
|
289
|
-
MechanikaTheory.discontinuous [:eletkora,2], [:idotartama, 2], [:periodusideje, 2], [:athaladasi_ideje, 3]
|
290
|
-
|
291
|
-
:univerzum.eletkora! 4e17.s
|
292
|
-
:Fold.eletkora! 1.3e17.s
|
293
|
-
:emberiseg.eletkora! 1e13.s
|
294
|
-
:piramisok.eletkora! 1e11.s
|
295
|
-
:ember.eletkora! 2e9.s
|
296
|
-
:ev.per! :s, 1.2e7
|
297
|
-
:nap.per! :s, 8.64e4
|
298
|
-
:egy_meteres_fonalinga.periodusideje 2.s
|
299
|
-
:sziv.periodusideje 8e-1.s
|
300
|
-
:hang.periodusideje 1e-3.s
|
301
|
-
:hang.periodusideje 1e-4.s
|
302
|
-
:radiohullam.periodusideje 1e-6.s
|
303
|
-
:radiohullam.periodusideje 1e-9.s
|
304
|
-
:racsrezges.periodusideje 1e-13.s
|
305
|
-
:feny.periodusideje 2e-15.s
|
306
|
-
:nuklearis_utkozes.idotartama 1e-22.s
|
307
|
-
:feny.athaladasi_ideje :proton.atmeroje, 3.3e-24.s
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
Clause.see.if(
|
331
|
-
Clause._puts &
|
332
|
-
Vars.is {|clause|clause.rubylog_variables.select{|v|
|
333
|
-
!v.assigned?}} &
|
334
|
-
(V.in Vars).all(
|
335
|
-
V._print & '?'._puts) &
|
336
|
-
proc{gets} &
|
337
|
-
(Clause &
|
338
|
-
(V.in Vars).all(V._puts) | :true)
|
339
|
-
|
340
|
-
)
|
341
|
-
|
342
|
-
Clause.learn.if(
|
343
|
-
(
|
344
|
-
Clause._puts &
|
345
|
-
Vars.is {|clause|clause.rubylog_variables.select{|v|
|
346
|
-
!v.assigned?}} &
|
347
|
-
(V.in Vars).all(
|
348
|
-
V._print & '.is '._print & V.is{eval gets} &
|
349
|
-
Clause &
|
350
|
-
"Correct"._puts
|
351
|
-
)
|
352
|
-
) | (
|
353
|
-
"Wrong"._puts &
|
354
|
-
Clause &
|
355
|
-
Clause._p &
|
356
|
-
(ANY.in 1..10).all(:nl) &
|
357
|
-
:fail
|
358
|
-
)
|
359
|
-
)
|
360
|
-
|
361
|
-
|
362
|
-
A.all_learn(B).if(
|
363
|
-
:repeat &
|
364
|
-
A.one(B.learn.fails)
|
365
|
-
)
|
366
|
-
|
367
|
-
A.all_see(B).if(
|
368
|
-
A.all(B.see)
|
369
|
-
)
|
370
|
-
|
371
|
-
|
372
|
-
def self.ask question
|
373
|
-
p question
|
374
|
-
puts "X = ?"
|
375
|
-
gets
|
376
|
-
p(*question.to_a)
|
377
|
-
puts
|
378
|
-
end
|
379
|
-
|
380
|
-
def self.ask_something functor=nil, arity=nil, n=nil
|
381
|
-
functor ||= MechanikaTheory.database.keys.choose
|
382
|
-
arity ||= MechanikaTheory.database[functor].keys.choose
|
383
|
-
clause = MechanikaTheory.database[functor][arity].choose
|
384
|
-
return unless clause.is_a? Rubylog::Clause
|
385
|
-
head = clause[0]
|
386
|
-
solution = head.solutions.choose
|
387
|
-
n ||= (0..solution.arity-1).choose
|
388
|
-
args = solution.args.dup
|
389
|
-
args[n] = X
|
390
|
-
question = Rubylog::Clause.new functor, *args
|
391
|
-
ask question
|
392
|
-
end
|
393
|
-
|
394
|
-
while true
|
395
|
-
begin
|
396
|
-
#ask_something :elt,2,1
|
397
|
-
ask_something
|
398
|
-
rescue StandardError
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
|
403
|
-
#(
|
404
|
-
#X.ember.all_see X.elt [Szuletett, Meghalt]
|
405
|
-
#X.modszer.all_see X.def D
|
406
|
-
#).solve
|
407
|
-
|
408
|
-
#pp *(X.elt Y).solutions
|
409
|
-
end
|
data/examples/parse.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'rubylog'
|
2
|
-
|
3
|
-
class << Rubylog.theory
|
4
|
-
include Rubylog::DSL::DCG
|
5
|
-
|
6
|
-
:sentence.means :subject.and :verb.and :object
|
7
|
-
:subject .means :modifier.and :noun
|
8
|
-
:noun. means [:cat].or [:mouse].or [:polar_bear]
|
9
|
-
:modifier.means [:the]
|
10
|
-
:verb .means [:chases].or [:eats]
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
|
data/lib/array.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
class Array
|
2
|
-
|
3
|
-
# Unifiable methods
|
4
|
-
include Rubylog::Unifiable
|
5
|
-
def rubylog_unify other
|
6
|
-
return super{yield} unless other.instance_of? self.class
|
7
|
-
if empty?
|
8
|
-
yield if other.empty?
|
9
|
-
else
|
10
|
-
self[0].rubylog_unify other[0] do
|
11
|
-
self[1..-1].rubylog_unify other[1..-1] do
|
12
|
-
yield
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# CompositeTerm methods
|
19
|
-
include Rubylog::CompositeTerm
|
20
|
-
def rubylog_clone &block
|
21
|
-
block[map{|t|t.rubylog_clone &block}]
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
data/lib/method.rb
DELETED
data/lib/object.rb
DELETED
data/lib/proc.rb
DELETED