Skip to content

Commit 3b985fa

Browse files
committed
rule distinct_elim; polymorphic programs to manipulate f-lists
1 parent bc31159 commit 3b985fa

File tree

3 files changed

+220
-111
lines changed

3 files changed

+220
-111
lines changed

carcara/src/translation/tests/alethe_signature/alethe.eo

+100-36
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,27 @@
4747
:conclusion CL
4848
)
4949

50-
;TODO
50+
;;;;;;;;;;;;;;;;;;;;;;;
51+
; Rule 6: th_resolution
52+
;;;;;;;;;;;;;;;;;;;;;;;
53+
; TODO
5154
(program check_resolution ((Cs Bool) (CL Bool))
5255
(Bool Bool) Bool
5356
(
5457
((check_resolution Cs CL) true)
5558
)
5659
)
5760

58-
;TRUST
59-
(declare-rule th_resolution ((Cs Bool) (CL Bool))
61+
(declare-rule th_resolution ((Cs Bool))
6062
:premise-list Cs and
61-
:args (CL)
62-
:requires (((check_resolution Cs CL) true))
63-
:conclusion CL
63+
:requires (((check_resolution Cs eo::conclusion) true))
64+
:conclusion-given
6465
)
6566

67+
;;;;;;;;;;;;;;;;;;;;;;;
68+
; Rule 7: resolution
69+
;;;;;;;;;;;;;;;;;;;;;;;
70+
6671
;TRUST
6772
(declare-rule resolution ((Cs Bool))
6873
:premise-list Cs and
@@ -442,7 +447,7 @@
442447
(program check_and ((premise Bool) (premise_non_cl Bool) (index Int) (conclusion Bool))
443448
(Bool Int Bool) Bool
444449
(((check_and premise index conclusion)
445-
(cl_equal (to_cl (index_list and (from_cl premise) index))
450+
(cl_equal (to_cl (f_list_index and (from_cl premise) index))
446451
conclusion))
447452
)
448453
)
@@ -491,7 +496,7 @@
491496
(check_not_or premise_non_cl index conclusion))
492497

493498
((check_not_or (not disjuncts) index conclusion)
494-
(cl_equal (to_cl (not (index_list or disjuncts index)))
499+
(cl_equal (to_cl (not (f_list_index or disjuncts index)))
495500
conclusion))
496501
)
497502
)
@@ -570,7 +575,7 @@
570575
(program check_not_and ((conjunction Bool) (conclusion Bool))
571576
(Bool Bool) Bool
572577
(((check_not_and (not conjunction) conclusion)
573-
(cl_equal (transform_not_and conjunction) conclusion)
578+
(cl_equal (de_morgan_not_and conjunction) conclusion)
574579
)
575580
)
576581
)
@@ -877,11 +882,11 @@
877882
(Int Bool) Bool
878883
(
879884
((check_and_pos pos (@cl (not antecedent) consequent))
880-
(cl_equal (index_list and antecedent pos) consequent))
885+
(cl_equal (f_list_index and antecedent pos) consequent))
881886

882887
;; To simplify the use of the checker
883888
((check_and_pos pos (@cl consequent (not antecedent)))
884-
(cl_equal (index_list and antecedent pos) consequent))
889+
(cl_equal (f_list_index and antecedent pos) consequent))
885890
)
886891
)
887892

@@ -919,7 +924,7 @@
919924
(Bool) Bool
920925
(
921926
((check_and_neg (@cl left_disjunct right_disjunct))
922-
(cl_equal (transform_not_and left_disjunct)
927+
(cl_equal (de_morgan_not_and left_disjunct)
923928
right_disjunct))
924929
)
925930
)
@@ -970,10 +975,10 @@
970975
(Int Bool) Bool
971976
(
972977
((check_or_neg index (@cl left_disjunct (not right_disjunct)))
973-
(prop_syntax_eq (index_list or left_disjunct index) right_disjunct))
978+
(prop_syntax_eq (f_list_index or left_disjunct index) right_disjunct))
974979

975980
((check_or_neg index (@cl (not left_disjunct) right_disjunct))
976-
(prop_syntax_eq right_disjunct (index_list or left_disjunct index)))
981+
(prop_syntax_eq right_disjunct (f_list_index or left_disjunct index)))
977982
)
978983
)
979984

@@ -1632,18 +1637,17 @@
16321637
)
16331638

16341639
;TODO
1635-
(program check_prod_simplify ((l Bool) (r Bool))
1636-
(Bool Bool) Bool
1640+
(program check_prod_simplify ((conclusion Bool))
1641+
(Bool) Bool
16371642
(
1638-
((check_prod_simplify l r) true)
1643+
((check_prod_simplify conclusion) true)
16391644
)
16401645
)
16411646

16421647
;TRUST
1643-
(declare-rule prod_simplify ((l Bool) (r Bool))
1644-
:args ((@cl (= l r)))
1645-
:requires (((check_prod_simplify l r) true))
1646-
:conclusion (@cl (= l r))
1648+
(declare-rule prod_simplify ()
1649+
:requires (((check_prod_simplify eo::conclusion) true))
1650+
:conclusion-given
16471651
)
16481652

16491653
;TODO
@@ -1731,30 +1735,88 @@
17311735
:conclusion-given
17321736
)
17331737

1734-
;TODO
1735-
(program check_distinct_elim ((l Bool) (r Bool))
1738+
;;;;;;;;;;;;;;;;;;;;;;;;
1739+
; Rule 93: distinct_elim
1740+
;;;;;;;;;;;;;;;;;;;;;;;;
1741+
1742+
; program: build_distinct_list_single_elem
1743+
; args:
1744+
; - lhs Bool:
1745+
; - distinct_list Bool: a distinct-list
1746+
; return:
1747+
(program build_distinct_list_single_elem ((lhs Bool) (hd Bool) (tail Bool))
17361748
(Bool Bool) Bool
17371749
(
1738-
((check_distinct_elim l r) true)
1750+
((build_distinct_list_single_elem lhs (distinct Bool hd tail))
1751+
(and (not (= lhs hd))
1752+
(build_distinct_list_single_elem lhs (distinct Bool tail))))
1753+
1754+
; { hd is single element distinct-list }
1755+
((build_distinct_list_single_elem lhs (distinct Bool hd))
1756+
(not (= lhs hd)))
17391757
)
17401758
)
17411759

1742-
;TRUST
1743-
(declare-rule distinct_elim ((l Bool) (r Bool))
1744-
:args ((@cl (= l r)))
1745-
:requires (((check_distinct_elim l r) true))
1746-
:conclusion (@cl (= l r))
1760+
; program: check_distinct_elim
1761+
; args:
1762+
; - l Bool:
1763+
; - r Bool:
1764+
; return:
1765+
(program build_distinct_list_full_list ((lhs Bool) (rhs Bool) (tl Bool :list))
1766+
(Bool) Bool
1767+
(
1768+
((build_distinct_list_full_list (and (distinct lhs rhs) tl
1769+
))
1770+
(and (not (= lhs rhs))
1771+
(build_distinct_list_full_list tl)))
1772+
1773+
; Only one proposition
1774+
((build_distinct_list_full_list (distinct lhs rhs)) (not (= lhs rhs)))
1775+
1776+
; Only one proposition
1777+
((build_distinct_list_full_list (distinct lhs)) true)
1778+
1779+
((build_distinct_list_full_list true) true)
1780+
)
17471781
)
17481782

1749-
;;;;;;;;;;;;;;;;;;
1750-
; Rule 94: and_neg
1751-
;;;;;;;;;;;;;;;;;;
1783+
(program check_distinct_elim ((hd Bool) (tl Bool) (conjunctions Bool))
1784+
(Bool) Bool
1785+
(
1786+
((check_distinct_elim (@cl (= (distinct Bool hd tl) conjunctions)))
1787+
;; (f_list_equal and
1788+
(build_distinct_list_full_list (distinct Bool hd tl))
1789+
;; conjunctions)
1790+
)
1791+
1792+
; Only one proposition
1793+
((check_distinct_elim (@cl (= (distinct Bool hd) true))) true)
1794+
)
1795+
)
1796+
1797+
; rule: distinct_elim
1798+
; implements: TODO?
1799+
; premises:
1800+
; - distinct_elim nil:
1801+
; args:
1802+
; requires:
1803+
; conclusion:
1804+
(declare-rule distinct_elim ()
1805+
:requires (((check_distinct_elim eo::conclusion) true))
1806+
:conclusion-given
1807+
)
1808+
1809+
;;;;;;;;;;;;;;;;;;;
1810+
; Rule 94: la_rw_eq
1811+
;;;;;;;;;;;;;;;;;;;
17521812

17531813
; program: check_la_rw_eq
17541814
; args:
1755-
; - t Real:
1756-
; - u Real:
1757-
; return:
1815+
; - conclusion Bool: >
1816+
; The conclusion provided to the la_rw_eq rule. Must be build with @cl.
1817+
; return: >
1818+
; A boolean indicating if "conclusion" is a clause of the form
1819+
; (= (= t u) (and (<= t u) (<= u t))), for some numbers t and u.
17581820
(program check_la_rw_eq ((t Real) (u Real))
17591821
(Bool) Bool
17601822
(
@@ -1765,7 +1827,9 @@
17651827
; TODO: other number types. Can the equality be flipped?
17661828
; rule: la_rw_eq
17671829
; implements: TODO?
1768-
; requires:
1830+
; requires: >
1831+
; Requires for the conclusion to be a clause of the form
1832+
; (= (= t u) (and (<= t u) (<= u t))), for some numbers t and u.
17691833
; conclusion-given: >
17701834
; Only the "requires" predicate checks if a proper conclusion is given.
17711835
(declare-rule la_rw_eq ()

0 commit comments

Comments
 (0)