繁体   English   中英

支持方形交叉的几何定理证明器

[英]Geometry theorem prover with support for square intersection

我试图自动证明/反驳一些与正方形有关的几何定理,例如“对于7个不相交的正方形的每3个集合,可以从每个集合中选择1个正方形,使得3个代表是内部不相交的?”。

我尝试使用OpenGeoProver并提出了以下对方块的描述:

    <!-- define a 'free' point - the south-western corner of the square: -->
    <pfree       label="square1southwest"/>

    <!-- define a line that is parallel to the x axis and goes throught that point - the southern boundary: -->
    <lparallel   label="square1south" point="square1southwest" baseline="xaxis" />

    <!-- define a random point on the southern line, which will be the south-eastern corner: -->
    <prandline   label="square1southeast" line="square1south" />

    <!-- rotate the south-eastern corner 90 degrees around the south-western corner, to create the north-western corner: -->
    <protated    label="square1northwest" origpt="square1southeast" center="square1southwest" angmeasure="-90"/>

    <!-- translate the north-western corner by the vector between the two southern corners, to create the north-eastern corner of the square: -->
    <ptranslated label="square1northeast" origpt="square1northwest" point1="square1southwest" point2="square1southeast"/>

这就是我被困的地方:如何定义简单的语句“square A和square B intersect”?

如何在Z3中解决这个问题?

我试图用MiniZinc反驳你的定理:

int: noOfCollections = 3;
int: noOfDisjoints = 7;
int: noOfSquares = noOfCollections * noOfDisjoints;
set of int: Squares = 1..noOfSquares;
int: maxDim = 10000;  %  somewhat arbitrary limit!
int: maxLeft = maxDim;
int: maxRight = maxDim;
int: maxTop = maxDim;
int: maxBottom = maxDim;
int: maxHeight = maxBottom - 1;
int: maxWidth = maxRight - 1;

array[Squares] of var 1..maxLeft: Left;
array[Squares] of var 1..maxTop: Top;
array[Squares] of var 1..maxHeight: Height;
array[Squares] of var 1..maxWidth: Width;
array[Squares] of var bool: Representative;
array[Squares] of 1..noOfCollections: 
      Collection = [1 + (s mod noOfCollections) | s in Squares];

%  Squares must fit in the overall frame
constraint
    forall(s in Squares)(
        (Left[s] + Width[s] - 1 <= maxRight) /\
        (Top[s] + Height[s] - 1 <= maxBottom)
    );

predicate disjoint(var int: s1, var int: s2) =
    (Left[s1] + Width[s1] - 1 < Left[s2]) \/
    (Left[s2] + Width[s2] - 1 < Left[s1]) \/
    (Top[s1] + Height[s1] - 1 < Top[s2]) \/
    (Top[s2] + Height[s2] - 1 < Top[s1]);

%  Squares in a collection must be disjoint
constraint
    forall(s1 in Squares, s2 in Squares 
           where (s1 > s2) /\ (Collection[s1] == Collection[s2]))(
        disjoint(s1, s2)
    );

%   Exactly one Representative per Collection
constraint
    1 == sum(c in 1..noOfCollections, s in Squares 
             where c == 1 + (s mod noOfCollections))
           (bool2int(Representative[s]));

%   Is it possible to select 1 square from each collection such 
%   that the 3 representatives are interior disjoint?
constraint
    forall(s1 in Squares, s2 in Squares, s3 in Squares
           where (Collection[s1] == 1) /\
                 (Collection[s2] == 2) /\
                 (Collection[s3] == 3))(
        disjoint(s1, s2) /\
        disjoint(s1, s3) /\
        disjoint(s2, s3) /\
        Representative[s1] /\
        Representative[s2] /\
        Representative[s3]
    );

solve satisfy;

MiniZinc在45ms后推出“UNSAT”。

我是唯一一个将此视为算法问题的人吗?

  • 是的,标题和问题的开头有点令人困惑但是
  • 据我所知,问题是(或应该)如何实现几何陈述的证明。
  • 我认为一些重新编辑/重新标记会对它有好处

我会这样做(不会使用任何语言或框架,因为它不相关):

1.dataset定义

  • 用于定理的几何实体的总和/大小/数量(点,线,rects,......)
  • 输入数据的所有条件/约束的总和

2.dataset生成

  • 可以随机+丢弃无效实体(不匹配1)
  • 或者你可以在一定的准确度内为位置/大小生成所有有效的可能性......
  • 但由于时间和空间的复杂性,这真的很讨厌

  • 这是困难的部分

  • 你必须在表现/相关性之间做出选择
  • 我担心这项任务不能以令人满意的性能自动化
  • 相反,你必须为每个定理编写一些生成脚本

3.定理陈述

  • 这是最容易的部分
  • 只需检查该定理是否对当前数据集有效
  • 如果不是定理无效
  • 如果数据集是随机的,则使用足够大的测试次数......

语句“方形A和方形B相交”有问题

  • 我假设您在生成数据集后说明了这一点
  • 这只是子弹1的另一个条件
  • 所以你的数据集生成器必须生成相交的A,B方块
  • A - 按原样生成
  • 把B - 起点放在A里面(随机或中间或其他)

  • 另一个选项是仅选择与数据集相交的方块

  • 通过所有i = 1..N方块(A)
  • 然后通过i + 1..N方格,如果两个相交,那么它就是你的B方格

希望我离你想做的事情不太远......

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM